From e3cdb01398bd6d7fec56726260f35d77660f3d80 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Mon, 19 Jan 2015 21:09:28 +0100 Subject: [PATCH] device: use async DeviceChannel.open() --- src/device.vala | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/device.vala b/src/device.vala index b18169b..79e76ff 100644 --- a/src/device.vala +++ b/src/device.vala @@ -125,17 +125,15 @@ class Device : Object { var core = Core.instance(); _channel = new DeviceChannel(this.host, this.tcp_port, core.crypt); - _channel.connected.connect((c) => { - this.greet.begin(); - }); _channel.disconnected.connect((c) => { this.handle_disconnect(); }); _channel.packet_received.connect((c, pkt) => { this.packet_received(pkt); }); - _channel.open.begin(); - debug("open finished"); + _channel.open.begin((c, res) => { + this.channel_openend(_channel.open.end(res)); + }); } public void deactivate() { @@ -166,6 +164,16 @@ class Device : Object { } } + + private void channel_openend(bool result) { + debug("channel openend: %s", result.to_string()); + if (result == true) { + greet(); + } else { + _channel = null; + } + } + private void packet_received(Packet pkt) { debug("got packet"); if (pkt.pkt_type == Packet.PAIR) {