Example #1
0
 /// <summary>
 /// Polls the connection, and checks for drops
 /// </summary>
 public static void SendKeepAlive(GPCMSession session)
 {
     if (session.PlayerInfo.LoginProcess == LoginStatus.Completed)
     {
         // Try and send a Keep-Alive
         try
         {
             session.Send(@"\ka\\final\");
         }
         catch
         {
             session.DisconnectByReason(DisconnectReason.KeepAliveFailed);
         }
     }
 }
Example #2
0
        public static void Switch(GPCMSession session, Dictionary <string, string> recv)
        {
            string command = recv.Keys.First();

            try
            {
                switch (command)
                {
                case "inviteto":
                    InviteToHandler.InvitePlayer(session, recv);
                    break;

                case "login":    //login to gamespy
                    LoginHandler login = new LoginHandler(recv);
                    login.Handle(session);
                    //LoginSwitcher.Switch(session, recv);
                    break;

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

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

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

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

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

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

                case "logout":
                    session.DisconnectByReason(DisconnectReason.NormalLogout);
                    break;

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

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

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

                case "KA":
                    KAHandler.SendKeepAlive(session);
                    break;

                case "newprofile":
                    NewProfileHandler.ChangeNick(session, recv);
                    break;

                default:
                    session.UnknownDataRecived(recv);
                    break;
                }
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }
        }