// TODO client callbacks don't need NetworkConnection parameter. use NetworkClient.connection! protected void ClientReject(NetworkConnection conn) { // Set this on the client for local reference conn.isAuthenticated = false; // disconnect the client conn.Disconnect(); }
/// <summary> /// Called on the server when a new client connects. /// <para>Unity calls this on the Server when a Client connects to the Server. Use an override to tell the NetworkManager what to do when a client connects to the server.</para> /// </summary> /// <param name="conn">Connection from client.</param> public override void OnServerConnect(NetworkConnection conn) { if (numPlayers >= maxConnections) { conn.Disconnect(); return; } // cannot join game in progress if (!IsSceneActive(RoomScene)) { conn.Disconnect(); return; } base.OnServerConnect(conn); OnRoomServerConnect(conn); }
/// <summary> /// /// </summary> /// <param name="conn">Connection of the client</param> public override void OnServerConnect(NetworkConnection conn) { if (numPlayers >= maxConnections) { conn.Disconnect(); return; } // cannot join game in progress if (SceneManager.GetActiveScene().name != RoomScene) { conn.Disconnect(); return; } base.OnServerConnect(conn); OnRoomServerConnect(conn); }
public static void DisconnectAllConnections() { foreach (KeyValuePair <int, NetworkConnection> kvp in connections) { NetworkConnection conn = kvp.Value; conn.Disconnect(); conn.Dispose(); } }
protected void ClientReject(NetworkConnection conn) { Debug.Log("Client reject called, disconnecting."); // Set this on the client for local reference conn.isAuthenticated = false; // disconnect the client conn.Disconnect(); }
public virtual void Disconnect() { connectState = ConnectState.Disconnected; ClientScene.HandleClientDisconnect(m_Connection); if (m_Connection != null) { m_Connection.Disconnect(); m_Connection.Dispose(); m_Connection = null; m_ClientId = -1; } }
public static void DisconnectAllConnections() { for (int i = 0; i < connections.Count; i++) { NetworkConnection conn = connections[i]; if (conn != null) { conn.Disconnect(); conn.Dispose(); } } }
// ------------------------ server handlers ------------------------ public override void OnServerConnect(NetworkConnection conn) { // numPlayers returns the player count including this one, so ok to be equal if (numPlayers > maxPlayers) { if (LogFilter.logWarn) { Debug.LogWarning("NetworkLobbyManager can't accept new connection [" + conn + "], too many players connected."); } conn.Disconnect(); return; } // cannot join game in progress string loadedSceneName = SceneManager.GetSceneAt(0).name; if (loadedSceneName != m_LobbyScene) { if (LogFilter.logWarn) { Debug.LogWarning("NetworkLobbyManager can't accept new connection [" + conn + "], not in lobby and game already in progress."); } conn.Disconnect(); return; } base.OnServerConnect(conn); // when a new client connects, set all old players as dirty so their current ready state is sent out for (int i = 0; i < lobbySlots.Length; ++i) { if (lobbySlots[i]) { lobbySlots[i].SetDirtyBit(1); } } OnLobbyServerConnect(conn); }
public static void DisconnectAllConnections() { foreach (KeyValuePair<int, NetworkConnection> kvp in connections) { NetworkConnection conn = kvp.Value; conn.Disconnect(); // call OnDisconnected unless local player in host mode if (conn.connectionId != 0) OnDisconnected(conn); conn.Dispose(); } connections.Clear(); }
protected void ServerReject(NetworkConnection conn) { conn.Disconnect(); }