diff --git a/src/Fleck/Interfaces/ISocket.cs b/src/Fleck/Interfaces/ISocket.cs index b6481a0..64adc7a 100644 --- a/src/Fleck/Interfaces/ISocket.cs +++ b/src/Fleck/Interfaces/ISocket.cs @@ -19,6 +19,7 @@ public interface ISocket Task Accept(Action callback, Action error); Task Send(byte[] buffer, Action callback, Action error); + Task Send(byte[] buffer, int offset, int length, Action callback, Action error); Task Receive(byte[] buffer, Action callback, Action error, int offset = 0); Task Authenticate(X509Certificate2 certificate, SslProtocols enabledSslProtocols, Action callback, Action error); diff --git a/src/Fleck/SocketWrapper.cs b/src/Fleck/SocketWrapper.cs index 379485e..77e886e 100644 --- a/src/Fleck/SocketWrapper.cs +++ b/src/Fleck/SocketWrapper.cs @@ -14,10 +14,10 @@ namespace Fleck { public class SocketWrapper : ISocket { - + public const UInt32 KeepAliveInterval = 60000; public const UInt32 RetryInterval = 10000; - + private readonly Socket _socket; private Stream _stream; private CancellationTokenSource _tokenSource; @@ -166,6 +166,10 @@ public int EndSend(IAsyncResult asyncResult) } public Task Send(byte[] buffer, Action callback, Action error) + { + return Send(buffer, 0, buffer.Length, callback, error); + } + public Task Send(byte[] buffer, int offset, int length, Action callback, Action error) { if (_tokenSource.IsCancellationRequested) return null; @@ -173,7 +177,7 @@ public Task Send(byte[] buffer, Action callback, Action error) try { Func begin = - (cb, s) => _stream.BeginWrite(buffer, 0, buffer.Length, cb, s); + (cb, s) => _stream.BeginWrite(buffer, offset, length, cb, s); Task task = Task.Factory.FromAsync(begin, _stream.EndWrite, null); task.ContinueWith(t => callback(), TaskContinuationOptions.NotOnFaulted)