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 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); }
// perform actual broadcasts public bool StartAsServer() { if (m_HostId != -1 || m_Running) { if (LogFilter.logWarn) { Debug.LogWarning("NetworkDiscovery StartAsServer already started"); } return(false); } m_HostId = NetworkTransport.AddHost(m_DefaultTopology, 0); if (m_HostId == -1) { if (LogFilter.logError) { Debug.LogError("NetworkDiscovery StartAsServer - addHost failed"); } return(false); } byte err; if (!NetworkTransport.StartBroadcastDiscovery(m_HostId, m_BroadcastPort, m_BroadcastKey, m_BroadcastVersion, m_BroadcastSubVersion, m_MsgOutBuffer, m_MsgOutBuffer.Length, m_BroadcastInterval, out err)) { if (LogFilter.logError) { Debug.LogError("NetworkDiscovery StartBroadcast failed err: " + err); } return(false); } m_Running = true; m_IsServer = true; if (LogFilter.logDebug) { Debug.Log("StartAsServer Discovery broadcasting"); } DontDestroyOnLoad(gameObject); return(true); }
/// <summary> /// <para>Starts sending broadcast messages.</para> /// </summary> /// <returns> /// <para>True is able to broadcast.</para> /// </returns> public bool StartAsServer() { if (this.m_HostId != -1 || this.m_Running) { if (LogFilter.logWarn) { Debug.LogWarning((object)"NetworkDiscovery StartAsServer already started"); } return(false); } this.m_HostId = NetworkTransport.AddHost(this.m_DefaultTopology, 0); if (this.m_HostId == -1) { if (LogFilter.logError) { Debug.LogError((object)"NetworkDiscovery StartAsServer - addHost failed"); } return(false); } byte error; 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 error)) { if (LogFilter.logError) { Debug.LogError((object)("NetworkDiscovery StartBroadcast failed err: " + (object)error)); } return(false); } this.m_Running = true; this.m_IsServer = true; if (LogFilter.logDebug) { Debug.Log((object)"StartAsServer Discovery broadcasting"); } UnityEngine.Object.DontDestroyOnLoad((UnityEngine.Object) this.gameObject); return(true); }
public bool StartBroadcastDiscovery(int hostId, int broadcastPort, int key, int version, int subversion, byte[] buffer, int size, int timeout, out byte error) { return(NetworkTransport.StartBroadcastDiscovery(hostId, broadcastPort, key, version, subversion, buffer, size, timeout, out error)); }