Ejemplo n.º 1
0
 public RemoteBattle(NetworkManager.PType protocolType, int port)
 {
     NetworkManager.AddPacketTypes();
     NetworkManager.CreateServer(NETWORK_NAME, protocolType, 10);
     NetworkManager.AddServerEventHandler(NETWORK_NAME, this.ProcessServerEvent);
     NetworkManager.StartServer(NETWORK_NAME, port);
     Logger.Log($"Server started, listening port: {port}");
 }
Ejemplo n.º 2
0
 private NetModule(NetworkManager.PType protocolType)
 {
     NetworkManager.AddPacketTypes();
     if (protocolType == NetworkManager.PType.Kcp)
     {
         NetworkManager.SetupKCP();
     }
     NetworkManager.CreateClient(NETWORK_NAME, protocolType);
     NetworkManager.AddClientEventHandler(NETWORK_NAME, this.ProcessClientEvent);
 }
Ejemplo n.º 3
0
        private void Init()
        {
            this._ready = true;

            Defs.Init(Resources.Load <TextAsset>("Defs/b_defs").text, Resources.Load <TextAsset>("Defs/lscript").text);

            UIManager.Init();

            NetworkManager.SetupKCP();
            NetworkManager.AddPacketTypes();
            Windows.CONNECTING_WIN.Open(NetworkConfig.CONNECTION_TIMEOUT / 1000f);
            NetModule.Initialize(this.useKCP ? NetworkManager.PType.Kcp : NetworkManager.PType.Tcp);
            NetModule.instance.OnSocketEvent += this.OnSocketEvent;
            NetModule.instance.Connect(this.ip, this.port);

            Windows.CONNECTING_WIN.Open(Core.Net.NetworkConfig.CONNECTION_TIMEOUT / 1000f);
        }
Ejemplo n.º 4
0
        public NetworkTest()
        {
            NetworkManager.AddPacketTypes();
            NetworkManager.CreateServer(SERVER_NAME, NetworkManager.PType.Tcp, 10);
            NetworkManager.AddServerEventHandler(SERVER_NAME, this.ProcessServerEvent);
            NetworkManager.StartServer(SERVER_NAME, 2551);

            NetworkManager.CreateClient(CLIENT_NAME, NetworkManager.PType.Tcp);
            NetworkManager.AddClientEventHandler(CLIENT_NAME, this.ProcessClientEvent);
            NetworkManager.Connect(CLIENT_NAME, "127.0.0.1", 2551);

            int i = 300;

            while (i > 0)
            {
                NetworkManager.Update(10);
                Thread.Sleep(10);
                --i;
            }
            NetworkManager.Dispose();
        }