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(); }
public override AChannel ConnectChannel(IPEndPoint ipEndPoint) { TChannel channel = new TChannel(ipEndPoint, this); idChannels[channel.Id] = channel; return(channel); }
public override AChannel GetChannel(long id) { TChannel channel = null; idChannels.TryGetValue(id, out channel); return(channel); }
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(); }