コード例 #1
0
 public void Awake(string address)
 {
     try
     {
         IPEndPoint        ipEndPoint       = NetworkHelper.ToIPEndPoint(address);
         NetOuterComponent networkComponent = Game.Scene.GetComponent <NetOuterComponent>();
         for (int i = 0; i < 2000; i++)
         {
             TestAsync(networkComponent, ipEndPoint, i);
         }
     }
     catch (Exception e)
     {
         Log.Exception(e);
     }
 }
コード例 #2
0
ファイル: NetworkComponent.cs プロジェクト: pinzeweifen/DCET
        public void Awake(NetworkProtocol protocol, string address, int packetSize = Packet.PacketSizeLength4)
        {
            try
            {
                IPEndPoint ipEndPoint;
                switch (protocol)
                {
                case NetworkProtocol.KCP:
                    ipEndPoint   = NetworkHelper.ToIPEndPoint(address);
                    this.Service = new KService(ipEndPoint, (channel) => { this.OnAccept(channel); })
                    {
                        Parent = this
                    };
                    break;

                case NetworkProtocol.TCP:
                    ipEndPoint   = NetworkHelper.ToIPEndPoint(address);
                    this.Service = new TService(packetSize, ipEndPoint, (channel) => { this.OnAccept(channel); })
                    {
                        Parent = this
                    };
                    break;

                case NetworkProtocol.WebSocket:
                    string[] prefixs = address.Split(';');
                    this.Service = new WService(prefixs, (channel) => { this.OnAccept(channel); })
                    {
                        Parent = this
                    };
                    break;
                }
            }
            catch (Exception e)
            {
                throw new Exception($"NetworkComponent Awake Error {address}", e);
            }
        }
コード例 #3
0
        public override AChannel ConnectChannel(string address)
        {
            IPEndPoint ipEndPoint = NetworkHelper.ToIPEndPoint(address);

            return(this.ConnectChannel(ipEndPoint));
        }