From 3c255f6f0dd77a8f2463c655c85fac89a7d520a5 Mon Sep 17 00:00:00 2001 From: Maciek Borzecki Date: Sat, 17 Jan 2015 15:49:47 +0100 Subject: [PATCH] devicechannel: catch send error --- src/devicechannel.vala | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/devicechannel.vala b/src/devicechannel.vala index 0cbdfc7..00a7e0f 100644 --- a/src/devicechannel.vala +++ b/src/devicechannel.vala @@ -75,11 +75,22 @@ class DeviceChannel : Object { connected(); } + /** + * send: + * Possibly blocking + * + * @param: instance of Packet + **/ public async void send(Packet pkt) { string to_send = pkt.to_string() + "\n"; debug("send data: %s", to_send); // _dout.put_string(data); - yield _conn.output_stream.write_async(to_send.data); + try { + _dout.put_string(to_send); + } catch (IOError e) { + critical("failed to send message: %s", e.message); + // TODO disconnect? + } } public async void receive(out Packet pkt) throws Error {