public void Switch(GStatsSession session, string message)
        {
            try
            {
                if (message[0] != '\\')
                {
                    return;
                }
                string[] recieved = message.TrimStart('\\').Split('\\');
                Dictionary <string, string> recv = GameSpyUtils.ConvertRequestToKeyValue(recieved);

                switch (recv.Keys.First())
                {
                case "auth":
                    new AuthHandler().Handle(session, recv);
                    break;

                case "authp":
                    new AuthPHandler().Handle(session, recv);
                    break;

                case "getpid":
                    new GetPidHandler().Handle(session, recv);
                    break;

                case "getpd":    //get player data
                    new GetPDHandler().Handle(session, recv);
                    break;

                case "setpd":
                    new SetPDHandler().Handle(session, recv);
                    break;

                case "updgame":
                    new UpdGameHandler().Handle(session, recv);
                    break;

                case "newgame":
                    new NewGameHandler().Handle(session, recv);
                    break;

                default:
                    LogWriter.UnknownDataRecieved(message);
                    break;
                }
            }
            catch (Exception e)
            {
                LogWriter.ToLog(e);
            }
        }
Beispiel #2
0
        public static void Switch(ISession session, string rawRequest)
        {
            try
            {
                if (rawRequest[0] != '\\')
                {
                    return;
                }
                string[] requestFraction = rawRequest.TrimStart('\\').Split('\\');
                var      request         = GameSpyUtils.ConvertRequestToKeyValue(requestFraction);

                switch (request.Keys.First())
                {
                case GStatsRequestName.AuthenticateUser:
                    new AuthHandler(session, request).Handle();
                    break;

                case GStatsRequestName.AuthenticatePlayer:
                    new AuthPHandler(session, request).Handle();
                    break;

                case GStatsRequestName.GetProfileID:
                    new GetPIDHandler(session, request).Handle();
                    break;

                case GStatsRequestName.GetPlayerData:
                    new GetPDHandler(session, request).Handle();
                    break;

                case GStatsRequestName.SetPlayerData:
                    new SetPDHandler(session, request).Handle();
                    break;

                case GStatsRequestName.UpdateGameData:
                    new UpdGameHandler(session, request).Handle();
                    break;

                case GStatsRequestName.CreateNewGamePlayerData:
                    new NewGameHandler(session, request).Handle();
                    break;

                default:
                    LogWriter.UnknownDataRecieved(rawRequest);
                    break;
                }
            }
            catch (Exception e)
            {
                LogWriter.ToLog(LogEventLevel.Error, e.ToString());
            }
        }
        public void Switch(ISession client, string message)
        {
            message.Replace(@"\r\n", "").Replace("\0", "");
            string[] keyValueArray           = message.TrimStart('\\').Split('\\');
            Dictionary <string, string> recv = GameSpyUtils.ConvertRequestToKeyValue(keyValueArray);

            try
            {
                switch (recv.Keys.First())
                {
                //keep client alive request, we skip this
                case "ka":
                    Console.WriteLine("Received keep alive command");
                    break;

                case "auth":
                    break;

                case "resp":
                    break;

                case "skey":
                    SKeyHandler.IsCDKeyValid(client, recv);
                    break;

                case "disc":    //disconnect from server
                    break;

                case "uon":
                    break;

                default:
                    LogWriter.UnknownDataRecieved(message);
                    break;
                }
            }
            catch (Exception e)
            {
                LogWriter.ToLog(e);
            }
        }
Beispiel #4
0
        public static void Switch(ISession session, string rawRequest)
        {
            try
            {
                //message = @"\login\\challenge\VPUKQ5CiXSqtt0EdOKMwwRvf3CHqxrah\user\borger@[email protected]\partnerid\0\response\4ec2535ddba4773168337c7b5f9588e7\firewall\1\port\0\productid\10936\gamename\greconawf2\namespaceid\0\sdkrevision\3\id\1\final\";
                rawRequest = PCMRequestBase.NormalizeRequest(rawRequest);
                if (rawRequest[0] != '\\')
                {
                    LogWriter.ToLog(LogEventLevel.Error, "Invalid request recieved!");
                    return;
                }
                string[] commands = rawRequest.Split("\\final\\", StringSplitOptions.RemoveEmptyEntries);

                foreach (string command in commands)
                {
                    if (command.Length < 1)
                    {
                        continue;
                    }

                    // Read client message, and parse it into key value pairs
                    string[] recieved = command.TrimStart('\\').Split('\\');

                    Dictionary <string, string> recv = GameSpyUtils.ConvertRequestToKeyValue(recieved);

                    switch (recv.Keys.First())
                    {
                    case PCMRequestName.Login:    //login to retrospy
                        new LoginHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.Logout:    //logout from retrospy
                        new LogoutHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.KeepAlive:
                        new KeepAliveHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.GetProfile:    //get profile of a player
                        new GetProfileHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.RegisterNick:    //update user's uniquenick
                        new RegisterNickHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.NewUser:    //create an new user
                        new NewUserHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.UpdateUI:    //update a user's email
                        new UpdateUIHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.UpdatePro:    //update a user's profile
                        new UpdateProHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.NewProfile:    //create an new profile
                        new NewProfileHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.DelProfile:    //delete profile
                        break;

                    case PCMRequestName.AddBlock:    //add an user to our block list
                        new AddBlockHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.RemoveBlock:
                        new RemoveBlockHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.AddBuddy:    //Send a request which adds an user to our friend list
                        new AddBuddyHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.DelBuddy:    //delete a user from our friend list
                        new DelBuddyHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.Status:    //update current logged in user's status info
                        new StatusHandler(session, recv).Handle();
                        break;

                    case PCMRequestName.StatusInfo:
                        throw new NotImplementedException();

                    case PCMRequestName.InviteTo:
                        throw new NotImplementedException();

                    default:
                        LogWriter.UnknownDataRecieved(rawRequest);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                LogWriter.ToLog(LogEventLevel.Error, e.ToString());
            }
        }
Beispiel #5
0
        public void Switch(GPSPSession session, string message)
        {
            try
            {
                if (message[0] != '\\')
                {
                    GameSpyUtils.SendGPError(session, GPErrorCode.Parse, "An invalid request was sended.");
                    return;
                }

                string[] commands = message.Split("\\final\\", System.StringSplitOptions.RemoveEmptyEntries);

                foreach (string command in commands)
                {
                    if (command.Length < 1)
                    {
                        continue;
                    }

                    // Read client message, and parse it into key value pairs
                    string[] recieved = command.TrimStart('\\').Split('\\');
                    Dictionary <string, string> recv = GameSpyUtils.ConvertRequestToKeyValue(recieved);

                    switch (recv.Keys.First())
                    {
                    case "search":
                        new SearchHandler(session, recv).Handle();
                        break;

                    case "valid":    //is email format valid
                        new ValidHandler(session, recv).Handle();
                        break;

                    case "nicks":    // search an user with nick name
                        new NickHandler(session, recv).Handle();
                        break;

                    //case "pmatch":
                    //    PmatchHandler pmatch = new PmatchHandler(recv);
                    //    pmatch.Handle(session);
                    //    break;

                    case "check":
                        new CheckHandler(session, recv).Handle();
                        break;

                    case "newuser":    //create an new user
                        new NewUserHandler(session, recv).Handle();
                        break;

                    case "searchunique":    //search an user with uniquenick
                        new SearchUniqueHandler(session, recv).Handle();
                        break;

                    case "others":    //search
                        new OthersHandler(session, recv).Handle();
                        break;

                    case "otherslist":    //search other players friend list to see who is in his list?
                        new OthersListHandler(session, recv).Handle();
                        break;

                    case "uniquesearch":    //search a user with uniquenick and namespaceid
                        new UniqueSearchHandler(session, recv).Handle();
                        break;

                    default:
                        LogWriter.UnknownDataRecieved(message);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                LogWriter.ToLog(e);
            }
        }
Beispiel #6
0
        public static void Switch(PSPSession session, string message)
        {
            try
            {
                if (message[0] != '\\')
                {
                    LogWriter.ToLog(LogEventLevel.Error, "Invalid request recieved!");
                    return;
                }
                string[] requests = message.Split("\\final\\", StringSplitOptions.RemoveEmptyEntries);

                foreach (string request in requests)
                {
                    if (request.Length < 1)
                    {
                        continue;
                    }

                    // Read client message, and parse it into key value pairs
                    Dictionary <string, string> recv = GameSpyUtils.ConvertRequestToKeyValue(request);

                    switch (recv.Keys.First())
                    {
                    case PSPRequestName.Search:
                        new SearchHandler(session, recv).Handle();
                        break;

                    case PSPRequestName.Valid:
                        new ValidHandler(session, recv).Handle();
                        break;

                    case PSPRequestName.Nicks:
                        new NicksHandler(session, recv).Handle();
                        break;

                    case PSPRequestName.PMatch:
                        //    PmatchHandler pmatch = new PmatchHandler(recv);
                        //    pmatch.Handle(session);
                        break;

                    case PSPRequestName.Check:
                        new CheckHandler(session, recv).Handle();
                        break;

                    case PSPRequestName.NewUser:
                        new NewUserHandler(session, recv).Handle();
                        break;

                    case PSPRequestName.SearchUnique:
                        new SearchUniqueHandler(session, recv).Handle();
                        break;

                    case PSPRequestName.Others:
                        new OthersHandler(session, recv).Handle();
                        break;

                    case PSPRequestName.OtherList:
                        new OthersListHandler(session, recv).Handle();
                        break;

                    case PSPRequestName.UniqueSearch:
                        new UniqueSearchHandler(session, recv).Handle();
                        break;

                    default:
                        LogWriter.UnknownDataRecieved(message);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                LogWriter.ToLog(e);
            }
        }
Beispiel #7
0
        public void Switch(GPCMSession session, string message)
        {
            try
            {
                message = session.RequstFormatConversion(message);
                if (message[0] != '\\')
                {
                    GameSpyUtils.SendGPError(session, GPErrorCode.General, "An invalid request was sended.");
                    return;
                }
                string[] commands = message.Split("\\final\\", StringSplitOptions.RemoveEmptyEntries);

                foreach (string command in commands)
                {
                    if (command.Length < 1)
                    {
                        continue;
                    }

                    // Read client message, and parse it into key value pairs
                    string[] recieved = command.TrimStart('\\').Split('\\');

                    Dictionary <string, string> recv = GameSpyUtils.ConvertRequestToKeyValue(recieved);

                    switch (recv.Keys.First())
                    {
                    //case "inviteto":
                    //    InviteToHandler.InvitePlayer();
                    //    break;

                    case "login":    //login to retrospy
                        new LoginHandler(session, recv).Handle();
                        break;

                    case "getprofile":    //get profile of a player
                        new GetProfileHandler(session, recv).Handle();
                        break;

                    case "addbuddy":    //Send a request which adds an user to our friend list
                        new AddBuddyHandler(session, recv).Handle();
                        break;

                    case "delbuddy":    //delete a user from our friend list
                        new DelBuddyHandler(session, recv).Handle();
                        break;

                    case "updateui":    //update a user's email
                        new UpdateUIHandler(session, recv).Handle();
                        break;

                    case "updatepro":    //update a user's profile
                        new UpdateProHandler(session, recv).Handle();
                        break;

                    case "registernick":    //update user's uniquenick
                        new RegisterNickHandler(session, recv).Handle();
                        break;

                    case "logout":    //logout from retrospy
                        session.Disconnect();
                        GPCMServer.LoggedInSession.TryRemove(session.Id, out _);
                        break;

                    case "status":    //update current logged in user's status info
                        new StatusHandler(session, recv).Handle();
                        break;

                    case "newuser":    //create an new user
                        new NewUserHandler(session, recv).Handle();
                        break;

                    case "addblock":    //add an user to our block list
                        new AddBlockHandler(session, recv).Handle();
                        break;

                    case "ka":
                        //KAHandler.SendKeepAlive(_session);
                        break;

                    case "newprofile":    //create an new profile
                        new NewProfileHandler(session, recv).Handle();
                        break;

                    default:
                        LogWriter.UnknownDataRecieved(message);
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                LogWriter.ToLog(Serilog.Events.LogEventLevel.Error, e.ToString());
            }
        }
Beispiel #8
0
        /// <summary>
        /// Returns PCM request class instance
        /// </summary>
        /// <param name="command">raw request</param>
        /// <param name="specificRequest">The valid serialized request</param>
        /// <returns>error code</returns>
        private static IRequest GenerateRequest(string command)
        {
            if (command.Length < 1)
            {
                return(null);
            }
            // Read client message, and parse it into key value pairs
            string[] recieved = command.TrimStart('\\').Split('\\');
            Dictionary <string, string> keyValue = GameSpyUtils.ConvertRequestToKeyValue(recieved);

            switch (keyValue.Keys.First())
            {
            case PCMRequestName.Login:
                return(new LoginRequest(keyValue));

            case PCMRequestName.Logout:
                return(new LogoutRequest(keyValue));

            case PCMRequestName.KeepAlive:
                return(new KeepAliveRequest(keyValue));

            case PCMRequestName.GetProfile:
                return(new GetProfileRequest(keyValue));

            case PCMRequestName.RegisterNick:
                return(new RegisterNickRequest(keyValue));

            case PCMRequestName.NewUser:
                return(new NewUserRequest(keyValue));

            case PCMRequestName.UpdateUI:
                return(new UpdateUIRequest(keyValue));

            case PCMRequestName.UpdatePro:
                return(new UpdateProRequest(keyValue));

            case PCMRequestName.NewProfile:
                return(new NewUserRequest(keyValue));

            case PCMRequestName.DelProfile:
                throw new NotImplementedException();

            case PCMRequestName.AddBlock:
                return(new AddBlockRequest(keyValue));

            case PCMRequestName.RemoveBlock:
                throw new NotImplementedException();

            case PCMRequestName.AddBuddy:
                return(new AddBuddyRequest(keyValue));

            case PCMRequestName.DelBuddy:
                return(new DelBuddyRequest(keyValue));

            case PCMRequestName.Status:
                return(new StatusRequest(keyValue));

            case PCMRequestName.StatusInfo:
                return(new StatusInfoRequest(keyValue));

            case PCMRequestName.InviteTo:
                return(new InviteToRequest(keyValue));

            default:
                LogWriter.UnknownDataRecieved(command);
                return(null);
            }
        }