public override AChannel ConnectChannel(string host, int port) { IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(host), port); KChannel channel = this.CreateConnectChannel(ipEndPoint); return(channel); }
private KChannel CreateConnectChannel(IPEndPoint remoteEndPoint) { KChannel channel = new KChannel(++this.IdGenerater, this.socket, remoteEndPoint, this); this.idChannels[channel.Id] = channel; return(channel); }
public override Task <AChannel> AcceptChannel() { if (this.udpResults.Count > 0) { UdpReceiveResult udpReceiveResult = this.udpResults.Dequeue(); uint requestConn = BitConverter.ToUInt32(udpReceiveResult.Buffer, 4); KChannel kChannel = this.CreateAcceptChannel(udpReceiveResult.RemoteEndPoint, requestConn); return(Task.FromResult <AChannel>(kChannel)); } acceptTcs = new TaskCompletionSource <AChannel>(); return(this.acceptTcs.Task); }
public override AChannel ConnectChannel(IPEndPoint remoteEndPoint) { uint conv = (uint)RandomHelper.RandomNumber(1000, int.MaxValue); KChannel channel = new KChannel(conv, this.socket, remoteEndPoint, this); KChannel oldChannel; if (this.idChannels.TryGetValue(channel.Id, out oldChannel)) { this.idChannels.Remove(oldChannel.Id); oldChannel.Dispose(); } this.idChannels[channel.Id] = channel; return(channel); }