Пример #1
0
        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);
        }
Пример #2
0
        /// <summary>
        /// Stops the Server Instance.
        /// </summary>
        public void ServerStop()
        {
            // Better disconnect just in case.
            TNManager.Disconnect();

            // Stop the server.
            TNServerInstance.Stop();
        }
Пример #3
0
 public void AgentDisconnect()
 {
     if (IsConnected)
     {
         SendDestroyRemotePlayer("Some Data");
         TNManager.Disconnect();
     }
 }
Пример #4
0
        public void AgentConnect(ConnectionString connection)
        {
            // Disconnect from current server
            if (IsConnected)
            {
                TNManager.Disconnect();
            }

            TNManager.Connect(connection.IP, connection.Port);
        }
Пример #5
0
    /// <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();
        }
    }
Пример #6
0
    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();
    }
Пример #7
0
    /// <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();
        }
    }
Пример #8
0
    private void button_disconnect_onClick()
    {
        button_disconnect.interactable = false;

        TNManager.Disconnect();
    }
Пример #9
0
 public void OnDisconnect()
 {
     StopCoroutine("UpdateChannelList");
     TNManager.Disconnect();
 }