public void Setup() { _cbs = new MockSmartCallbacks(); _bareSock = new MockSock(); _bufferPool = new ByteBufferPool(); _sock = new SmartSock(_bufferPool, _bareSock, _cbs); }
public BareSock(BufferPoolBase buffersPool, AddressFamily addressFamily, ILogger logger) { SysSock = new Socket(addressFamily, SocketType.Dgram, ProtocolType.Udp); SysSock.Blocking = false; _buffersPool = buffersPool; _logger = logger; }
public static ArraySegment <byte> ToBuffer(byte[] array, BufferPoolBase bufferPool) { var buffer = bufferPool.Get(array.Length); Array.Copy(array, buffer, array.Length); return(new ArraySegment <byte>(buffer, 0, array.Length)); }
public static ArraySegment <byte> ToBuffer(MemoryStream ms, BufferPoolBase bufferPool) { var buffer = bufferPool.Get((int)ms.Length); var array = ms.ToArray(); Array.Copy(array, buffer, array.Length); return(new ArraySegment <byte>(buffer, 0, array.Length)); }
public void Init(BufferPoolBase buffersPool, Pool <FragmentedPacket> fragPacketsPool, Pool <PacketHeader> headersPool, ushort sessionId) { _buffersPool = buffersPool; _fragPacketsPool = fragPacketsPool; _headersPool = headersPool; LastActive = Environment.TickCount; SessionId = sessionId; }
public ThreadSmartSock(SmartSock socket, BufferPoolBase buffersPool) { _socket = socket; _buffersPool = buffersPool; _ioThread = new Thread(IOLoop); _ioThread.IsBackground = true; }
public void Setup() { _cbs = new MockSmartCallbacks(); _bareSock = new MockSock(); _bufferPool = new ByteBufferPool(); _sock = new SmartSock(_bufferPool, _bareSock, _cbs); _endPoint = new IPEndPoint(IPAddress.Loopback, 23452); Utils.SendConnectRequest(_bareSock, _endPoint, _bufferPool); }
public ThreadSock(BufferPoolBase buffersPool, AddressFamily addressFamily, ILogger logger) { SysSock = new Socket(addressFamily, SocketType.Dgram, ProtocolType.Udp); _closing = false; _buffersPool = buffersPool; _logger = logger; _sendThread = new Thread(SendLoop); _sendThread.IsBackground = true; _sendThread.Start(); _receiveThread = new Thread(ReceiveLoop); _receiveThread.IsBackground = true; }
public SmartSock(BufferPoolBase buffersPool, SockBase subSock, SmartReceiverBase callbacks) { _buffersPool = buffersPool; SubSock = subSock; if (callbacks != null) { _callbacks = callbacks; } else { _callbacks = new NullSmartReceiver(); } }
public ThreadSmartSock(BufferPoolBase buffersPool, SockBase subSock, SmartReceiverBase callbacks) { _socket = new SmartSock(buffersPool, subSock, this); _buffersPool = buffersPool; if (callbacks != null) { _callbacks = callbacks; } else { _callbacks = new NullSmartReceiver(); } _ioThread = new Thread(IOLoop); _ioThread.IsBackground = true; }
public void SetSocket(SmartSock socket, BufferPoolBase bufferPool) { _servSock = socket; _bufferPool = bufferPool; }
public static void SendDisconnectResponse(MockSock bareSock, IPEndPoint endPoint, BufferPoolBase bufferPool) { ushort sessionId = 427; var header = new PacketHeader(); header.SetSessionId(sessionId); header.SetDisconnect(); var buffer = bufferPool.Get(header.HeaderLength); header.Length = (ushort)header.HeaderLength; header.WriteTo(buffer, 0); bareSock.FakeReceive(buffer, 0, header.HeaderLength, endPoint); }
public static void SendDisconnectRequest(MockSock bareSock, IPEndPoint endPoint, BufferPoolBase bufferPool) { SendDisconnectResponse(bareSock, endPoint, bufferPool); }
public AsyncSock(BufferPoolBase buffersPool, AddressFamily addressFamily) : this(buffersPool, addressFamily, new LoggerStub()) { }
public void Init(BufferPoolBase buffersPool, Pool <FragmentedPacket> fragPacketsPool, Pool <PacketHeader> headersPool) { Init(buffersPool, fragPacketsPool, headersPool, (ushort)(Rnd.Next(ushort.MaxValue) + 1)); }
public static void SendConnectRequest(MockSock bareSock, IPEndPoint endPoint, BufferPoolBase bufferPool) { var header = new PacketHeader(); header.SetSessionId(PacketHeader.EmptySessionId); header.SetConnect(); var buffer = bufferPool.Get(header.HeaderLength); header.Length = (ushort)header.HeaderLength; header.WriteTo(buffer, 0); bareSock.FakeReceive(buffer, 0, header.HeaderLength, endPoint); }
public AsyncSock(BufferPoolBase buffersPool, AddressFamily addressFamily, ILogger logger) { _buffersPool = buffersPool; _addressFamily = addressFamily; _logger = logger; }