private void Cleanup() { if (mNetwork != null) { if (mIsServer) { mNetwork.StopServer(); mIsServer = false; } mNetwork.Dispose(); mNetwork = null; } }
/// <summary> /// Stops the server on the node /// </summary> /// <param name="callback">Callback for when the server stopped</param> /// <returns>If the server can be stopped</returns> public bool StopServer(Action callback) { if (m_Network == null) { return(false); } // WebRTC doesn't tell the client when the server it is connected to // goes offline. So broadcast a reserved event message to everyone, reliably Send(Packet.From(CId).WithTag(ReservedTags.ServerStopped), true); m_StopServerCallback = callback; m_Network.StopServer(); return(false); }
public void CloseServer() { if (mIsServer) { foreach (KeyValuePair <ConnectionId, ConnectionStatus> p in mConnections) { ConnectionId id = p.Key; byte[] closeData = { 0xFF, 0x00 }; mNetwork.SendData(id, closeData, 0, closeData.Length, true); } mNetwork.StopServer(); Reset(); } }
/// <summary> /// Stops the server (if it's running) /// </summary> public void StopServer() => network.StopServer();