示例#1
0
        public Connector(TcpService service, TcpServiceConfig.ClientConfig config, Object token)
        {
            _service = service;
            _config  = config;
            _token   = token;

            System.Net.IPAddress addr;
            System.Net.IPAddress.TryParse(_config.ip, out addr);
            EndPoint = new System.Net.IPEndPoint(addr, _config.port);
        }
示例#2
0
        public Session(TcpService service, Socket client, IMessageBuilder msgBuilder, IMessageResolver msgResolver)
        {
            this.Socket            = client;
            this.ID                = _sessionId.Generate();
            this.Service           = service;
            this._closeReason      = CloseReason.Unknown;
            this._lastActivateTime = Environment.TickCount;

            this._messageBuilder  = msgBuilder;
            this._messageResolver = msgResolver;
        }
        public virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (IsRunning)
                {
                    Stop();
                }

                _connected.Close();
                _connected = null;
            }

            _service = null;
            _thread  = null;
        }
示例#4
0
        public void Dispose(bool disposing)
        {
            if (disposing)
            {
                // send queue에 있던놈 메모리 해제 하기
                ArraySegment <byte> arraySeg;
                while (_sendQueue.TryDequeue(out arraySeg))
                {
                    Service._pooledBufferManager.Return(arraySeg.Array);
                }

                // 소켓 닫기
                try
                {
                    Socket.Close();
                    Socket = null;
                }
                catch (Exception e)
                {
                    Service.Logger.Log(LogLevel.Debug, "Socket Close 예외 발생", e);
                }

                // 타이머 종료( Dispose 되어도 비동기적으로 타이머가 호출되기 때문에 Update 가 호출될수 있음 )
                _updateTimer.Dispose();
                _updateTimer = null;

                // 닫힘 알리기
                Service.CloseSession(ID, _closeReason, _receiveEventArgs, _sendEventArgs);
                Service = null;

                if (_messageResolver != null)
                {
                    _messageResolver.OnClose(this);
                    _messageResolver = null;
                }
                if (_messageBuilder != null)
                {
                    _messageBuilder.OnClose(this);
                    _messageResolver = null;
                }
            }
        }
 public Listener(TcpService service, IPEndPoint endPoint, int backlog)
 {
     _service = service;
     EndPoint = endPoint;
     Backlog  = backlog;
 }