Esempio n. 1
0
        public void Execute()
        {
            _services.Trace.Event(TraceEventType.Start, TraceMessage.Connection);

            _baton = new Baton(_services.Memory);

            _fault = ex => { Debug.WriteLine(ex.Message); };

            _receiveSocketEvent = _services.Memory.AllocSocketEvent();
            _receiveSocketEvent.SetBuffer(_services.Memory.Empty, 0, 0);

            _frameConsumeCallback = frame =>
            {
                try
                {
                    Go(false, frame);
                }
                catch (Exception ex)
                {
                    _fault(ex);
                }
            };

            try
            {
                _socket.Blocking = false;
                _socket.NoDelay = true;
                Go(true, null);
            }
            catch (Exception ex)
            {
                _fault(ex);
            }
        }
Esempio n. 2
0
 public SocketSender(IFireflyService service, ISocket socket)
 {
     _service = service;
     _socket = socket;
     _state = State.Immediate;
     _socketEvent = _service.Memory.AllocSocketEvent();
 }
Esempio n. 3
0
        public bool SendAsync(ISocketEvent socketEvent)
        {
            lock (_sendLock)
            {
                var buffers = socketEvent.BufferList ??
                    new[] {new ArraySegment<byte>(socketEvent.Buffer, socketEvent.Offset, socketEvent.Count)};

                var byteTransfered =
                    GiveOutput(new ArraySegment<byte>(socketEvent.Buffer, socketEvent.Offset, socketEvent.Count));
                var errorCode = byteTransfered == 0 ? SocketError.IOPending : SocketError.Success;

                ((FakeSocketEvent)socketEvent).SocketError = errorCode;
                ((FakeSocketEvent)socketEvent).BytesTransferred = byteTransfered;
                return errorCode == SocketError.IOPending;
            }
        }
Esempio n. 4
0
        public bool ReceiveAsync(ISocketEvent socketEvent)
        {
            lock (_receiveLock)
            {
                if (ReceiveAsyncPaused)
                {
                    throw new InvalidOperationException(
                        "FakeSocket.Receive cannot be called when ReceiveCalled is true");
                }

                ReceiveAsyncPaused = true;
                ReceiveAsyncArgs = socketEvent;
                return TryReceiveAsync() == null;
            }
        }
 public void FreeSocketEvent(ISocketEvent socketEvent)
 {
     socketEvent.Dispose();
 }
Esempio n. 6
0
 public void FreeSocketEvent(ISocketEvent socketEvent)
 {
 }
Esempio n. 7
0
 public bool SendAsync(ISocketEvent socketEvent)
 {
     return _socket.SendAsync(((SocketEventWrapper)socketEvent).SocketAsyncEventArgs);
 }
Esempio n. 8
0
 public bool ReceiveAsync(ISocketEvent socketEvent)
 {
     return _socket.ReceiveAsync(((SocketEventWrapper)socketEvent).SocketAsyncEventArgs);
 }
Esempio n. 9
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (_socketEvent != null)
         {
             _socketEvent.Dispose();
             _socketEvent = null;
         }
         _disposed = true;
     }
 }
 public void FreeSocketEvent(ISocketEvent socketEvent)
 {
 }