/// <summary> /// This method is called when the host server button is clicked /// </summary> public void StartServer() { // Create a host connection socket = Networking.Host((ushort)port, protocolType, playerCount, IsWinRT, useNat: useNatHolePunching); socket.TrackBandwidth = showBandwidth; #if !NETFX_CORE if (socket is CrossPlatformUDP) { ((CrossPlatformUDP)socket).packetDropSimulationChance = packetDropSimulationChance; ((CrossPlatformUDP)socket).networkLatencySimulationTime = networkLatencySimulationTime; } #endif if (!string.IsNullOrEmpty(masterServerIp)) { socket.connected += delegate() { ForgeMasterServer.RegisterServer(masterServerIp, (ushort)port, playerCount, "My Awesome Game Name", "Deathmatch", "Thank you for your support!", sceneName: sceneName); }; socket.playerConnected += UpdatePlayerCount; socket.playerDisconnected += UpdatePlayerCount; } Go(); }
private void RefreshServerList() { ForgeMasterServer.GetHosts(masterServerIp, 0, (HostInfo[] hosts) => { BeardedManStudios.Network.Unity.MainThreadManager.Run(delegate() { for (int i = Grid.childCount - 1; i >= 0; i--) { Destroy(Grid.GetChild(0).gameObject); } foreach (HostInfo host in hosts) { #if UNITY_EDITOR //You can get a ping from the client to a host by doing this! Networking.Ping(host, (hostInfo) => { Debug.Log(string.Format("Ping to host({0}) is: {1}", hostInfo.ipAddress, hostInfo.LastPingTime)); }); #endif GameObject gO = Instantiate(ServerListItemPrefab) as GameObject; gO.transform.parent = Grid; gO.GetComponent <ServerListItem>().SetupServerListItem(host); } }); }); }
private void RefreshServerList() { ForgeMasterServer.GetHosts(masterServerIp, 0, (HostInfo[] hosts) => { BeardedManStudios.Network.Unity.MainThreadManager.Run(delegate() { for (int i = Grid.childCount - 1; i >= 0; i--) { Destroy(Grid.GetChild(0).gameObject); } foreach (HostInfo host in hosts) { GameObject gO = Instantiate(ServerListItemPrefab) as GameObject; gO.transform.parent = Grid; gO.GetComponent <ServerListItem>().SetupServerListItem(host); } }); }); }
private void Awake() { ForgeMasterServer.SetIp(masterServerIp); }
/// <summary> /// This method is called when a player connects or disconnects in order to update the player count on Arbiter /// </summary> /// <param name="player">The player that just connected or disconnected</param> private void UpdatePlayerCount(NetworkingPlayer player) { ForgeMasterServer.UpdateServer(masterServerIp, socket.Port, socket.Players.Count); }
public void GUIServerName() { ForgeMasterServer.RegisterServer(Networking.GetExternalIPAddress(), (ushort)Networking.PrimarySocket.Port, 16, ServerNameInput.text, ((GameManager.GameMode)GameTypeInput.value).ToString("F"), "Insert comment here", null, MapNameInput.text); }