public void StopBroadcast() { if (m_HostId == -1) { if (LogFilter.logError) { Debug.LogError("NetworkDiscovery StopBroadcast not initialized"); } return; } if (!m_Running) { Debug.LogWarning("NetworkDiscovery StopBroadcast not started"); return; } if (m_IsServer) { NetworkTransport.StopBroadcastDiscovery(); } NetworkTransport.RemoveHost(m_HostId); m_HostId = -1; m_Running = false; m_IsServer = false; m_IsClient = false; m_MsgInBuffer = null; m_BroadcastsReceived = null; if (LogFilter.logDebug) { Debug.Log("Stopped Discovery broadcasting"); } }
/// <summary> /// <para>Stops listening and broadcasting.</para> /// </summary> public void StopBroadcast() { if (this.m_HostId == -1) { if (!LogFilter.logError) { return; } Debug.LogError((object)"NetworkDiscovery StopBroadcast not initialized"); } else if (!this.m_Running) { Debug.LogWarning((object)"NetworkDiscovery StopBroadcast not started"); } else { if (this.m_IsServer) { NetworkTransport.StopBroadcastDiscovery(); } NetworkTransport.RemoveHost(this.m_HostId); this.m_HostId = -1; this.m_Running = false; this.m_IsServer = false; this.m_IsClient = false; this.m_MsgInBuffer = (byte[])null; this.m_BroadcastsReceived = (Dictionary <string, NetworkBroadcastResult>)null; if (!LogFilter.logDebug) { return; } Debug.Log((object)"Stopped Discovery broadcasting"); } }
public void Stop() { if (LogFilter.logDebug) { Debug.Log("NetworkServerSimple stop "); } NetworkTransport.RemoveHost(m_ServerHostId); m_ServerHostId = -1; }
public virtual void Disconnect() { m_AsyncConnect = ConnectState.Disconnected; ClientScene.HandleClientDisconnect(m_Connection); if (m_Connection != null) { m_Connection.Disconnect(); m_Connection.Dispose(); m_Connection = null; NetworkTransport.RemoveHost(m_ClientId); } }
private void OnDestroy() { if ((this.m_IsServer && this.m_Running) && (this.m_HostId != -1)) { NetworkTransport.StopBroadcastDiscovery(); NetworkTransport.RemoveHost(this.m_HostId); } if ((this.m_IsClient && this.m_Running) && (this.m_HostId != -1)) { NetworkTransport.RemoveHost(this.m_HostId); } }
void OnDestroy() { if (m_IsServer && m_Running && m_HostId != -1) { NetworkTransport.StopBroadcastDiscovery(); NetworkTransport.RemoveHost(m_HostId); } if (m_IsClient && m_Running && m_HostId != -1) { NetworkTransport.RemoveHost(m_HostId); } }
private void OnDestroy() { if (this.m_IsServer && this.m_Running && this.m_HostId != -1) { NetworkTransport.StopBroadcastDiscovery(); NetworkTransport.RemoveHost(this.m_HostId); } if (!this.m_IsClient || !this.m_Running || this.m_HostId == -1) { return; } NetworkTransport.RemoveHost(this.m_HostId); }
/// <summary> /// <para>Disconnect from server.</para> /// </summary> public virtual void Disconnect() { this.m_AsyncConnect = NetworkClient.ConnectState.Disconnected; ClientScene.HandleClientDisconnect(this.m_Connection); if (this.m_Connection == null) { return; } this.m_Connection.Disconnect(); this.m_Connection.Dispose(); this.m_Connection = (NetworkConnection)null; NetworkTransport.RemoveHost(this.m_ClientId); this.m_ClientId = -1; }
public void Shutdown() { if (LogFilter.logDebug) { Debug.Log("Shutting down client " + this.m_ClientId); } if (this.m_ClientId != -1) { NetworkTransport.RemoveHost(this.m_ClientId); this.m_ClientId = -1; } NetworkClient.RemoveClient(this); if (NetworkClient.s_Clients.Count == 0) { NetworkClient.SetActive(false); } }
public void Shutdown() { if (LogFilter.logDebug) { Debug.Log("Shutting down client " + m_ClientId); } if (m_ClientId != -1) { NetworkTransport.RemoveHost(m_ClientId); m_ClientId = -1; } RemoveClient(this); if (s_Clients.Count == 0) { SetActive(state: false); } }
/// <summary> /// Starts sending broadcast messages. /// </summary> /// <returns>True is able to broadcast.</returns> // 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 = NetworkManager.activeTransport.AddHost(m_DefaultTopology, 0, null); if (m_HostId == -1) { if (LogFilter.logError) { Debug.LogError("NetworkDiscovery StartAsServer - addHost failed"); } return(false); } NetworkTransport.SetMulticastLock(true); byte err; if (!NetworkManager.activeTransport.StartBroadcastDiscovery(m_HostId, m_BroadcastPort, m_BroadcastKey, m_BroadcastVersion, m_BroadcastSubVersion, m_MsgOutBuffer, m_MsgOutBuffer.Length, m_BroadcastInterval, out err)) { NetworkTransport.RemoveHost(m_HostId); m_HostId = -1; 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); }
public bool RemoveHost(int hostId) { return(NetworkTransport.RemoveHost(hostId)); }