public void Receive(Buffer buffer, ConnectionIoCallback callback) { if (ReceiveAction != null) { ReceiveAction(buffer, callback); } }
internal static IOState Create(BufferManager.Buffer buffer, int bytes, IConnection connection, IBandwidthController bandwidthController, SuccessCallback onSuccess, FailureCallback onFailure) { var state = Pool.Count > 0 ? Pool.Dequeue() : new IOState(); state._buffer = buffer; state._bytes = bytes; state._pendingBytes = state._bytes; state._connection = connection; state._bandwidthController = bandwidthController; state._onSuccess = onSuccess; state._onFailure = onFailure; return(state); }
public void Send(BufferManager.Buffer buffer, ConnectionIoCallback callback) { if (CheckDisconnectedOrDisposed(callback)) { return; } var sendAsyncEventArgs = SendRecvSaeaPool.Take(); sendAsyncEventArgs.UserToken = callback; sendAsyncEventArgs.BufferList = buffer.ToArraySegmentList(); var async = _socket.SendAsync(sendAsyncEventArgs); if (!async) { SendRecvCompleted(null, sendAsyncEventArgs); } }
public void Send(Buffer buffer, ConnectionIoCallback callback) { }
public void Free(Buffer segments) { }
public void Send(byte[] data, IConnection connection, IBandwidthController bandwidthController, SuccessCallback onSuccess, FailureCallback onFailure) { var buffer = new Buffer(data); SendInternal(IOState.Create(buffer, buffer.Size, connection, bandwidthController, onSuccess, onFailure)); }
public void Receive(Buffer buffer, ConnectionIoCallback callback) { if(ReceiveAction!=null) ReceiveAction(buffer, callback); }
public void ShouldSendData() { var localConnectionWaiter = new ManualResetEvent(false); var remoteConnectionWaiter = new ManualResetEvent(false); Connection remoteConnection = null; _remote.ConnectionRequested += (sender, args) => { remoteConnection = new Connection(args.Socket); remoteConnectionWaiter.Set(); }; var localConnection = new Connection(new IPEndPoint(IPAddress.Loopback, 9999)); localConnection.Connect(c => localConnectionWaiter.Set()); WaitHandle.WaitAll(new WaitHandle[] { localConnectionWaiter, remoteConnectionWaiter }); localConnectionWaiter.Reset(); remoteConnectionWaiter.Reset(); var remoteBuffer = new Buffer(new byte[1]); remoteConnection.Receive(remoteBuffer, (i, b) => remoteConnectionWaiter.Set()); localConnection.Send(new Buffer(new byte[] { 0xf1 }), (i, b) => localConnectionWaiter.Set()); WaitHandle.WaitAll(new WaitHandle[] { localConnectionWaiter, remoteConnectionWaiter }); Assert.AreEqual(0xf1, remoteBuffer.Segment.Array[0]); }