示例#1
0
        public Session(Server server, Socket socket, SocketAsyncEventArgs recvSAEA, SocketAsyncEventArgs sendSAEA)
        {
            Server = server;
            m_Socket = socket;
            m_RecvSAEA = recvSAEA;
            m_SendSAEA = sendSAEA;
            m_RecvSAEA.UserToken = this;
            m_SendSAEA.UserToken = this;

            StartTime = DateTime.Now;
            LastActiveTime = StartTime;
        }
示例#2
0
        public void Stop()
        {
            if (m_ListenSocket == null)
                return;

            lock (this)
            {
                if (m_ListenSocket == null)
                    return;

                try
                {
                    m_ListenSocket.Close();
                }
                finally
                {
                    m_ListenSocket = null;
                }

                Server = null;
            }
        }
示例#3
0
 public void Dispose()
 {
     Server = null;
 }
示例#4
0
 public Listener(ServerConfig.ListenerConfig listenerConfig, Server server)
 {
     m_Config = listenerConfig;
     Server = server;
 }
示例#5
0
 public ExampleSession(Server server, Socket socket, SocketAsyncEventArgs recvSAEA, SocketAsyncEventArgs sendSAEA)
     : base(server, socket, recvSAEA, sendSAEA)
 {
 }
示例#6
0
 public void Stop()
 {
     Server = null;
 }
示例#7
0
 public Connector(Server server)
 {
     Server = server;
 }
示例#8
0
        public void Disconnect(CloseReason reason = CloseReason.Unknown)
        {
            //// 받거나 보내고 있는 중이라면 Closing으로 바꾸고 넘어가자
            //if (flagReceiving.IsTrue() || flagSending.IsTrue())
            //{
            //    flagClosing.ForceTrue();
            //    m_ClosingReason = reason;
            //    return;
            //}

            if (flagClosing.SetTrue() == true)
            {
                if (reason == CloseReason.Unknown)
                    reason = m_ClosingReason;
                else
                    m_ClosingReason = reason;

                m_SendingList.Clear();

                ArraySegment<byte> arraySeg;
                while (m_SendQueue.TryDequeue(out arraySeg))
                {
                    Server.m_PooledBufferManager.Return(arraySeg.Array);
                }

                if (m_Socket != null)
                {
                    m_Socket.CloseEx();
                    m_Socket = null;
                }

                // 얘들은 윗단에서 이벤트 받은 서버쪽에서 풀에 다시 넣는다
                //m_RecvSAEA = null;
                //m_SendSAEA = null;

                Server = null;

                OnDisconnected(reason);

                flagClosed.ForceTrue();
            }
        }