Exemplo n.º 1
0
 private static void ClientJoinGameRequest(Socket clientSocket, List <string> content)
 {
     CuentaNetwork.JoinGame(int.Parse(content[1]), int.Parse(content[2]), false);
     Send(clientSocket, CreatePackage(new object[] {
         (byte)NetworkServerResponses.PlayerJoined
     }));
 }
Exemplo n.º 2
0
        private static void ClientRegisterRequest(Socket clientSocket, List <string> content)
        {
            var networkServerResponse = NetworkServerResponses.RegisterSuccess;

            if (!CuentaNetwork.TryRegister(content[1], content[2], content[3]))
            {
                networkServerResponse = NetworkServerResponses.RegisterError;
            }
            IList <ArraySegment <byte> > serverResponse = CreateServerResponse(networkServerResponse);

            Send(clientSocket, serverResponse);
        }
Exemplo n.º 3
0
        private static void ClientCreateGameRequest(Socket clientSocket, List <string> content)
        {
            var serverResponse = (byte)NetworkServerResponses.GameCreated;

            if (!CuentaNetwork.CreateGame(int.Parse(content[1])))
            {
                serverResponse = (byte)NetworkServerResponses.CreateGameError;
            }
            Send(clientSocket, CreatePackage(new List <Dictionary <string, object> >()
            {
                { new Dictionary <string, object>()
                  {
                      { "code", serverResponse }
                  } }
            }));
        }
Exemplo n.º 4
0
        private static void ClientLoginRequest(Socket clientSocket, List <string> content)
        {
            Dictionary <string, object> accountData = CuentaNetwork.TryLogin(content[1], content[2]);

            if (accountData.Count == 0)
            {
                IList <ArraySegment <byte> > serverResponse = CreateServerResponse(NetworkServerResponses.LoginError);
                Send(clientSocket, serverResponse);
            }
            else
            {
                if ((short)accountData["confirmado"] == 0)
                {
                    IList <ArraySegment <byte> > serverResponse = CreateServerResponse(NetworkServerResponses.AccountNotConfirmed);
                    Send(clientSocket, serverResponse);
                    return;
                }
                IList <ArraySegment <byte> > accountDataPackage = CreatePackage(accountData);
                Send(clientSocket, accountDataPackage);
                Console.WriteLine(">> " + accountData["usuario"] + " has logged in.");
                clients[clientSocket] = (int)accountData["idcuenta"];
            }
        }
Exemplo n.º 5
0
 private static void ClientLogoutRequest(Socket clientSocket, List <string> content)
 {
     CuentaNetwork.Logout(int.Parse(content[1]));
 }
Exemplo n.º 6
0
        private static void ClientGetAccountData(Socket clientSocket, List <string> content)
        {
            var accountDataPackage = CreatePackage(CuentaNetwork.GetAccountData(int.Parse(content[1])));

            Send(clientSocket, accountDataPackage);
        }