Browse Source

device: use async DeviceChannel.open()

bboozzoo/device-cache
Maciek Borzecki 10 years ago
parent
commit
e3cdb01398
1 changed files with 13 additions and 5 deletions
  1. +13
    -5
      src/device.vala

+ 13
- 5
src/device.vala View File

@ -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) {


Loading…
Cancel
Save