lightmelody

changeset 746:0608d319c258

Cleaned up open_async, catching connection errors and storing returned _stream
author Arc Riley <arcriley@gmail.com>
date Sat, 06 Jun 2015 21:13:16 -0400
parents a5cf28dbe400
children 6cd1456da9ae
files src/Connection.gs
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line diff
     1.1 --- a/src/Connection.gs	Fri Jun 05 06:31:55 2015 -0400
     1.2 +++ b/src/Connection.gs	Sat Jun 06 21:13:16 2015 -0400
     1.3 @@ -270,12 +270,14 @@
     1.4          // Store callback
     1.5          _open_func = (owned) function
     1.6  
     1.7 +        // Pass-through to the real open_async function
     1.8          self.open_async.begin((AsyncReadyCallback) _open_callfunc)
     1.9  
    1.10          return true
    1.11  
    1.12  
    1.13 -    def _open_callfunc(res : AsyncResult)
    1.14 +    def _open_callfunc(res : AsyncResult) raises Error
    1.15 +        // This is a shim callback for the deprecated open method
    1.16          _open_func(self, open_async.end(res))
    1.17  
    1.18  
    1.19 @@ -294,15 +296,21 @@
    1.20  
    1.21          // Connect using GIO
    1.22          client : SocketClient = new SocketClient()
    1.23 -        yield client.connect_to_service_async(server, "xmpp-client", null)
    1.24 +        try
    1.25 +            _stream = yield client.connect_to_service_async(server,
    1.26 +                                                            "xmpp-client")
    1.27 +        except e : GLib.Error
    1.28 +            return false
    1.29  
    1.30 +        // Success
    1.31          return true
    1.32  
    1.33  
    1.34 +    // TODO when open() is deprecated, this should be renamed to that
    1.35      def open_and_block () : bool raises Error
    1.36          client : SocketClient = new SocketClient()
    1.37          try
    1.38 -            _stream = client.connect_to_service(server, "xmpp-client", null)
    1.39 +            _stream = client.connect_to_service(server, "xmpp-client")
    1.40          except e : GLib.Error
    1.41              return false
    1.42