public AChannel GetChannel(ObjectId id) { TChannel channel = null; this.idChannels.TryGetValue(id, out channel); return(channel); }
public void Remove(AChannel channel) { TChannel tChannel = channel as TChannel; if (tChannel == null) { return; } this.idChannels.Remove(channel.Id); this.channels.Remove(channel.RemoteAddress); this.timerManager.Remove(tChannel.SendTimer); }
public async Task <AChannel> GetChannel() { if (this.acceptor == null) { throw new Exception("service construct must use host and port param"); } TSocket socket = new TSocket(this.poller); await this.acceptor.AcceptAsync(socket); TChannel channel = new TChannel(socket, this); this.channels[channel.RemoteAddress] = channel; this.idChannels[channel.Id] = channel; return(channel); }
public AChannel GetChannel(string host, int port) { TChannel channel = null; if (this.channels.TryGetValue(host + ":" + port, out channel)) { return(channel); } TSocket newSocket = new TSocket(this.poller); channel = new TChannel(newSocket, host, port, this); this.channels[channel.RemoteAddress] = channel; this.idChannels[channel.Id] = channel; this.SocketConnectAsync(channel); return(channel); }
private void Dispose(bool disposing) { if (this.acceptor == null) { return; } if (disposing) { foreach (ObjectId id in this.idChannels.Keys.ToArray()) { TChannel channel = this.idChannels[id]; channel.Dispose(); } this.acceptor.Dispose(); } this.acceptor = null; }
public async Task<AChannel> GetChannel() { if (this.acceptor == null) { throw new Exception("service construct must use host and port param"); } TSocket socket = new TSocket(this.poller); await this.acceptor.AcceptAsync(socket); TChannel channel = new TChannel(socket, this); this.channels[channel.RemoteAddress] = channel; this.idChannels[channel.Id] = channel; return channel; }
public AChannel GetChannel(string host, int port) { TChannel channel = null; if (this.channels.TryGetValue(host + ":" + port, out channel)) { return channel; } TSocket newSocket = new TSocket(this.poller); channel = new TChannel(newSocket, host, port, this); this.channels[channel.RemoteAddress] = channel; this.idChannels[channel.Id] = channel; this.SocketConnectAsync(channel); return channel; }