Beispiel #1
0
        void HandleWhoIs(WhoIsRequest packet)
        {
            if (!HasPermission(RBACPermissions.OpcodeWhois))
            {
                SendNotification(CypherStrings.YouNotHavePermission);
                return;
            }

            if (!ObjectManager.NormalizePlayerName(ref packet.CharName))
            {
                SendNotification(CypherStrings.NeedCharacterName);
                return;
            }

            Player player = Global.ObjAccessor.FindPlayerByName(packet.CharName);

            if (!player)
            {
                SendNotification(CypherStrings.PlayerNotExistOrOffline, packet.CharName);
                return;
            }

            PreparedStatement stmt = DB.Login.GetPreparedStatement(LoginStatements.SEL_ACCOUNT_WHOIS);

            stmt.AddValue(0, player.GetSession().GetAccountId());

            SQLResult result = DB.Login.Query(stmt);

            if (result.IsEmpty())
            {
                SendNotification(CypherStrings.AccountForPlayerNotFound, packet.CharName);
                return;
            }

            string acc = result.Read <string>(0);

            if (string.IsNullOrEmpty(acc))
            {
                acc = "Unknown";
            }

            string email = result.Read <string>(1);

            if (string.IsNullOrEmpty(email))
            {
                email = "Unknown";
            }

            string lastip = result.Read <string>(2);

            if (string.IsNullOrEmpty(lastip))
            {
                lastip = "Unknown";
            }

            WhoIsResponse response = new WhoIsResponse();

            response.AccountName = packet.CharName + "'s " + "account is " + acc + ", e-mail: " + email + ", last ip: " + lastip;
            SendPacket(response);
        }
Beispiel #2
0
        public void SerializeDeserialize(string prefixString, int asn, string description, int numRisPeers)
        {
            var before = new WhoIsResponse(AddressPrefix.Parse(prefixString), asn, description, numRisPeers);
            var json   = JsonSerializer.Serialize(before);
            var after  = JsonSerializer.Deserialize <WhoIsResponse>(json);

            Assert.Equal(before, after);
        }