Small fixes for wp8

This commit is contained in:
Martin Obrátil 2014-10-13 14:45:17 +02:00
parent 4b99d73adf
commit a781e7cd6b
2 changed files with 18 additions and 1 deletions

View File

@ -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<byte[]> 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());

View File

@ -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<string[]>(parameters)[0];
ISocketAdapter socket = this.socketStorage.Get(socketKey);
socket.ShutdownWrite();
}
public void close(string parameters)
{
string socketKey = JsonHelper.Deserialize<string[]>(parameters)[0];