Example #1
0
    private void ConnectToServer()
    {
        ICEventfulNetworkDiscovery networkDiscovery = GetNetworkDiscovery();

        if (networkDiscovery.servers.ContainsKey(serverList.selectedItem))
        {
            var server = networkDiscovery.servers[serverList.selectedItem];
            var parts  = server.Data.Split(':');

            var address = parts[1];
            int port;
            int.TryParse(parts[2], out port);

            experimentSetup.StartClient(address, port);
        }
    }
Example #2
0
    /**
     * Returns an instance of the ICEventfulNetworkDiscovery.
     */
    public static ICEventfulNetworkDiscovery GetNetworkDiscovery()
    {
        GameObject networkManagerObject = GameObject.Find("NetworkManager");

        if (!networkManagerObject)
        {
            networkManagerObject = new GameObject();
        }

        ICEventfulNetworkDiscovery networkDiscovery = networkManagerObject.GetComponent <ICEventfulNetworkDiscovery>();

        if (!networkDiscovery)
        {
            networkDiscovery = networkManagerObject.AddComponent <ICEventfulNetworkDiscovery>();
            networkDiscovery.useNetworkManager = false;
        }

        return(networkDiscovery);
    }