コード例 #1
0
 public void OnStartClient()
 {
     _fixedUpdater = new FixedUpdater((int)(NetworkTime.Milliseconds), timeStepMilliseconds, time =>
     {
         _inputMessage.Time = time;
         NetworkClient.Send(_inputMessage, 1);
         NetworkInput.AddKeyMap(_inputMessage.Keymap);
         _inputMessage.Keymap = 0u;
     });
 }
コード例 #2
0
 public void Connect(System.Net.IPAddress ipAddress, int port)
 {
     if (!IsConnected)
     {
         if (_client == null)
         {
             Initalize();
         }
         StartedConnection?.Invoke();
         Action updateAction = _client.Connect(ipAddress, port);
         if (_updater == null)
         {
             GameObject updaterInstance = Instantiate(_updaterPrefab);
             DontDestroyOnLoad(updaterInstance);
             _updater = updaterInstance.GetComponent <FixedUpdater>();
         }
         _updater.UpdateAction = updateAction;
         _updater.enabled      = true;
         //start listening for
     }
 }
コード例 #3
0
 public void StartServer(int port, ushort maxClients)
 {
     if (!IsRunning)
     {
         if (_server == null)
         {
             Initalize();
         }
         Debug.Log("Starting Server");
         Action serverTicker = _server.Start(port, maxClients);
         IsRunning = true;
         if (_updater == null)
         {
             GameObject updaterInstance = Instantiate(_updaterPrefab);
             DontDestroyOnLoad(updaterInstance);
             _updater = updaterInstance.GetComponent <FixedUpdater>();
         }
         _updater.UpdateAction       = serverTicker;
         _updater.enabled            = true;
         _server.ClientConnected    += OnClientConnected;
         _server.ClientDisconnected += OnClientDisconnect;
         Started?.Invoke();
     }
 }