Exemplo n.º 1
0
        void UUIDNameRequestHandler(Packet packet, Agent agent)
        {
            UUIDNameRequestPacket request = (UUIDNameRequestPacket)packet;

            UUIDNameReplyPacket reply = new UUIDNameReplyPacket();

            reply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[request.UUIDNameBlock.Length];

            for (int i = 0; i < request.UUIDNameBlock.Length; i++)
            {
                UUID id = request.UUIDNameBlock[i].ID;

                reply.UUIDNameBlock[i]    = new UUIDNameReplyPacket.UUIDNameBlockBlock();
                reply.UUIDNameBlock[i].ID = id;

                Agent foundAgent;
                if (server.Agents.TryGetValue(id, out foundAgent))
                {
                    reply.UUIDNameBlock[i].FirstName = Utils.StringToBytes(foundAgent.FirstName);
                    reply.UUIDNameBlock[i].LastName  = Utils.StringToBytes(foundAgent.LastName);
                }
                else
                {
                    reply.UUIDNameBlock[i].FirstName = new byte[0];
                    reply.UUIDNameBlock[i].LastName  = new byte[0];
                }
            }

            server.UDP.SendPacket(agent.AgentID, reply, PacketCategory.Transaction);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Request a single avatar name
        /// </summary>
        /// <param name="id">The avatar key to retrieve a name for</param>
        public void RequestAvatarName(LLUUID id)
        {
            UUIDNameRequestPacket request = new UUIDNameRequestPacket();

            request.UUIDNameBlock       = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
            request.UUIDNameBlock[0]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
            request.UUIDNameBlock[0].ID = id;

            Client.Network.SendPacket(request);
        }
Exemplo n.º 3
0
        public void RequestNameFromKey(UUID key)
        {
            UUIDNameRequestPacket nrp = new UUIDNameRequestPacket();

            nrp.Type                = PacketType.UUIDNameRequest;
            nrp.UUIDNameBlock       = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
            nrp.UUIDNameBlock[0]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
            nrp.UUIDNameBlock[0].ID = key;
            proxy.InjectPacket(nrp, Direction.Outgoing);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Request a single avatar name
        /// </summary>
        /// <param name="id">The avatar key to retrieve a name for</param>
        public void RequestAvatarName(UUID id)
        {
            Console.WriteLine("AvatarManager requesting UUID for {0}", id);
            UUIDNameRequestPacket request = new UUIDNameRequestPacket();

            request.UUIDNameBlock       = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
            request.UUIDNameBlock[0]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
            request.UUIDNameBlock[0].ID = id;

            Client.Network.SendPacket(request);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Request a list of avatar names
        /// </summary>
        /// <param name="ids">The avatar keys to retrieve names for</param>
        public void RequestAvatarNames(List <LLUUID> ids)
        {
            UUIDNameRequestPacket request = new UUIDNameRequestPacket();

            request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[ids.Count];

            for (int i = 0; i < ids.Count; i++)
            {
                request.UUIDNameBlock[i]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                request.UUIDNameBlock[i].ID = ids[i];
            }

            Client.Network.SendPacket(request);
        }
Exemplo n.º 6
0
Arquivo: useful.cs Projeto: zadark/par
    private Packet OutAvatarPropertiesRequestHandler(Packet requestpacket, IPEndPoint sim)
    {
        if (requestpacket.Header.Resent)
        {
            return(requestpacket);
        }
        AvatarPropertiesRequestPacket packet = (AvatarPropertiesRequestPacket)requestpacket;
        UUID uuid = packet.AgentData.AvatarID;

        System.Timers.Timer timer    = new System.Timers.Timer(5000);
        bool           found         = false;
        PacketDelegate replyCallback = delegate(Packet replypacket, IPEndPoint blarg)
        {
            if (!found)
            {
                UUIDNameReplyPacket reply = (UUIDNameReplyPacket)replypacket;
                foreach (UUIDNameReplyPacket.UUIDNameBlockBlock block in reply.UUIDNameBlock)
                {
                    if (block.ID == uuid)
                    {
                        found = true;
                        string firstname = Utils.BytesToString(block.FirstName);
                        string lastname  = Utils.BytesToString(block.LastName);
                        frame.SayToUser(firstname + " " + lastname + " = " + uuid.ToString());
                        return(replypacket);
                    }
                }
            }
            return(replypacket);
        };

        proxy.AddDelegate(PacketType.UUIDNameReply, Direction.Incoming, replyCallback);
        timer.Elapsed += delegate(object sender, System.Timers.ElapsedEventArgs e)
        {
            proxy.RemoveDelegate(PacketType.UUIDNameReply, Direction.Incoming, replyCallback);
            timer.Stop();
        };
        UUIDNameRequestPacket request = new UUIDNameRequestPacket();

        request.UUIDNameBlock       = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
        request.UUIDNameBlock[0]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
        request.UUIDNameBlock[0].ID = uuid;
        request.Header.Reliable     = true;
        proxy.InjectPacket(request, Direction.Outgoing);
        timer.Start();
        return(packet);
    }
Exemplo n.º 7
0
 public Packet ItsOver(Packet packet, IPEndPoint sim)
 {
     if (form.getEnabled())
     {
         TerminateFriendshipPacket tp = (TerminateFriendshipPacket)packet;
         //UUIDNameRequest = 65771,
         //UUIDNameReply = 65772,
         currentBastard = tp.ExBlock.OtherID;
         UUIDNameRequestPacket nr = new UUIDNameRequestPacket();
         UUIDNameRequestPacket.UUIDNameBlockBlock[] temp = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
         temp[0]          = new UUIDNameRequestPacket.UUIDNameBlockBlock();
         temp[0].ID       = currentBastard;
         nr.UUIDNameBlock = temp;
         proxy.InjectPacket(nr, Direction.Outgoing);
     }
     return(packet);
 }
Exemplo n.º 8
0
        private void UUIDNameRequestHandler(Packet packet, LLAgent agent)
        {
            UUIDNameRequestPacket request = (UUIDNameRequestPacket)packet;

            List <UUIDNameReplyPacket.UUIDNameBlockBlock> responses = new List <UUIDNameReplyPacket.UUIDNameBlockBlock>();

            for (int i = 0; i < request.UUIDNameBlock.Length; i++)
            {
                UUID   requestID = request.UUIDNameBlock[i].ID;
                string firstName = null, lastName = null;

                // See if we can fetch a presence in the local scene with the requested UUID first
                IScenePresence localPresence;
                if (m_scene.TryGetPresence(requestID, out localPresence))
                {
                    Util.GetFirstLastName(localPresence.Name, out firstName, out lastName);
                }
                else if (m_userClient != null)
                {
                    // TODO: We might want to switch to a batch user service command in the future
                    User user;
                    if (m_userClient.TryGetUser(requestID, out user))
                    {
                        Util.GetFirstLastName(user.Name, out firstName, out lastName);
                    }
                }

                if (firstName != null && lastName != null)
                {
                    UUIDNameReplyPacket.UUIDNameBlockBlock block = new UUIDNameReplyPacket.UUIDNameBlockBlock();
                    block.ID        = requestID;
                    block.FirstName = Utils.StringToBytes(firstName);
                    block.LastName  = Utils.StringToBytes(lastName);

                    responses.Add(block);
                }
            }

            // Build the response packet
            UUIDNameReplyPacket response = new UUIDNameReplyPacket();

            response.UUIDNameBlock = responses.ToArray();

            m_udp.SendPacket(agent, response, ThrottleCategory.Task, true);
        }
Exemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ids"></param>
        public void BeginGetAvatarNames(List <LLUUID> ids, AgentNamesCallback anc)
        {
            if (anc != null)
            {
                OnAgentNames = anc;
            }

            Dictionary <LLUUID, string> havenames = new Dictionary <LLUUID, string>();
            List <LLUUID> neednames = new List <LLUUID>();

            // Fire callbacks for the ones we already have cached
            foreach (LLUUID id in ids)
            {
                if (Avatars.ContainsKey(id))
                {
                    havenames[id] = Avatars[id].Name;
                }
                else
                {
                    neednames.Add(id);
                }
            }

            if (havenames.Count > 0 && OnAgentNames != null)
            {
                OnAgentNames(havenames);
            }

            if (neednames.Count > 0)
            {
                UUIDNameRequestPacket request = new UUIDNameRequestPacket();

                request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[neednames.Count];

                for (int i = 0; i < neednames.Count; i++)
                {
                    request.UUIDNameBlock[i]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                    request.UUIDNameBlock[i].ID = neednames[i];
                }

                Client.Network.SendPacket(request);
            }
        }
Exemplo n.º 10
0
        public bool RequestUUIDName(SimClient simClient, Packet packet)
        {
            System.Text.Encoding enc = System.Text.Encoding.ASCII;
            Console.WriteLine(packet.ToString());
            UUIDNameRequestPacket nameRequest = (UUIDNameRequestPacket)packet;
            UUIDNameReplyPacket   nameReply   = new UUIDNameReplyPacket();

            nameReply.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[nameRequest.UUIDNameBlock.Length];

            for (int i = 0; i < nameRequest.UUIDNameBlock.Length; i++)
            {
                nameReply.UUIDNameBlock[i]           = new UUIDNameReplyPacket.UUIDNameBlockBlock();
                nameReply.UUIDNameBlock[i].ID        = nameRequest.UUIDNameBlock[i].ID;
                nameReply.UUIDNameBlock[i].FirstName = enc.GetBytes("Who\0");   //for now send any name
                nameReply.UUIDNameBlock[i].LastName  = enc.GetBytes("Knows\0"); //in future need to look it up
            }
            simClient.OutPacket(nameReply);
            return(true);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Request a list of avatar names
        /// </summary>
        /// <param name="ids">The avatar keys to retrieve names for</param>
        public void RequestAvatarNames(List <UUID> ids)
        {
            Logger.Log("AvatarManager requesting UUIDs count " + ids.Count, Helpers.LogLevel.Debug);
            if (ids.Count > 0)
            {
                UUIDNameRequestPacket request = new UUIDNameRequestPacket();
                request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[ids.Count];

                for (int i = 0; i < ids.Count; i++)
                {
                    request.UUIDNameBlock[i]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                    request.UUIDNameBlock[i].ID = ids[i];
                }

                Client.Network.SendPacket(request);
            }
            else
            {
                // not sending request, no ids!
            }
        }
Exemplo n.º 12
0
Arquivo: useful.cs Projeto: zadark/par
    // try to stop autopilot when sit response is received
    //private Packet InAvatarSitResponseHandler(Packet packet, IPEndPoint sim)
    //{
    //    if (LastAgentUpdate != null)
    //    {
    //        AgentUpdatePacket p = LastAgentUpdate;
    //        p.AgentData.ControlFlags = 524288; // (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS;
    //        proxy.InjectPacket(p, Direction.Outgoing);
    //        p.AgentData.ControlFlags = 0;
    //        proxy.InjectPacket(p, Direction.Outgoing);
    //    }
    //    return packet;
    //}

    private Packet InTerminateFriendshipHandler(Packet packet, IPEndPoint sim)
    {
        if (packet.Header.Resent)
        {
            return(packet);
        }
        UUID             uuid        = ((TerminateFriendshipPacket)packet).ExBlock.OtherID;
        string           name        = "(waiting)";
        ManualResetEvent evt         = new ManualResetEvent(false);
        PacketDelegate   nameHandler = delegate(Packet packet2, IPEndPoint sim2)
        {
            foreach (UUIDNameReplyPacket.UUIDNameBlockBlock block in ((UUIDNameReplyPacket)packet2).UUIDNameBlock)
            {
                if (block.ID == uuid)
                {
                    name = Utils.BytesToString(block.FirstName) + " " + Utils.BytesToString(block.LastName);
                    evt.Set();
                }
            }
            return(packet2);
        };
        Thread myThread = new Thread(new ThreadStart(delegate
        {
            proxy.AddDelegate(PacketType.UUIDNameReply, Direction.Incoming, nameHandler);
            UUIDNameRequestPacket request = new UUIDNameRequestPacket();
            request.UUIDNameBlock         = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
            request.UUIDNameBlock[0]      = new UUIDNameRequestPacket.UUIDNameBlockBlock();
            request.UUIDNameBlock[0].ID   = uuid;
            request.Header.Reliable       = true;
            proxy.InjectPacket(request, Direction.Outgoing);
            evt.WaitOne(10000, false);
            proxy.RemoveDelegate(PacketType.UUIDNameReply, Direction.Incoming, nameHandler);
            frame.SayToUser("Friendship terminated with " + name);
        }));

        myThread.Start();
        return(packet);
    }
Exemplo n.º 13
0
        /// <summary>
        /// Request a list of avatar names
        /// </summary>
        /// <param name="ids">The avatar keys to retrieve names for</param>
        public void RequestAvatarNames(List <UUID> ids)
        {
            int m = MAX_UUIDS_PER_PACKET;
            int n = ids.Count / m; // Number of full requests to make
            int i = 0;

            UUIDNameRequestPacket request;

            for (int j = 0; j < n; j++)
            {
                request = new UUIDNameRequestPacket();
                request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[m];

                for (; i < (j + 1) * m; i++)
                {
                    request.UUIDNameBlock[i % m]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                    request.UUIDNameBlock[i % m].ID = ids[i];
                }

                Client.Network.SendPacket(request);
            }

            // Get any remaining names after left after the full requests
            if (ids.Count > n * m)
            {
                request = new UUIDNameRequestPacket();
                request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[ids.Count - n * m];

                for (; i < ids.Count; i++)
                {
                    request.UUIDNameBlock[i % m]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                    request.UUIDNameBlock[i % m].ID = ids[i];
                }

                Client.Network.SendPacket(request);
            }
        }
Exemplo n.º 14
0
Arquivo: useful.cs Projeto: zadark/par
 private Packet OutAvatarPropertiesRequestHandler(Packet requestpacket, IPEndPoint sim)
 {
     if (requestpacket.Header.Resent)
         return requestpacket;
     AvatarPropertiesRequestPacket packet = (AvatarPropertiesRequestPacket)requestpacket;
     UUID uuid = packet.AgentData.AvatarID;
     System.Timers.Timer timer = new System.Timers.Timer(5000);
     bool found = false;
     PacketDelegate replyCallback = delegate(Packet replypacket, IPEndPoint blarg)
     {
         if (!found)
         {
             UUIDNameReplyPacket reply = (UUIDNameReplyPacket)replypacket;
             foreach (UUIDNameReplyPacket.UUIDNameBlockBlock block in reply.UUIDNameBlock)
             {
                 if (block.ID == uuid)
                 {
                     found = true;
                     string firstname = Utils.BytesToString(block.FirstName);
                     string lastname = Utils.BytesToString(block.LastName);
                     frame.SayToUser(firstname + " " + lastname + " = " + uuid.ToString());
                     return replypacket;
                 }
             }
         }
         return replypacket;
     };
     proxy.AddDelegate(PacketType.UUIDNameReply, Direction.Incoming, replyCallback);
     timer.Elapsed += delegate(object sender, System.Timers.ElapsedEventArgs e)
     {
         proxy.RemoveDelegate(PacketType.UUIDNameReply, Direction.Incoming, replyCallback);
         timer.Stop();
     };
     UUIDNameRequestPacket request = new UUIDNameRequestPacket();
     request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
     request.UUIDNameBlock[0] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
     request.UUIDNameBlock[0].ID = uuid;
     request.Header.Reliable = true;
     proxy.InjectPacket(request, Direction.Outgoing);
     timer.Start();
     return packet;
 }
Exemplo n.º 15
0
        /// <summary>
        /// Request a list of avatar names
        /// </summary>
        /// <param name="ids">The avatar keys to retrieve names for</param>
        public void RequestAvatarNames(List<UUID> ids)
        {
            int m = MAX_UUIDS_PER_PACKET;
            int n = ids.Count / m; // Number of full requests to make
            int i = 0;

            UUIDNameRequestPacket request;

            for (int j = 0; j < n; j++)
            {
                request = new UUIDNameRequestPacket();
                request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[m];

                for (; i < (j + 1) * m; i++)
                {
                    request.UUIDNameBlock[i % m] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                    request.UUIDNameBlock[i % m].ID = ids[i];
                }

                Client.Network.SendPacket(request);
            }

            // Get any remaining names after left after the full requests
            if (ids.Count > n * m)
            {
                request = new UUIDNameRequestPacket();
                request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[ids.Count - n * m];

                for (; i < ids.Count; i++)
                {
                    request.UUIDNameBlock[i % m] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                    request.UUIDNameBlock[i % m].ID = ids[i];
                }

                Client.Network.SendPacket(request);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Request a single avatar name
        /// </summary>
        /// <param name="id">The avatar key to retrieve a name for</param>
        public void RequestAvatarName(UUID id)
        {
            UUIDNameRequestPacket request = new UUIDNameRequestPacket();
            request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
            request.UUIDNameBlock[0] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
            request.UUIDNameBlock[0].ID = id;

            Client.Network.SendPacket(request);
        }
Exemplo n.º 17
0
        public Packet IMs(Packet p, IPEndPoint sim)
        {
            if (enabled)
            {
                GregIm g = new GregIm();
                ImprovedInstantMessagePacket imm = (ImprovedInstantMessagePacket)p;

                g.fromname  = Utils.BytesToString(imm.MessageBlock.FromAgentName);
                g.ownerkey  = imm.AgentData.AgentID;
                g.regionkey = imm.MessageBlock.RegionID;
                g.regionpos = imm.MessageBlock.Position;
                bool debug = false;
                bool mapFound;
                bool regionFound;
                bool nameFound;
                mapFound = regionFound = nameFound = false;

                if (g.regionkey != UUID.Zero && imm.MessageBlock.Dialog == (byte)InstantMessageDialog.MessageFromObject)
                {
                    /*if ((imm.MessageBlock.Dialog == 0 && imm.MessageBlock.Offline != 1) || g.ownerkey == frame.AgentID)
                     * {
                     *  imm.MessageBlock.FromAgentName = Utils.StringToBytes(g.fromname.ToString() + " @ " + g.regionpos.ToString());
                     *  return imm;
                     * }*/
                    g.p = imm;
                    if (debug)
                    {
                        frame.SayToUser("region key was not zero..:");
                    }
                    // request region name
                    RegionHandleRequestPacket rhp = new RegionHandleRequestPacket();
                    rhp.RequestBlock.RegionID = g.regionkey;


                    System.Timers.Timer mygregTimer = new System.Timers.Timer(30000);

                    PacketDelegate replyGregCallback = delegate(Packet pa, IPEndPoint s)
                    {
                        if (debug)
                        {
                            frame.SayToUser("got the region handle...");
                        }
                        if (!regionFound)
                        {
                            regionFound = true;
                            RegionIDAndHandleReplyPacket rid = (RegionIDAndHandleReplyPacket)pa;
                            ulong  handle = rid.ReplyBlock.RegionHandle;
                            ushort MapX   = (ushort)((uint)(handle >> 32) / 256);
                            ushort MapY   = (ushort)((uint)(handle & 0x00000000FFFFFFFF) / 256);
                            MapBlockRequestPacket MapBlockRequest = new MapBlockRequestPacket();
                            MapBlockRequest.AgentData           = new MapBlockRequestPacket.AgentDataBlock();
                            MapBlockRequest.AgentData.AgentID   = frame.AgentID;
                            MapBlockRequest.AgentData.SessionID = frame.SessionID;
                            MapBlockRequest.AgentData.Flags     = 0;
                            MapBlockRequest.AgentData.Godlike   = false;
                            MapBlockRequest.PositionData        = new MapBlockRequestPacket.PositionDataBlock();
                            MapBlockRequest.PositionData.MinX   = MapX;
                            MapBlockRequest.PositionData.MaxX   = MapX;
                            MapBlockRequest.PositionData.MinY   = MapY;
                            MapBlockRequest.PositionData.MaxY   = MapY;



                            System.Timers.Timer myTimer2 = new System.Timers.Timer(20000);

                            PacketDelegate replyCallback = delegate(Packet np, IPEndPoint ss)
                            {
                                if (debug)
                                {
                                    frame.SayToUser("got the map..:");
                                }
                                if (!mapFound)
                                {
                                    mapFound = true;
                                    MapBlockReplyPacket reply = (MapBlockReplyPacket)np;
                                    foreach (MapBlockReplyPacket.DataBlock block in reply.Data)
                                    {
                                        if ((block.X == MapX) && (block.Y == MapY))
                                        {
                                            g.regionName    = Utils.BytesToString(block.Name);
                                            g.regionglobalx = MapX;
                                            g.regionglobaly = MapY;
                                            g.slurl         = "secondlife://" + g.regionName.Replace(" ", "%20") + "/" + g.regionpos.X.ToString() + "/" + g.regionpos.Y.ToString() + "/" + g.regionpos.Z.ToString();
                                            System.Timers.Timer timer = new System.Timers.Timer(10000);

                                            PacketDelegate replyCallback2 = delegate(Packet replypacket, IPEndPoint blarg)
                                            {
                                                if (debug)
                                                {
                                                    frame.SayToUser("got the name");
                                                }

                                                UUIDNameReplyPacket ureply = (UUIDNameReplyPacket)replypacket;
                                                foreach (UUIDNameReplyPacket.UUIDNameBlockBlock bblock in ureply.UUIDNameBlock)
                                                {
                                                    if (bblock.ID == g.ownerkey)
                                                    {
                                                        if (!nameFound)
                                                        {
                                                            nameFound = true;

                                                            string firstname = Utils.BytesToString(bblock.FirstName);
                                                            string lastname  = Utils.BytesToString(bblock.LastName);
                                                            g.ownername = firstname + " " + lastname;
                                                            g.p.MessageBlock.FromAgentName = Utils.StringToBytes(g.ownername + "'s " + g.fromname + " @ " + g.slurl);
                                                            form.addListItem(g.ownerkey.ToString() + " \t" + g.ownername + " \t" + g.slurl + " \t" + g.fromname + " \t" + Utils.BytesToString(g.p.MessageBlock.Message));
                                                            imm = g.p;
                                                            proxy.InjectPacket(g.p, Direction.Incoming);
                                                        }
                                                        return(replypacket);
                                                    }
                                                }

                                                return(replypacket);
                                            };
                                            proxy.AddDelegate(PacketType.UUIDNameReply, Direction.Incoming, replyCallback2);
                                            timer.Elapsed += delegate(object sender, System.Timers.ElapsedEventArgs e)
                                            {
                                                proxy.RemoveDelegate(PacketType.UUIDNameReply, Direction.Incoming, replyCallback2);
                                                timer.Stop();
                                                //proxy.InjectPacket(p, Direction.Incoming);
                                            };
                                            UUIDNameRequestPacket request = new UUIDNameRequestPacket();
                                            request.UUIDNameBlock       = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
                                            request.UUIDNameBlock[0]    = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                                            request.UUIDNameBlock[0].ID = g.ownerkey;
                                            request.Header.Reliable     = true;
                                            proxy.InjectPacket(request, Direction.Outgoing);
                                            timer.Start();
                                        }
                                    }
                                }
                                return(np);
                            };

                            System.Timers.ElapsedEventHandler timerCallback = delegate(object sender, System.Timers.ElapsedEventArgs e)
                            {
                                proxy.RemoveDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback);
                                myTimer2.Stop();
                                //proxy.InjectPacket(p, Direction.Incoming);
                            };

                            proxy.AddDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback);
                            myTimer2.Elapsed += timerCallback;
                            myTimer2.Start();

                            proxy.InjectPacket(MapBlockRequest, Direction.Outgoing);
                        }
                        return(pa);
                    };

                    System.Timers.ElapsedEventHandler timerGregCallback = delegate(object sender, System.Timers.ElapsedEventArgs e)
                    {
                        proxy.RemoveDelegate(PacketType.RegionIDAndHandleReply, Direction.Incoming, replyGregCallback);
                        mygregTimer.Stop();
                        //proxy.InjectPacket(p, Direction.Incoming);
                    };

                    proxy.AddDelegate(PacketType.RegionIDAndHandleReply, Direction.Incoming, replyGregCallback);
                    mygregTimer.Elapsed += timerGregCallback;
                    mygregTimer.Start();

                    proxy.InjectPacket(rhp, Direction.Outgoing);



                    //----------------------
                    return(null);
                }
            }


            return(p);
        }
Exemplo n.º 18
0
 public void RequestNameFromKey(UUID key)
 {
     UUIDNameRequestPacket nrp = new UUIDNameRequestPacket();
     nrp.Type = PacketType.UUIDNameRequest;
     nrp.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
     nrp.UUIDNameBlock[0] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
     nrp.UUIDNameBlock[0].ID = key;
     proxy.InjectPacket(nrp, Direction.Outgoing);
 }
Exemplo n.º 19
0
        /// <summary>
        /// Request a single avatar name
        /// </summary>
        /// <param name="id">The avatar key to retrieve a name for</param>
        public void RequestAvatarName(Guid id)
        {
            Console.WriteLine("AvatarManager requesting Guid for {0}", id);
            UUIDNameRequestPacket request = new UUIDNameRequestPacket();
            request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
            request.UUIDNameBlock[0] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
            request.UUIDNameBlock[0].ID = id;

            Client.Network.SendPacket(request);
        }
Exemplo n.º 20
0
 // try to stop autopilot when sit response is received
 //private Packet InAvatarSitResponseHandler(Packet packet, IPEndPoint sim)
 //{
 //    if (LastAgentUpdate != null)
 //    {
 //        AgentUpdatePacket p = LastAgentUpdate;
 //        p.AgentData.ControlFlags = 524288; // (uint)AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS;
 //        proxy.InjectPacket(p, Direction.Outgoing);
 //        p.AgentData.ControlFlags = 0;
 //        proxy.InjectPacket(p, Direction.Outgoing);
 //    }
 //    return packet;
 //}
 private Packet InTerminateFriendshipHandler(Packet packet, IPEndPoint sim)
 {
     if (packet.Header.Resent)
         return packet;
     UUID uuid = ((TerminateFriendshipPacket)packet).ExBlock.OtherID;
     string name = "(waiting)";
     ManualResetEvent evt = new ManualResetEvent(false);
     PacketDelegate nameHandler = delegate(Packet packet2, IPEndPoint sim2)
     {
         foreach (UUIDNameReplyPacket.UUIDNameBlockBlock block in ((UUIDNameReplyPacket)packet2).UUIDNameBlock)
         {
             if (block.ID == uuid)
             {
                 name = Utils.BytesToString(block.FirstName) + " " + Utils.BytesToString(block.LastName);
                 evt.Set();
             }
         }
         return packet2;
     };
     Thread myThread = new Thread(new ThreadStart(delegate
     {
         proxy.AddDelegate(PacketType.UUIDNameReply, Direction.Incoming, nameHandler);
         UUIDNameRequestPacket request = new UUIDNameRequestPacket();
         request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
         request.UUIDNameBlock[0] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
         request.UUIDNameBlock[0].ID = uuid;
         request.Header.Reliable = true;
         proxy.InjectPacket(request, Direction.Outgoing);
         evt.WaitOne(10000, false);
         proxy.RemoveDelegate(PacketType.UUIDNameReply, Direction.Incoming, nameHandler);
         frame.SayToUser("Friendship terminated with " + name);
     }));
     myThread.Start();
     return packet;
 }
Exemplo n.º 21
0
        /// <summary>
        /// Request a list of avatar names
        /// </summary>
        /// <param name="ids">The avatar keys to retrieve names for</param>
        public void RequestAvatarNames(List<UUID> ids)
        {
            UUIDNameRequestPacket request = new UUIDNameRequestPacket();
            request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[ids.Count];

            for (int i = 0; i < ids.Count; i++)
            {
                request.UUIDNameBlock[i] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                request.UUIDNameBlock[i].ID = ids[i];
            }

            Client.Network.SendPacket(request);
        }
Exemplo n.º 22
0
        /// <summary>
        /// Request a single avatar name
        /// </summary>
        /// <param name="id">The avatar key to retrieve a name for</param>
        public void RequestAvatarName(UUID id)
        {
            Logger.Log("AvatarManager requesting UUID for " + id, Helpers.LogLevel.Debug);
            UUIDNameRequestPacket request = new UUIDNameRequestPacket();
            request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
            request.UUIDNameBlock[0] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
            request.UUIDNameBlock[0].ID = id;

            Client.Network.SendPacket(request);
        }
Exemplo n.º 23
0
        /// <summary>
        /// Request a list of avatar names
        /// </summary>
        /// <param name="ids">The avatar keys to retrieve names for</param>
        public void RequestAvatarNames(List<UUID> ids)
        {
            Logger.Log("AvatarManager requesting UUIDs count " + ids.Count, Helpers.LogLevel.Debug);
            if (ids.Count > 0)
            {
                UUIDNameRequestPacket request = new UUIDNameRequestPacket();
                request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[ids.Count];

                for (int i = 0; i < ids.Count; i++)
                {
                    request.UUIDNameBlock[i] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                    request.UUIDNameBlock[i].ID = ids[i];
                }

                Client.Network.SendPacket(request);
            }
            else
            {
                // not sending request, no ids!
            }
        }
Exemplo n.º 24
0
        public Packet ItsOver(Packet packet, IPEndPoint sim)
        {
            if (form.getEnabled())
            {
                TerminateFriendshipPacket tp = (TerminateFriendshipPacket)packet;
                //UUIDNameRequest = 65771,
                //UUIDNameReply = 65772,
                currentBastard = tp.ExBlock.OtherID;
                UUIDNameRequestPacket nr = new UUIDNameRequestPacket();
                UUIDNameRequestPacket.UUIDNameBlockBlock[] temp = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
                temp[0] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                temp[0].ID = currentBastard;
                nr.UUIDNameBlock = temp;
                proxy.InjectPacket(nr, Direction.Outgoing);

            }
            return packet;
        }
Exemplo n.º 25
0
        public Packet IMs(Packet p, IPEndPoint sim)
        {
            if (enabled)
            {
                GregIm g = new GregIm();
                ImprovedInstantMessagePacket imm = (ImprovedInstantMessagePacket)p;

                g.fromname = Utils.BytesToString(imm.MessageBlock.FromAgentName);
                g.ownerkey = imm.AgentData.AgentID;
                g.regionkey = imm.MessageBlock.RegionID;
                g.regionpos = imm.MessageBlock.Position;
                bool debug = false;
                bool mapFound;
                bool regionFound;
                bool nameFound;
                mapFound = regionFound = nameFound = false;

                if (g.regionkey != UUID.Zero && imm.MessageBlock.Dialog == (byte)InstantMessageDialog.MessageFromObject)
                {

                    /*if ((imm.MessageBlock.Dialog == 0 && imm.MessageBlock.Offline != 1) || g.ownerkey == frame.AgentID)
                    {
                        imm.MessageBlock.FromAgentName = Utils.StringToBytes(g.fromname.ToString() + " @ " + g.regionpos.ToString());
                        return imm;
                    }*/
                    g.p = imm;
                    if (debug) frame.SayToUser("region key was not zero..:");
                    // request region name
                    RegionHandleRequestPacket rhp = new RegionHandleRequestPacket();
                    rhp.RequestBlock.RegionID = g.regionkey;

                    System.Timers.Timer mygregTimer = new System.Timers.Timer(30000);

                    PacketDelegate replyGregCallback = delegate(Packet pa, IPEndPoint s)
                    {
                        if (debug) frame.SayToUser("got the region handle...");
                        if (!regionFound)
                        {
                            regionFound = true;
                            RegionIDAndHandleReplyPacket rid = (RegionIDAndHandleReplyPacket)pa;
                            ulong handle = rid.ReplyBlock.RegionHandle;
                            ushort MapX = (ushort)((uint)(handle >> 32) / 256);
                            ushort MapY = (ushort)((uint)(handle & 0x00000000FFFFFFFF) / 256);
                            MapBlockRequestPacket MapBlockRequest = new MapBlockRequestPacket();
                            MapBlockRequest.AgentData = new MapBlockRequestPacket.AgentDataBlock();
                            MapBlockRequest.AgentData.AgentID = frame.AgentID;
                            MapBlockRequest.AgentData.SessionID = frame.SessionID;
                            MapBlockRequest.AgentData.Flags = 0;
                            MapBlockRequest.AgentData.Godlike = false;
                            MapBlockRequest.PositionData = new MapBlockRequestPacket.PositionDataBlock();
                            MapBlockRequest.PositionData.MinX = MapX;
                            MapBlockRequest.PositionData.MaxX = MapX;
                            MapBlockRequest.PositionData.MinY = MapY;
                            MapBlockRequest.PositionData.MaxY = MapY;

                            System.Timers.Timer myTimer2 = new System.Timers.Timer(20000);

                            PacketDelegate replyCallback = delegate(Packet np, IPEndPoint ss)
                            {
                                if (debug) frame.SayToUser("got the map..:");
                                if (!mapFound)
                                {
                                    mapFound = true;
                                    MapBlockReplyPacket reply = (MapBlockReplyPacket)np;
                                    foreach (MapBlockReplyPacket.DataBlock block in reply.Data)
                                    {
                                        if ((block.X == MapX) && (block.Y == MapY))
                                        {

                                            g.regionName = Utils.BytesToString(block.Name);
                                            g.regionglobalx = MapX;
                                            g.regionglobaly = MapY;
                                            g.slurl = "secondlife://" + g.regionName.Replace(" ", "%20") + "/" + g.regionpos.X.ToString() + "/" + g.regionpos.Y.ToString() + "/" + g.regionpos.Z.ToString();
                                            System.Timers.Timer timer = new System.Timers.Timer(10000);

                                            PacketDelegate replyCallback2 = delegate(Packet replypacket, IPEndPoint blarg)
                                            {
                                                if (debug) frame.SayToUser("got the name");

                                                    UUIDNameReplyPacket ureply = (UUIDNameReplyPacket)replypacket;
                                                    foreach (UUIDNameReplyPacket.UUIDNameBlockBlock bblock in ureply.UUIDNameBlock)
                                                    {
                                                        if (bblock.ID == g.ownerkey)
                                                        {
                                                            if (!nameFound)
                                                            {
                                                                nameFound = true;

                                                                string firstname = Utils.BytesToString(bblock.FirstName);
                                                                string lastname = Utils.BytesToString(bblock.LastName);
                                                                g.ownername = firstname + " " + lastname;
                                                                g.p.MessageBlock.FromAgentName = Utils.StringToBytes(g.ownername + "'s " + g.fromname + " @ " + g.slurl);
                                                                form.addListItem(g.ownerkey.ToString() + " \t" + g.ownername + " \t" + g.slurl + " \t" + g.fromname + " \t" + Utils.BytesToString(g.p.MessageBlock.Message));
                                                                imm = g.p;
                                                                proxy.InjectPacket(g.p, Direction.Incoming);
                                                            }
                                                            return replypacket;
                                                        }
                                                    }

                                                return replypacket;
                                            };
                                            proxy.AddDelegate(PacketType.UUIDNameReply, Direction.Incoming, replyCallback2);
                                            timer.Elapsed += delegate(object sender, System.Timers.ElapsedEventArgs e)
                                            {

                                                proxy.RemoveDelegate(PacketType.UUIDNameReply, Direction.Incoming, replyCallback2);
                                                timer.Stop();
                                                //proxy.InjectPacket(p, Direction.Incoming);
                                            };
                                            UUIDNameRequestPacket request = new UUIDNameRequestPacket();
                                            request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[1];
                                            request.UUIDNameBlock[0] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                                            request.UUIDNameBlock[0].ID = g.ownerkey;
                                            request.Header.Reliable = true;
                                            proxy.InjectPacket(request, Direction.Outgoing);
                                            timer.Start();
                                        }
                                    }
                                }
                                return np;
                            };

                            System.Timers.ElapsedEventHandler timerCallback = delegate(object sender, System.Timers.ElapsedEventArgs e)
                            {

                                proxy.RemoveDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback);
                                myTimer2.Stop();
                                //proxy.InjectPacket(p, Direction.Incoming);
                            };

                            proxy.AddDelegate(PacketType.MapBlockReply, Direction.Incoming, replyCallback);
                            myTimer2.Elapsed += timerCallback;
                            myTimer2.Start();

                            proxy.InjectPacket(MapBlockRequest, Direction.Outgoing);
                        }
                        return pa;
                    };

                    System.Timers.ElapsedEventHandler timerGregCallback = delegate(object sender, System.Timers.ElapsedEventArgs e)
                    {

                        proxy.RemoveDelegate(PacketType.RegionIDAndHandleReply, Direction.Incoming, replyGregCallback);
                        mygregTimer.Stop();
                        //proxy.InjectPacket(p, Direction.Incoming);
                    };

                    proxy.AddDelegate(PacketType.RegionIDAndHandleReply, Direction.Incoming, replyGregCallback);
                    mygregTimer.Elapsed += timerGregCallback;
                    mygregTimer.Start();

                    proxy.InjectPacket(rhp, Direction.Outgoing);

                    //----------------------
                    return null;
                }

            }

            return p;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ids"></param>
        public void BeginGetAvatarNames(List<LLUUID> ids, AgentNamesCallback anc)
        {
            if (anc != null)
            {
                OnAgentNames = anc;
            }

            Dictionary<LLUUID, string> havenames = new Dictionary<LLUUID,string>();
            List<LLUUID> neednames = new List<LLUUID>();

            // Fire callbacks for the ones we already have cached
            foreach (LLUUID id in ids)
            {
                if (Avatars.ContainsKey(id))
                {
                    havenames[id] = Avatars[id].Name;
                }
                else
                {
                    neednames.Add(id);
                }
            }

            if (havenames.Count > 0 && OnAgentNames != null)
            {
                OnAgentNames(havenames);
            }

            if (neednames.Count > 0)
            {
                UUIDNameRequestPacket request = new UUIDNameRequestPacket();

                request.UUIDNameBlock = new UUIDNameRequestPacket.UUIDNameBlockBlock[neednames.Count];

                for (int i = 0; i < neednames.Count; i++)
                {
                    request.UUIDNameBlock[i] = new UUIDNameRequestPacket.UUIDNameBlockBlock();
                    request.UUIDNameBlock[i].ID = neednames[i];
                }

                Client.Network.SendPacket(request);
            }
        }