From a781e7cd6bf02dd5df298117dd4050ac60905b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Obr=C3=A1til?= Date: Mon, 13 Oct 2014 14:45:17 +0200 Subject: [PATCH] Small fixes for wp8 --- src/wp8/src/SocketAdapter.cs | 8 +++++++- src/wp8/src/SocketPlugin.cs | 11 +++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/wp8/src/SocketAdapter.cs b/src/wp8/src/SocketAdapter.cs index 83892ea..07d353c 100644 --- a/src/wp8/src/SocketAdapter.cs +++ b/src/wp8/src/SocketAdapter.cs @@ -12,6 +12,7 @@ namespace Blocshop.ScoketsForCordova { Task Connect(String host, int port); Task Write(byte[] data); + void ShutdownWrite(); void Close(); SocketAdapterOptions Options { set; } Action DataConsumer { set; } @@ -55,11 +56,16 @@ namespace Blocshop.ScoketsForCordova await this.socket.SendTaskAsync(socketAsyncEventArgs); } - public void Close() + public void ShutdownWrite() { this.socket.Shutdown(SocketShutdown.Send); } + public void Close() + { + this.socket.Close(); + } + private void StartReadTask() { Task.Factory.StartNew(() => this.RunRead()); diff --git a/src/wp8/src/SocketPlugin.cs b/src/wp8/src/SocketPlugin.cs index cced065..c73d13e 100644 --- a/src/wp8/src/SocketPlugin.cs +++ b/src/wp8/src/SocketPlugin.cs @@ -58,11 +58,13 @@ namespace Blocshop.ScoketsForCordova } catch (SocketException ex) { + this.ErrorHandler(socketKey, ex); this.DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ex.Message)); socketStorage.Remove(socketKey); } catch (AggregateException ex) { + this.ErrorHandler(socketKey, ex.InnerException); this.DispatchCommandResult(new PluginResult(PluginResult.Status.IO_EXCEPTION, ex.InnerException.Message)); socketStorage.Remove(socketKey); } @@ -87,6 +89,15 @@ namespace Blocshop.ScoketsForCordova } } + public void shutdownWrite(string parameters) + { + string socketKey = JsonHelper.Deserialize(parameters)[0]; + + ISocketAdapter socket = this.socketStorage.Get(socketKey); + + socket.ShutdownWrite(); + } + public void close(string parameters) { string socketKey = JsonHelper.Deserialize(parameters)[0];