Ejemplo n.º 1
0
        public static int CheckUsernameExistCommand(ref ServerConnection connection, string username)
        {
            string command = CreateClientMessage((int)Options.CHECK_USER_NAME, username);

            connection.SendMessage(command);
            string[] args = GetArgArrayFromResponse(connection.ReadMessage());
            return(Int32.Parse(args[0]));
        }
Ejemplo n.º 2
0
        public static int SearchMatchCommand(ref ServerConnection connection, string sessionID)
        {
            string command = CreateClientMessage((int)Options.SEARCH_GAME, sessionID);

            connection.SendMessage(command);
            string[] args = GetArgArrayFromResponse(connection.ReadMessage());
            return(Int32.Parse(args[0]));
        }
Ejemplo n.º 3
0
        public static int RegisterUser(ref ServerConnection connection, string username, string password)
        {
            string command = CreateClientMessage((int)Options.CREATE_USER, username, password);

            connection.SendMessage(command);
            string[] args = GetArgArrayFromResponse(connection.ReadMessage());
            return(Int32.Parse(args[0]));
        }
Ejemplo n.º 4
0
        //******************** COMMANDS ********************

        public static int DisconnectCommand(ref ServerConnection connection)
        {
            string command = CreateClientMessage((int)Options.DISCONNECT);

            connection.SendMessage(command);
            string[] args = GetArgArrayFromResponse(connection.ReadMessage());
            return(Int32.Parse(args[0]));
        }
Ejemplo n.º 5
0
        public static string Communicate(ref ServerConnection connection, string command)
        {
            string response = "";

            lock (comunicateLock) {
                connection.SendMessage(command);
                response = connection.ReadMessage();
            }
            return(response);
        }
Ejemplo n.º 6
0
        public static GetMatchHistoryCommandResponse GetMatchHistoryCommand(ref ServerConnection connection, string sessionID)
        {
            string command = CreateClientMessage((int)Options.MATCH_HISTORY, sessionID);

            connection.SendMessage(command);
            string[] args = GetArgArrayFromResponse(connection.ReadMessage());
            if (Int32.Parse(args[0]) != (int)ErrorCodes.NO_ERROR)
            {
                return(new GetMatchHistoryCommandResponse(Int32.Parse(args[0]), ""));
            }
            return(new GetMatchHistoryCommandResponse(Int32.Parse(args[0]), args[1]));
        }
Ejemplo n.º 7
0
        public static LoginCommandResponse LoginCommand(ref ServerConnection connection, string username, string password)
        {
            string command = CreateClientMessage((int)Options.LOGIN, username, password);

            connection.SendMessage(command);
            string[] args = GetArgArrayFromResponse(connection.ReadMessage());
            if (Int32.Parse(args[0]) != (int)ErrorCodes.NO_ERROR)
            {
                return(new LoginCommandResponse(Int32.Parse(args[0]), "", 0));
            }
            return(new LoginCommandResponse(Int32.Parse(args[0]), args[1], Int32.Parse(args[2])));
        }