private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (ClientSocket != null) { ClientSocket.CloseSocket(); } }
private void OnPlayerConnect(ClientSocket clientSocket, bool isReconnect) { if (_gameManager.Users.CountWithoutNull() >= _gameManager.GameConfig.MaxPlayers) { clientSocket.CloseSocket(); return; } _gameManager.AddUser(clientSocket); }
private void OnPlayerConnect(ClientSocket clientSocket, bool isReconnect) { if (!isReconnect) { _wssManager.DeviceIds.Remove(clientSocket.DeviceId); clientSocket.CloseSocket(); return; } var user = _gameManager.FindUserByDeviceId(clientSocket.DeviceId); if (user == null) { return; } user.UpdateClientSocketForReconnect(clientSocket); _playersByUser[user].Active = true; var position = _gameManager.FindUserPositionByClientSocket(user.ClientSocket); clientSocket.SendMessage(new StartGameMessage(position, _gameManager.GetAvatarList())); }
/// <summary> /// 关闭连接 /// </summary> public void CloseSocket() { m_RoomSocket.CloseSocket(); }
public void CloseSocket(ushort errorCode, string reason) => webSocket.CloseSocket(errorCode, reason);