/// <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."); } }
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; } }
/// <summary> /// Disconnects the network connection to the holographic camera rig. /// </summary> public void Disconnect() { connectionManager.DisconnectAll(); }