UnityEngine.Networking.NetworkDiscovery.Initialize C# (CSharp) Method

Initialize() public method

Initializes the NetworkDiscovery component.

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