From 00f660684dbeeaee706f6d77ebc8e2c8416e6cf0 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sun, 18 Jan 2015 00:20:05 +0100 Subject: [PATCH] devicechannel: close channel method --- src/devicechannel.vala | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/devicechannel.vala b/src/devicechannel.vala index 34cd5ce..f3652e4 100644 --- a/src/devicechannel.vala +++ b/src/devicechannel.vala @@ -34,6 +34,7 @@ class DeviceChannel : Object { private SocketConnection _conn = null; private DataOutputStream _dout = null; private DataInputStream _din = null; + private uint _srcid = 0; // channel encryption method private Crypt _crypt = null; @@ -75,11 +76,26 @@ class DeviceChannel : Object { return true; }); // attach source - source.attach(null); + _srcid = source.attach(null); connected(); } + public async void close() { + debug("closing connection"); + + if (_srcid > 0) { + Source.remove(_srcid); + _srcid = 0; + } + _din.close(); + _dout.close(); + _conn.close(); + _din = null; + _dout = null; + _conn = null; + } + /** * send: * Possibly blocking