- Home /
Master Server and Faciliator connection
Hello. This is my first time ever have to ask a question about Unity, as I understand most concepts of this engine. Before my question a small details of what I'm about to ask: I have Unity 4.2, I have downloaded the Master Server and Faciliator, and place them into the Dedicated Server of which I host. I am making a small Pong Game to test my Networking skills so I can be ready to make this next project I have in mind to be ready, but first I am making a small Network Test system to fully understand of how to connect and receive, and yes, its port forwarded. I have made a Hosting Server test on 1 Unity program and registered a hosting game to the Master Server with Faciliator settings to it. It works well, and seen both consoles have accepted it.
And please NOTE, that this is the tutorial I am following for the pong game:
Unity Networking: The Pong Game
Here's the script of the Server
using UnityEngine;
using System.Collections;
public class MultiplayerManager : MonoBehaviour
{
// Assuming Master Server and Facilitator are on the same machine
public string MasterServerIP = "xxx.xxx.xxx.xxx";
void Awake()
{
Debug.Log("Starting Master Server");
// set the IP and port of the Master Server to connect to
MasterServer.ipAddress = MasterServerIP;
MasterServer.port = 23466;
// set the IP and port of the Facilitator to connect to
Network.natFacilitatorIP = MasterServerIP;
Network.natFacilitatorPort = 50005;
Network.InitializeServer(4, 4848, true);
MasterServer.RegisterHost("Game_Pong", "Goldy's Test Server", "Just testing this MasterServer out");
Debug.Log("Master Server Started");
}
}
}
Ok, now that the server is made, now for the client. So I did everything from the tutorial, but only got the Networking part to find the type of game, and get the list if available, even though it didn't say where to try to find them, like an IP address or someting. Anyways, so I followed this, and put in some Degub.Log into certain part to make sure I am getting the connection I need to get the list of games. Now, the Debug log said there is some servers up of the gameNameType i found, which is Game_Pong, but it didnt list them. I am wondering is there a full comment on how to show the list of servers than to just explain them as a short conversation? Because these types, as i am seeing them, are like quick tutorial of how to connect, instead of giving a full understanding and code idea
Here's the client to get the connection and list them.
using UnityEngine;
using System.Collections;
public class MultiplayerManager : MonoBehaviour
{
// are we currently trying to download a host list?
private bool loading = false;
// the current position within the scrollview
private Vector2 scrollPos = Vector2.zero;
void Start()
{
// immediately request a list of hosts
refreshHostList();
}
void OnGUI()
{
if( GUILayout.Button( "Refresh" ) )
{
refreshHostList();
}
if (loading)
{
GUILayout.Label("Loading...");
}
else
{
scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Width(200f), GUILayout.Height(200f));
HostData[] hosts = MasterServer.PollHostList();
Debug.Log(hosts.Length);
for (int i = 0; i < hosts.Length; i++)
{
Debug.Log(hosts.Length);
if (GUILayout.Button(hosts[i].gameName, GUILayout.ExpandWidth(true)))
{
Network.Connect(hosts[i]);
}
}
if (hosts.Length == 0)
{
GUILayout.Label("No servers running");
}
GUILayout.EndScrollView();
}
}
void refreshHostList()
{
// let the user know we are awaiting results from the master server
loading = true;
MasterServer.ClearHostList();
MasterServer.RequestHostList("Game_Pong");
}
// this is called when the Master Server reports an event to the client – for example, server registered successfully, host list received, etc
void OnMasterServerEvent( MasterServerEvent msevent )
{
Debug.Log("Might have found some servers");
if( msevent == MasterServerEvent.HostListReceived )
{
Debug.Log("Found some servers");
// received the host list, no longer awaiting results
loading = false;
}
}
}
Anyone please? I'm looking for a fast response from anyone who know of ow to fix this and get it connecting to get the list of running servers from the $$anonymous$$aster Server and Faciliator.
this makes me sad, as there is noone answering to this, and i have waited patiently for any reply. I'll just have to figure this out myself then if noone wants to answer, as i seen other questions after me, and gets a fast reply.
Don't take it personally. Networking questions get predictably slow replies. There's nothing easy about networking, and even intricate tutorials don't seem to cover the full grasp.
I personally recommend you look up GTGD (Gamer to Game Developer) on YouTube. He's a really great tutor and goes over all of the intricacies of networking with Unity's system. He also has a really great s$$anonymous$$m package called GTGD S2 (season 2) which covers exactly what you're talking about (using master server and facilitators).
Also, could you restate your question? I got lost trying to search for exactly what you're trying to ask, which may also be why you aren't getting a response.
Good luck!
@Addyarb Thanks for the reply. Ima have to look into that Season 2 of GTGD. He does have really great tuts on making $$anonymous$$ultiplayer, which i like.
Your answer
Follow this Question
Related Questions
Server reports IP to MasterServer as 127.0.0.1 0 Answers
check if ip is on server 0 Answers
Password on a server (MasterServer) 1 Answer
MasterServer.RegisterHost causing a bad frame rate? 1 Answer
Game wont initialize with MasterServer Build at home 0 Answers