public virtual void CrossRegion(ulong handle, Vector3 pos, Vector3 lookAt,
                                        IPEndPoint newRegionExternalEndPoint,
                                        string capsURL, UUID avatarID, UUID sessionID, int regionSizeX, int regionSizeY)
        {
            if (DebugLevel > 0)
            {
                m_log.DebugFormat("{0} CrossRegion. handle={1}, avatarID={2}, regionSize={3},{4}>",
                                  LogHeader, handle, avatarID, regionSizeX, regionSizeY);
            }

            StringBuilder sb = StartEvent("CrossedRegion");

            LLSDxmlEncode.AddArrayAndMap("AgentData", sb);
            LLSDxmlEncode.AddElem("AgentID", avatarID, sb);
            LLSDxmlEncode.AddElem("SessionID", sessionID, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            LLSDxmlEncode.AddArrayAndMap("Info", sb);
            LLSDxmlEncode.AddElem("LookAt", lookAt, sb);
            LLSDxmlEncode.AddElem("Position", pos, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            LLSDxmlEncode.AddArrayAndMap("RegionData", sb);
            LLSDxmlEncode.AddElem("RegionHandle", handle, sb);
            LLSDxmlEncode.AddElem("SeedCapability", capsURL, sb);
            LLSDxmlEncode.AddElem("SimIP", newRegionExternalEndPoint.Address.GetAddressBytes(), sb);
            LLSDxmlEncode.AddElem("SimPort", newRegionExternalEndPoint.Port, sb);
            LLSDxmlEncode.AddElem("RegionSizeX", (uint)regionSizeX, sb);
            LLSDxmlEncode.AddElem("RegionSizeY", (uint)regionSizeY, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            OSD ev = new OSDllsdxml(EndEvent(sb));

            Enqueue(ev, avatarID);
        }
        public void ScriptRunningEvent(UUID objectID, UUID itemID, bool running, UUID avatarID)
        {
            StringBuilder sb = StartEvent("ScriptRunningReply");

            LLSDxmlEncode.AddArrayAndMap("Script", sb);
            LLSDxmlEncode.AddElem("ObjectID", objectID, sb);
            LLSDxmlEncode.AddElem("ItemID", itemID, sb);
            LLSDxmlEncode.AddElem("Running", running, sb);
            LLSDxmlEncode.AddElem("Mono", true, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            OSDllsdxml item = new OSDllsdxml(EndEvent(sb));

            Enqueue(item, avatarID);
        }
        public void GroupMembershipData(UUID AgentID, GroupMembershipData[] data)
        {
            StringBuilder sb = StartEvent("AgentGroupDataUpdate");

            LLSDxmlEncode.AddArrayAndMap("AgentData", sb);
            LLSDxmlEncode.AddElem("AgentID", AgentID, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            if (data.Length == 0)
            {
                LLSDxmlEncode.AddEmptyArray("GroupData", sb);
                LLSDxmlEncode.AddEmptyArray("NewGroupData", sb);
            }
            else
            {
                List <bool> lstInProfiles = new List <bool>(data.Length);
                LLSDxmlEncode.AddArray("GroupData", sb);
                foreach (GroupMembershipData m in data)
                {
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("GroupID", m.GroupID, sb);
                    LLSDxmlEncode.AddElem("GroupPowers", m.GroupPowers, sb);
                    LLSDxmlEncode.AddElem("AcceptNotices", m.AcceptNotices, sb);
                    LLSDxmlEncode.AddElem("GroupInsigniaID", m.GroupPicture, sb);
                    LLSDxmlEncode.AddElem("Contribution", m.Contribution, sb);
                    LLSDxmlEncode.AddElem("GroupName", m.GroupName, sb);
                    LLSDxmlEncode.AddEndMap(sb);
                    lstInProfiles.Add(m.ListInProfile);
                }
                LLSDxmlEncode.AddEndArray(sb);

                LLSDxmlEncode.AddArray("NewGroupData", sb);
                foreach (bool b in lstInProfiles)
                {
                    LLSDxmlEncode.AddMap(sb);
                    LLSDxmlEncode.AddElem("ListInProfile", b, sb);
                    LLSDxmlEncode.AddEndMap(sb);
                }
                LLSDxmlEncode.AddEndArray(sb);
            }

            OSD ev = new OSDllsdxml(EndEvent(sb));

            Enqueue(ev, AgentID);
        }
        public void partPhysicsProperties(uint localID, byte physhapetype,
                                          float density, float friction, float bounce, float gravmod, UUID avatarID)
        {
            StringBuilder sb = StartEvent("ObjectPhysicsProperties");

            LLSDxmlEncode.AddArrayAndMap("ObjectData", sb);
            LLSDxmlEncode.AddElem("LocalID", (int)localID, sb);
            LLSDxmlEncode.AddElem("Density", density, sb);
            LLSDxmlEncode.AddElem("Friction", friction, sb);
            LLSDxmlEncode.AddElem("GravityMultiplier", gravmod, sb);
            LLSDxmlEncode.AddElem("Restitution", bounce, sb);
            LLSDxmlEncode.AddElem("PhysicsShapeType", (int)physhapetype, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            OSDllsdxml item = new OSDllsdxml(EndEvent(sb));

            Enqueue(item, avatarID);
        }
        public virtual void TeleportFinishEvent(ulong regionHandle, byte simAccess,
                                                IPEndPoint regionExternalEndPoint,
                                                uint locationID, uint flags, string capsURL,
                                                UUID avatarID, int regionSizeX, int regionSizeY)
        {
            if (DebugLevel > 0)
            {
                m_log.DebugFormat("{0} TeleportFinishEvent. handle={1}, endPoint={2}, avatarID={3}",
                                  LogHeader, regionHandle, regionExternalEndPoint, avatarID, regionSizeX, regionSizeY);
            }

            // not sure why flags get overwritten here
            if ((flags & (uint)TeleportFlags.IsFlying) != 0)
            {
                flags = (uint)TeleportFlags.ViaLocation | (uint)TeleportFlags.IsFlying;
            }
            else
            {
                flags = (uint)TeleportFlags.ViaLocation;
            }

            StringBuilder sb = StartEvent("TeleportFinish");

            LLSDxmlEncode.AddArrayAndMap("Info", sb);
            LLSDxmlEncode.AddElem("AgentID", avatarID, sb);
            LLSDxmlEncode.AddElem("LocationID", (uint)4, sb);     // TODO what is this?
            LLSDxmlEncode.AddElem("SimIP", regionExternalEndPoint.Address.GetAddressBytes(), sb);
            LLSDxmlEncode.AddElem("SimPort", regionExternalEndPoint.Port, sb);
            LLSDxmlEncode.AddElem("RegionHandle", regionHandle, sb);
            LLSDxmlEncode.AddElem("SeedCapability", capsURL, sb);
            LLSDxmlEncode.AddElem("SimAccess", (int)simAccess, sb);
            LLSDxmlEncode.AddElem("TeleportFlags", flags, sb);
            LLSDxmlEncode.AddElem("RegionSizeX", (uint)regionSizeX, sb);
            LLSDxmlEncode.AddElem("RegionSizeY", (uint)regionSizeY, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            OSD ev = new OSDllsdxml(EndEvent(sb));

            Enqueue(ev, avatarID);
        }
        public virtual void EnableSimulator(ulong handle, IPEndPoint endPoint, UUID avatarID, int regionSizeX, int regionSizeY)
        {
            if (DebugLevel > 0)
            {
                m_log.DebugFormat("{0} EnableSimulator. handle={1}, endPoint={2}, avatarID={3}",
                                  LogHeader, handle, endPoint, avatarID, regionSizeX, regionSizeY);
            }

            StringBuilder sb = StartEvent("EnableSimulator");

            LLSDxmlEncode.AddArrayAndMap("SimulatorInfo", sb);
            LLSDxmlEncode.AddElem("Handle", handle, sb);
            LLSDxmlEncode.AddElem("IP", endPoint.Address.GetAddressBytes(), sb);
            LLSDxmlEncode.AddElem("Port", endPoint.Port, sb);
            LLSDxmlEncode.AddElem("RegionSizeX", (uint)regionSizeX, sb);
            LLSDxmlEncode.AddElem("RegionSizeY", (uint)regionSizeY, sb);
            LLSDxmlEncode.AddEndMapAndArray(sb);

            OSD item = new OSDllsdxml(EndEvent(sb));

            Enqueue(item, avatarID);
        }
        public virtual void EstablishAgentCommunication(UUID avatarID, IPEndPoint endPoint, string capsPath,
                                                        ulong regionHandle, int regionSizeX, int regionSizeY)
        {
            if (DebugLevel > 0)
            {
                m_log.DebugFormat("{0} EstablishAgentCommunication. handle={1}, endPoint={2}, avatarID={3}",
                                  LogHeader, regionHandle, endPoint, avatarID, regionSizeX, regionSizeY);
            }

            StringBuilder sb = StartEvent("EstablishAgentCommunication");

            LLSDxmlEncode.AddElem("agent-id", avatarID, sb);
            LLSDxmlEncode.AddElem("sim-ip-and-port", endPoint.ToString(), sb);
            LLSDxmlEncode.AddElem("seed-capability", capsPath, sb);
            // current viewers ignore this, also not needed its sent on enablesim
            //LLSDxmlEncode.AddElem("region-handle", regionHandle, sb);
            //LLSDxmlEncode.AddElem("region-size-x", (uint)regionSizeX, sb);
            //LLSDxmlEncode.AddElem("region-size-y", (uint)regionSizeY, sb);

            OSD ev = new OSDllsdxml(EndEvent(sb));

            Enqueue(ev, avatarID);
        }