コード例 #1
0
ファイル: KService.cs プロジェクト: Eagle-Lai/Egametang
        public override AChannel ConnectChannel(string host, int port)
        {
            IPEndPoint ipEndPoint = new IPEndPoint(IPAddress.Parse(host), port);
            KChannel   channel    = this.CreateConnectChannel(ipEndPoint);

            return(channel);
        }
コード例 #2
0
ファイル: KService.cs プロジェクト: Eagle-Lai/Egametang
        private KChannel CreateConnectChannel(IPEndPoint remoteEndPoint)
        {
            KChannel channel = new KChannel(++this.IdGenerater, this.socket, remoteEndPoint, this);

            this.idChannels[channel.Id] = channel;
            return(channel);
        }
コード例 #3
0
ファイル: KService.cs プロジェクト: Eagle-Lai/Egametang
        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);
        }
コード例 #4
0
        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);
        }