Пример #1
0
        public static void Switch(GPSPClient client, Dictionary <string, string> recv)
        {
            string command = recv.Keys.First();

            try
            {
                switch (command)
                {
                case "search":
                    SearchHandler.SearchUsers(client, recv);
                    break;

                case "valid":
                    ValidHandler.IsEmailValid(client, recv);
                    break;

                case "nicks":
                    NickHandler.SearchNicks(client, recv);
                    break;

                case "pmatch":
                    PmatchHandler.PlayerMatch(client, recv);
                    break;

                case "check":
                    CheckHandler.CheckProfileid(client, recv);
                    break;

                case "newuser":
                    NewUserHandler.NewUser(client, recv);
                    break;

                case "searchunique":
                    SearchUniqueHandler.SearchProfileWithUniquenick(client, recv);
                    break;

                case "others":
                    OthersHandler.SearchOtherBuddy(client, recv);
                    break;

                case "otherslist":
                    OthersListHandler.SearchOtherBuddyList(client, recv);
                    break;

                case "uniquesearch":
                    UniqueSearchHandler.SuggestUniqueNickname(client, recv);
                    break;

                default:
                    LogWriter.Log.Write("[GPSP] received unknown data " + command, LogLevel.Debug);
                    GameSpyUtils.PrintReceivedGPDictToLogger(command, recv);
                    GameSpyUtils.SendGPError(client, GPErrorCode.Parse, "An invalid request was sended.");
                    break;
                }
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }
        }
Пример #2
0
        public IClient SingleLoginTest(string userName = "******", string nickName = "unispy")
        {
            var userReq     = new UserRequest($"USER {userName} 127.0.0.1 peerchat.unispy.org :{userName}");
            var nickReq     = new NickRequest($"NICK {nickName}");
            var userHandler = new UserHandler(_client, userReq);
            var nickHandler = new NickHandler(_client, nickReq);

            userHandler.Handle();
            nickHandler.Handle();
            return(_client);
        }
Пример #3
0
        public void TestSelfNickNoChangeIfNotSame()
        {
            var nickHandler = new NickHandler();

            Talker.Nick = "b";
            var msg = new MsgEventArgs {
                Command = "nick", Data = new[] { "test" }, Meta = "a!b@c"
            };

            Caller.nick = new Action <NickAction>(res => { });
            nickHandler.Msg(Talker, Caller, msg);
            Assert.AreEqual("b", Talker.Nick);
        }
Пример #4
0
        public void TestNick()
        {
            var nickHandler = new NickHandler();
            var msg         = new MsgEventArgs {
                Command = "nick", Data = new[] { "test" }, Meta = "a!b@c"
            };
            var visited = false;

            Caller.nick = new Action <NickAction>(res =>
            {
                Assert.AreEqual("test", res.NewNick);
                var user = res.User;
                Assert.AreEqual("a", user.Nick);
                Assert.AreEqual("b", user.Name);
                Assert.AreEqual("c", user.Host);
                visited = true;
            });
            nickHandler.Msg(Talker, Caller, msg);
            Assert.IsTrue(visited);
        }
Пример #5
0
        public void TestNickChangeChangeInNamesList()
        {
            AddChatUsers("test", "a", "b", "c");
            AddChatUsers("test2", "a", "c");

            var msg = new MsgEventArgs {
                Command = "nick", Data = new[] { "d" }, Meta = "a!b@c"
            };

            Caller.nick = new Action <NickAction>(res => { });

            var nickHandler = new NickHandler();

            nickHandler.Msg(Talker, Caller, msg);
            var wat = Talker.Chats["test"].Users.Select(u => u.IrcUser.Nick).ToArray();

            CollectionAssert.AreEqual(new[] { "d", "b", "c" },
                                      Talker.Chats["test"].Users.Select(u => u.IrcUser.Nick).ToArray());
            CollectionAssert.AreEqual(new[] { "d", "c" },
                                      Talker.Chats["test2"].Users.Select(u => u.IrcUser.Nick).ToArray());
        }
Пример #6
0
        public static void Switch(GPSPSession session, Dictionary <string, string> recv)
        {
            string command = recv.Keys.First();

            try
            {
                switch (command)
                {
                case "search":
                    SearchHandler search = new SearchHandler(recv);
                    search.Handle(session);
                    break;

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

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

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

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

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

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

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

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

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

                default:
                    session.UnknownDataRecived(command, recv);
                    break;
                }
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
                Error.ErrorMsg.SendGPSPError(session, Enumerator.GPErrorCode.General, 0);
            }
        }
Пример #7
0
        public void TestOnlyTriggerOnNick()
        {
            var nickHandler = new NickHandler();

            Assert.AreEqual("NICK", nickHandler.ForCommand());
        }