Esempio n. 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);
        }
        public void WhoIs()
        {
            var request = new WhoIsRequest(GeneralRequests.WhoIs);

            request.Parse();
            Assert.Equal("spyguy", request.NickName);
        }
Esempio n. 3
0
        /// <summary>
        /// Sends a who is request to find a device with
        /// a specific instance
        /// </summary>
        /// <param name="instance">The instance of the device</param>
        private void _sendWhoIsForInstance(uint instance)
        {
            WhoIsRequest request = new WhoIsRequest(
                instance,
                instance);

            _sendUnconfirmedRequest(Address.GlobalBroadcast, true, request);
        }
Esempio n. 4
0
        /// <summary>
        /// Sends a who is request to find a device at
        /// a specific address
        /// </summary>
        /// <param name="address">The address of the device</param>
        private void _sendWhoIsForAddress(Address address)
        {
            WhoIsRequest request = new WhoIsRequest(
                Option <uint> .None,
                Option <uint> .None);

            _sendUnconfirmedRequest(address, true, request);
        }
Esempio n. 5
0
        /// <summary>
        /// Called when the search timer ticks, and the
        /// next Who-Is request should be sent
        /// </summary>
        /// <param name="state"></param>
        private void _searchTick(object state)
        {
            DeviceRange range = null;

            lock (_lock)
            {
                // get the next range we should send
                // a who-is request for

                var node = _lastRange;
                if (node == null)
                {
                    node = _ranges.First;
                }
                else
                {
                    node = node.Next;
                }

                DateTime maxLastSearch = DateTime.UtcNow.Add(RangeSearchInterval.Negate());

                while (node != null && (node.Value.Found || node.Value.LastSearch > maxLastSearch))
                {
                    node = node.Next;
                }

                if (node != null)
                {
                    range = node.Value;
                    range.Attempts++;
                    range.LastSearch = DateTime.UtcNow;
                    _lastRange       = node;
                }
            }

            if (range != null)
            {
                WhoIsRequest request = new WhoIsRequest(
                    range.Start,
                    range.End);

                _host.SendUnconfirmedRequest(Address.GlobalBroadcast, true, request);
            }
        }