public ITcpSession Pop() { ITcpSession session; if (!pool.TryDequeue(out session)) { if (Interlocked.Increment(ref count) <= TcpServer.Config.MaxConnections) { session = new TcpSession(); session.SessionId = sessionId.NewId(); session.Pool = this; session.ReceiveBuffer = new byte[TcpServer.Config.BufferSize]; session.PacketProtocol = TcpServer.GetProtocol(); session.PacketProtocol.Session = session; } else { TcpServer.Loger.Warning("session count attain maxnum"); } } if (session != null) { activeDict.TryAdd(session.SessionId, session); session.ConnectDateTime = DateTime.Now; session.ActiveDateTime = DateTime.Now; } return(session); }
public Connect GetConnect() { var connect = new Connect(Config); connect.SessionId = sessionId.NewId(); connect.Connect(); connect.RpcContainer = rpcContainer; return(connect); }
public ITcpClientSession Pop() { ITcpClientSession session; if (!pool.TryDequeue(out session)) { if (Interlocked.Increment(ref count) <= maxSessions) { session = new TcpClientSession(remoteEndPoint, bufferSize, loger); session.Pool = this; session.SessionId = sessionId.NewId(); session.PacketProtocol = GetProtocal(); } } if (session != null) { activeDict.TryAdd(session.SessionId, session); } return(session); }
public IRUdpSession Pop() { IRUdpSession session; if (!pool.TryDequeue(out session)) { if (Interlocked.Increment(ref count) <= RUdpServer.Config.MaxConnections) { session = new RUdpSession(); session.SessionId = sessionId.NewId(); session.Pool = this; session.PacketProtocol = RUdpServer.GetProtocol(); session.PacketProtocol.Session = session; } else { RUdpServer.Loger.Warning("session count attain maxnum"); } } return(session); }