public bool Initialize()
{
bool result;
if (this.m_BroadcastData.Length >= 1024)
{
if (LogFilter.logError)
{
Debug.LogError("NetworkDiscovery Initialize - data too large. max is " + 1024);
}
result = false;
}
else
{
if (!NetworkTransport.IsStarted)
{
NetworkTransport.Init();
}
if (this.m_UseNetworkManager && NetworkManager.singleton != null)
{
this.m_BroadcastData = string.Concat(new object[]
{
"NetworkManager:",
NetworkManager.singleton.networkAddress,
":",
NetworkManager.singleton.networkPort
});
if (LogFilter.logInfo)
{
Debug.Log("NetworkDiscovery set broadcast data to:" + this.m_BroadcastData);
}
}
this.m_MsgOutBuffer = NetworkDiscovery.StringToBytes(this.m_BroadcastData);
this.m_MsgInBuffer = new byte[1024];
this.m_BroadcastsReceived = new Dictionary <string, NetworkBroadcastResult>();
ConnectionConfig connectionConfig = new ConnectionConfig();
connectionConfig.AddChannel(QosType.Unreliable);
this.m_DefaultTopology = new HostTopology(connectionConfig, 1);
if (this.m_IsServer)
{
this.StartAsServer();
}
if (this.m_IsClient)
{
this.StartAsClient();
}
result = true;
}
return(result);
}