Beispiel #1
0
        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);
        }
 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;
 }