UnityEngine.Networking.NetworkTransport.StartBroadcastDiscovery C# (CSharp) Method

StartBroadcastDiscovery() public static method

public static StartBroadcastDiscovery ( int hostId, int broadcastPort, int key, int version, int subversion, byte buffer, int size, int timeout, byte &error ) : bool
hostId int
broadcastPort int
key int
version int
subversion int
buffer byte
size int
timeout int
error byte
return bool
        public static bool StartBroadcastDiscovery(int hostId, int broadcastPort, int key, int version, int subversion, byte[] buffer, int size, int timeout, out byte error)
        {
            if (buffer != null)
            {
                if (buffer.Length < size)
                {
                    object[] objArray1 = new object[] { "Size: ", size, " > buffer.Length ", buffer.Length };
                    throw new ArgumentOutOfRangeException(string.Concat(objArray1));
                }
                if (size == 0)
                {
                    throw new ArgumentOutOfRangeException("Size is zero while buffer exists, please pass null and 0 as buffer and size parameters");
                }
            }
            if (buffer == null)
            {
                return StartBroadcastDiscoveryWithoutData(hostId, broadcastPort, key, version, subversion, timeout, out error);
            }
            return StartBroadcastDiscoveryWithData(hostId, broadcastPort, key, version, subversion, buffer, size, timeout, out error);
        }

Usage Example

Example #1
0
        public bool StartAsServer()
        {
            bool result;

            if (this.m_HostId != -1 || this.m_Running)
            {
                if (LogFilter.logWarn)
                {
                    Debug.LogWarning("NetworkDiscovery StartAsServer already started");
                }
                result = false;
            }
            else
            {
                this.m_HostId = NetworkTransport.AddHost(this.m_DefaultTopology, 0);
                byte b;
                if (this.m_HostId == -1)
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("NetworkDiscovery StartAsServer - addHost failed");
                    }
                    result = false;
                }
                else if (!NetworkTransport.StartBroadcastDiscovery(this.m_HostId, this.m_BroadcastPort, this.m_BroadcastKey, this.m_BroadcastVersion, this.m_BroadcastSubVersion, this.m_MsgOutBuffer, this.m_MsgOutBuffer.Length, this.m_BroadcastInterval, out b))
                {
                    if (LogFilter.logError)
                    {
                        Debug.LogError("NetworkDiscovery StartBroadcast failed err: " + b);
                    }
                    result = false;
                }
                else
                {
                    this.m_Running  = true;
                    this.m_IsServer = true;
                    if (LogFilter.logDebug)
                    {
                        Debug.Log("StartAsServer Discovery broadcasting");
                    }
                    Object.DontDestroyOnLoad(base.gameObject);
                    result = true;
                }
            }
            return(result);
        }
All Usage Examples Of UnityEngine.Networking.NetworkTransport::StartBroadcastDiscovery