예제 #1
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (ClientSocket != null)
     {
         ClientSocket.CloseSocket();
     }
 }
예제 #2
0
        private void OnPlayerConnect(ClientSocket clientSocket, bool isReconnect)
        {
            if (_gameManager.Users.CountWithoutNull() >= _gameManager.GameConfig.MaxPlayers)
            {
                clientSocket.CloseSocket();
                return;
            }

            _gameManager.AddUser(clientSocket);
        }
예제 #3
0
        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()));
        }
예제 #4
0
 /// <summary>
 /// 关闭连接
 /// </summary>
 public void CloseSocket()
 {
     m_RoomSocket.CloseSocket();
 }
예제 #5
0
 public void CloseSocket(ushort errorCode, string reason)
 => webSocket.CloseSocket(errorCode, reason);