Ejemplo n.º 1
0
        public static void ReceiveCommond(object sender, ReceiveCommond cmd)
        {
            TcpClientSession session = sender as TcpClientSession;
            string           msg     = Encoding.UTF8.GetString(cmd.Data);

            //li.Add(string.Format("sessionId:{0},cmdId:{1},msg:{2}", session.SessionId, cmd.CommondId, msg));
            Console.WriteLine("sessionId:{0},cmdId:{1},msg:{2}", session.SessionId, cmd.CommondId, msg);
        }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
0
        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);
        }