- Home /
HLAPI: Can't connect to Server via Broadcast on LAN
I am trying to connect an Android Device with my Desktop for a game. That part is done. Directly inputting the IP in an inputfield, then setting the networkAdress of the networkmanager yada yada. Works perfectly fine. However, now I want to add the broadcastdiscoverer for easy access. I have a panel that adds a big button "JOIN" whenever the broadcoastdiscoverer receives a broadcast.
When you click the button, the broadcast's IP address is set for my CustomLobbyManager class. The port is set as well. Then "StartClient()" is called.
Two issues:
1) I can only ever receive a broadcast if my Desktop is the Server, and my Android is the client. Other way around no broadcast will be received by the Desktop.
2) Whenever I click the button I will get a timeout. I checked if the IP is wrong in any way, but it's the exact same. I can still connect flawlessly whenever I input the IP in my inputfield.
I am at a loss right now, is there a quirk that stops this from working?
Answer by Shenanigator · Dec 02, 2018 at 07:03 PM
Nevermind, figured it out.
Reason was I created a custom Function OnServerStart that began the broadcast, but I forgot to actually tell the networkmanager to start the server.
So basically:
public CustomNetworkManager nm;
public OverridenNetworkDiscovery nd;
public void StartAsServer()
{
nd.StartBroadcast();
nm.StartServer(); // Added this one, now it works
}
public void StartBroadcast()
{
StopBroadcast();
base.Initialize();
base.StartAsServer();
}
HOWEVER, I still can't find my phone from my desktop :)
Your answer
