public bool ServerStart(string serverName) { Debug.Log("Server start " + serverName); // Check if we already have a local server running if (TNServerInstance.isActive) { return(false); } // Don't want you being connected to a server and making your own if (IsConnected) { TNManager.Disconnect(); } // Someone order a name? TNServerInstance.serverName = serverName; // Start it ... or not ... we'll let it decide. TNServerInstance.Start(TCPPort, UDPPort, "", LANPort); // Connect to server I created AgentConnect(new ConnectionString("127.0.0.1", TCPPort)); return(true); }
/// <summary> /// Stops the Server Instance. /// </summary> public void ServerStop() { // Better disconnect just in case. TNManager.Disconnect(); // Stop the server. TNServerInstance.Stop(); }
public void AgentDisconnect() { if (IsConnected) { SendDestroyRemotePlayer("Some Data"); TNManager.Disconnect(); } }
public void AgentConnect(ConnectionString connection) { // Disconnect from current server if (IsConnected) { TNManager.Disconnect(); } TNManager.Connect(connection.IP, connection.Port); }
/// <summary> /// The disconnect button is only shown if we are currently connected. /// </summary> void DrawDisconnectButton() { Rect rect = new Rect(Screen.width - buttonWidth, Screen.height - buttonHeight, buttonWidth, buttonHeight); if (GUI.Button(rect, "Disconnect", button)) { // Disconnecting while in some channel will cause "OnNetworkLeaveChannel" to be sent out first, // followed by "OnNetworkDisconnect". Disconnecting while not in a channel will only trigger // "OnNetworkDisconnect". TNManager.Disconnect(); } }
public void Disconnect() { // find other players var otherplayers = TNManager.GetPlayers(channelID); if (otherplayers.Count > 0) { var newHost = otherplayers.buffer[0]; TNManager.SetHost(channelID, newHost); gameEvents.OnChangeHost.Invoke(newHost.id); } // Debug.Log("Disconnecting"); TNManager.Disconnect(); }
/// <summary> /// Joined a channel (or failed to). /// </summary> void OnNetworkJoinChannel(bool result, string message) { if (result) { if (!string.IsNullOrEmpty(successFunctionName)) { UnityTools.Broadcast(successFunctionName); } } else { if (!string.IsNullOrEmpty(failureFunctionName)) { UnityTools.Broadcast(failureFunctionName, message); } else { Debug.LogError(message); } TNManager.Disconnect(); } }
private void button_disconnect_onClick() { button_disconnect.interactable = false; TNManager.Disconnect(); }
public void OnDisconnect() { StopCoroutine("UpdateChannelList"); TNManager.Disconnect(); }