Esempio n. 1
0
 public void Receive(Buffer buffer, ConnectionIoCallback callback)
 {
     if (ReceiveAction != null)
     {
         ReceiveAction(buffer, callback);
     }
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
 public void Send(Buffer buffer, ConnectionIoCallback callback)
 {
 }
Esempio n. 5
0
 public void Free(Buffer segments)
 {
 }
Esempio n. 6
0
 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 Send(Buffer buffer, ConnectionIoCallback callback)
 {
 }
 public void Receive(Buffer buffer, ConnectionIoCallback callback)
 {
     if(ReceiveAction!=null) ReceiveAction(buffer, callback);
 }
 public void Free(Buffer segments)
 {
 }
Esempio n. 10
0
        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]);
        }