- Home /
UNET : Custom Master server question.
Hello, folks. I'm trying to run my self-made master server with Unet. That i'm trying to achieve:
1) Client requests a list of active games.
2) Server responses with a "message" that contains a structure with some gameinfo AND ipAdress of another client what established his own game lobby.
3) Client connects to other player lobby via ip he recieved from "message".
The thing is... unity cant send a Connection via connection.Send(). Actually it can but.. with crashes in runtime on message deserialization. AS well as when trying to send List<> via NetworkMessage. So, ok, basic arrays only.
So, i can send an ip adress as string (yep, moar strings via network!) in my "message". But, there is a problem. When i want to connect to a regular UNet.connection i just use:
conn.Connect(desc.ipAdress, desc.port);
But since i've send ipAdress via string i dont have port in it. Okay i could create all custom games on the same specific port, lets say ":6666"(wish me luck).
So i could use something like this:
public void OnGamesList(NetworkMessage _msg) {
deserializedMsg = _msg.conn.Read ...
ipAdressOfSpecificGameLobby = deserializedMsg.gameInfoStruct[0].ipAdress;
}
....
NetworkClient userMachine = new NetworkClient ();
userMachine.Connect(ipAdressOfSpecificGameLobby , predefinedPort);
But there is a thing that conserns me:
When i was testing my master server for basic connections, i've opened a specific port with my router toolkit (168.192.1.1 e t c). So other PC's can connect to my static IP via this port(Works fine. But not fine without openning a port).
But when we talking about players they will not do this so...how could i connect to them? I mean they have all these ports closed by default.
Thanx for your time!