I am trying to get the broadcasted message in overridden method of NetworkDiscovery.OnReceivedBroadcast(). For that what I had done is below:
- I create class which implements NetworkDiscovery where I override the method OnReceivedBroadcast() to capture the broadcast messages.
- In Unity Editor, I created an empty GameObject where I add the class in step #1 as component.
Now in code, I started the custom NetworkDiscovery class as below:
Discovery.Initialize();
Discovery.StartAsClient();
Now, when I start the broadcast in server, I am not receiving any broadcast message in OnReceivedBroadcast().
Below is my custom NetworkDiscovery class.
public class CustomNetworkDiscovery : NetworkDiscovery
{
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public override void OnReceivedBroadcast(string fromAddress, string data)
{
base.OnReceivedBroadcast(fromAddress, data);
}
}
One thing I noted is, If I use the NetworkDiscovery component directly in step #2; instead of using custom NetworkDiscovery class. I am able to see broadcast messages in it's default GUI.
How can I receive the broadcast message in the inherited class?
Any help will be appreciated. Thanks.