Question by
cdalyz · Nov 05, 2016 at 03:43 PM ·
networkingserverclientclient-serverlan
LAN Auto find server/host
I have 2 simple methods which are attached to 2 buttons, one starts as the host and one starts as a client, these both work fine. I would like to just have 1 button, which will check if there is an existing game. if there is - use my BeTheClient() method if not - use the BeTheServer() method i have tried everything and am open to suggestion - very new to unity networking.
public override void OnReceivedBroadcast(string fromAddress, string data)
{
Debug.Log("recieved broadcast");
NetworkManager.singleton.networkAddress = fromAddress;
// NetworkManager.singleton.StartHost();
NetworkManager.singleton.StartClient();
this.StopBroadcast ();
}
public void BeTheServer(){
Initialize();
NetworkManager.singleton.StartHost ();
StartAsServer();
}
public void BeTheClient(){
Initialize();
StartAsClient();
}
Comment