public ServerSession(SessionCreateInfo createInfo) { SessionId = createInfo.SessionId; _tcpChannel = createInfo.TcpChannel; if (_tcpChannel != null) { _tcpChannel.PacketReceived = OnReceiveFromChannel; } _udpChannel = createInfo.UdpChannel; if (_udpChannel != null) { _udpChannel.PacketReceived = OnReceiveFromChannel; } _request = new SessionRequest(this, createInfo.Statistic); }
public DefaultSessionFactory( ServerOption serverOption, ILoggerFactory loggerFactory, NetStatistic statistic, Func <SessionCreateInfo, ServerSession> createSessionFunc = null) { createSessionFunc = createSessionFunc ?? CreateSession; _sessionQueue = new ConcurrentQueue <ISession>(); _maxSession = serverOption.MaxSession; var createInfo = new SessionCreateInfo(); for (int i = 0; i < _maxSession; ++i) { TcpChannel tcpChannel = new TcpChannel( serverOption, loggerFactory.CreateLogger(nameof(TcpChannel)), statistic); UdpChannel udpChannel = null; if (serverOption.IsServiceUdp) { udpChannel = new UdpChannel( serverOption, loggerFactory.CreateLogger(nameof(UdpChannel)), statistic, 0); } createInfo.SessionId = (ushort)(i + 1); createInfo.TcpChannel = tcpChannel; createInfo.UdpChannel = udpChannel; createInfo.Statistic = statistic; ServerSession session = createSessionFunc(createInfo); _sessionQueue.Enqueue(session); } }
private ServerSession CreateSession(SessionCreateInfo createInfo) { return(new ServerSession(createInfo)); }
public UserSession(SessionCreateInfo createInfo) : base(createInfo) { }