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