public override AChannel GetChannel(long id) { TChannel rChannel = null; this.mIdChannels.TryGetValue(id, out rChannel); return(rChannel); }
public override AChannel ConnectChannel(IPEndPoint rIpEndPoint) { TcpClient tcpClient = new TcpClient(); TChannel rChannel = new TChannel(tcpClient, rIpEndPoint, this); this.mIdChannels[rChannel.Id] = rChannel; return(rChannel); }
public override async Task <AChannel> AcceptChannel() { if (this.mAcceptor == null) { throw new Exception("service construct must use host and port param"); } TcpClient rTcpClient = await this.mAcceptor.AcceptTcpClientAsync(); TChannel rChannel = new TChannel(rTcpClient, this); this.mIdChannels[rChannel.Id] = rChannel; return(rChannel); }
public override void Dispose() { if (this.mAcceptor == null) { return; } foreach (long id in this.mIdChannels.Keys.ToArray()) { TChannel channel = this.mIdChannels[id]; channel.Dispose(); } this.mAcceptor.Stop(); this.mAcceptor = null; }