Beispiel #1
0
        private void OnAcceptComplete(object o)
        {
            if (this.m_Acceptor == null)
            {
                return;
            }
            SocketAsyncEventArgs e = (SocketAsyncEventArgs)o;

            if (e.SocketError != SocketError.Success)
            {
                Log.Error($"accept error {e.SocketError}");
                this.AcceptAsync();
                return;
            }
            TChannel channel = new TChannel(e.AcceptSocket, this);

            this.m_IdChannels[channel.Id] = channel;

            try
            {
                this.OnAccept(channel);
            }
            catch (Exception exception)
            {
                Log.Error(exception);
            }

            if (this.m_Acceptor == null)
            {
                return;
            }

            this.AcceptAsync();
        }
Beispiel #2
0
        public override AChannel GetChannel(long id)
        {
            TChannel channel = null;

            this.m_IdChannels.TryGetValue(id, out channel);
            return(channel);
        }
Beispiel #3
0
        public override AChannel ConnectChannel(IPEndPoint ipEndPoint)
        {
            TChannel channel = new TChannel(ipEndPoint, this);

            this.m_IdChannels[channel.Id] = channel;

            return(channel);
        }
Beispiel #4
0
        public override void Dispose()
        {
            base.Dispose();

            foreach (long id in this.m_IdChannels.Keys.ToArray())
            {
                TChannel channel = this.m_IdChannels[id];
                channel.Dispose();
            }
            this.m_Acceptor?.Close();
            this.m_Acceptor = null;
            this.m_InnArgs.Dispose();
            m_UpdateTime.Dispose();
        }