コード例 #1
0
 /// <summary>
 /// Disconnects the network connection to the holographic camera rig.
 /// </summary>
 public void Disconnect()
 {
     if (connectionManager != null)
     {
         connectionManager.DisconnectAll();
     }
     else
     {
         Debug.LogError($"Failed to disconnect: {nameof(connectionManager)} was not assigned.");
     }
 }
コード例 #2
0
        private void Update()
        {
            if (connectionManager.Connections.Count == 0)
            {
                return;
            }

            if (broadcastSent &&
                broadcastReceived)
            {
                Debug.Log("Broadcasts sent and received, attempting to disconnect");
                connectionManager.DisconnectAll();
                Debug.Log("INetworkConnectionManager has disconnected");
            }
            else if ((Time.time - lastBroadcast) > timeBetweenBroadcasts)
            {
                var message = runAsServer ? "Message from server" : "Message from client";
                var data    = Encoding.ASCII.GetBytes(message);
                connectionManager.Broadcast(data, 0, data.Length);
                broadcastSent = true;

                lastBroadcast = Time.time;
            }
        }