/// <inheritdoc />
        public void Connect()
        {
            if (net == null)
            {
                Debug.LogError("TCPConnectionManager not set for SocketNetworkingService. Unable to establish connection");
                return;
            }
            else
            {
                net.DisconnectAll();
            }

            net.OnConnected    += OnConnected;
            net.OnDisconnected += OnDisconnected;
            net.OnReceive      += OnReceive;

            if (runAsUser)
            {
                net.StartListening(userPort);
            }
            else
            {
                net.ConnectTo(userAddress, userPort);
            }
        }
 /// <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.");
     }
 }
예제 #3
0
        private void Update()
        {
            if (!connectionManager.HasConnections)
            {
                return;
            }

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

                lastBroadcast = Time.time;
            }
        }
예제 #4
0
 /// <summary>
 /// Disconnects the network connection to the holographic camera rig.
 /// </summary>
 public void Disconnect()
 {
     connectionManager.DisconnectAll();
 }