Esempio n. 1
0
        private void OnAcceptComplete(object o)
        {
            if (acceptor == null)
            {
                return;
            }
            SocketAsyncEventArgs e = (SocketAsyncEventArgs)o;

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

            idChannels[channel.Id] = channel;

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

            if (acceptor == null)
            {
                return;
            }

            AcceptAsync();
        }
Esempio n. 2
0
        public override AChannel ConnectChannel(IPEndPoint ipEndPoint)
        {
            TChannel channel = new TChannel(ipEndPoint, this);

            idChannels[channel.Id] = channel;
            return(channel);
        }
Esempio n. 3
0
        public override AChannel GetChannel(long id)
        {
            TChannel channel = null;

            idChannels.TryGetValue(id, out channel);
            return(channel);
        }
Esempio n. 4
0
 public override void Dispose()
 {
     if (IsDisposed)
     {
         return;
     }
     foreach (long id in idChannels.Keys.ToArray())
     {
         TChannel channel = idChannels[id];
         channel.Dispose();
     }
     acceptor?.Close();
     acceptor = null;
     innArgs.Dispose();
 }