public AsyncTcpSocketSession( TcpClient tcpClient, AsyncTcpSocketServerConfiguration configuration, IBufferManager bufferManager, IAsyncTcpSocketServerMessageDispatcher dispatcher, AsyncTcpSocketServer server) { if (tcpClient == null) throw new ArgumentNullException("tcpClient"); if (configuration == null) throw new ArgumentNullException("configuration"); if (bufferManager == null) throw new ArgumentNullException("bufferManager"); if (dispatcher == null) throw new ArgumentNullException("dispatcher"); if (server == null) throw new ArgumentNullException("server"); _tcpClient = tcpClient; _configuration = configuration; _bufferManager = bufferManager; _dispatcher = dispatcher; _server = server; _sessionKey = Guid.NewGuid().ToString(); this.StartTime = DateTime.UtcNow; _remoteEndPoint = (_tcpClient != null && _tcpClient.Client.Connected) ? (IPEndPoint)_tcpClient.Client.RemoteEndPoint : null; _localEndPoint = (_tcpClient != null && _tcpClient.Client.Connected) ? (IPEndPoint)_tcpClient.Client.LocalEndPoint : null; }
public AsyncTcpSocketSession( TcpClient tcpClient, AsyncTcpSocketServerConfiguration configuration, IBufferManager bufferManager, IAsyncTcpSocketServerMessageDispatcher dispatcher, AsyncTcpSocketServer server) { if (tcpClient == null) { throw new ArgumentNullException("tcpClient"); } if (configuration == null) { throw new ArgumentNullException("configuration"); } if (bufferManager == null) { throw new ArgumentNullException("bufferManager"); } if (dispatcher == null) { throw new ArgumentNullException("dispatcher"); } if (server == null) { throw new ArgumentNullException("server"); } _tcpClient = tcpClient; _configuration = configuration; _bufferManager = bufferManager; _dispatcher = dispatcher; _server = server; _sessionKey = Guid.NewGuid().ToString(); this.StartTime = DateTime.UtcNow; _remoteEndPoint = (_tcpClient != null && _tcpClient.Client.Connected) ? (IPEndPoint)_tcpClient.Client.RemoteEndPoint : null; _localEndPoint = (_tcpClient != null && _tcpClient.Client.Connected) ? (IPEndPoint)_tcpClient.Client.LocalEndPoint : null; }
public override void Initialize(string typename, Dictionary<string, ParaItem> paras) { //config if (paras.ContainsKey("port")) { Port = Int32.Parse(paras["port"].Values.FirstOrDefault()); } if (paras.ContainsKey("host")) { Host =paras["host"].Values.FirstOrDefault(); } var dispatcher = new SimpleMessageDispatcher(); dispatcher.Rev += (o,e) => { this.Rev(o, e); }; srv = new AsyncTcpSocketServer(IPAddress.Parse(Host), Port, dispatcher, new AsyncTcpSocketServerConfiguration() { FrameBuilder = new LineBasedFrameBuilder(LineDelimiter.WINDOWS) }); srv.Listen(); }