示例#1
0
文件: TService.cs 项目: taigacon/ET
        private void OnAcceptComplete(object sender, SocketAsyncEventArgs o)
        {
            if (this.acceptor == null)
            {
                return;
            }
            SocketAsyncEventArgs e = o;

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

            this.idChannels[channel.InstanceId] = channel;

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

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

            this.AcceptAsync();
        }
示例#2
0
文件: TService.cs 项目: taigacon/ET
        public override AChannel GetChannel(ulong id)
        {
            TChannel channel = null;

            this.idChannels.TryGetValue(id, out channel);
            return(channel);
        }
示例#3
0
文件: TService.cs 项目: taigacon/ET
        public override AChannel ConnectChannel(IPEndPoint ipEndPoint)
        {
            TChannel channel = new TChannel(ipEndPoint, this);

            this.idChannels[channel.InstanceId] = channel;

            return(channel);
        }
示例#4
0
文件: TService.cs 项目: taigacon/ET
        public override void Dispose()
        {
            if (this.IsDisposed)
            {
                return;
            }

            base.Dispose();

            foreach (ulong id in this.idChannels.Keys.ToArray())
            {
                TChannel channel = this.idChannels[id];
                channel.Dispose();
            }
            this.acceptor?.Close();
            this.acceptor = null;
            this.innArgs.Dispose();
        }