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