public OSDMap FireMessageReceived(string SessionID, OSDMap message)
        {
            OSDMap result = null;
            ulong  reg;

            if (ulong.TryParse(SessionID, out reg)) //Local region
            {
                if (OnMessageReceived != null)
                {
                    MessageReceived eventCopy = OnMessageReceived;
                    foreach (OSDMap r in from MessageReceived messagedelegate in eventCopy.GetInvocationList() select messagedelegate(message) into r where r != null select r)
                    {
                        result = r;
                    }
                }
            }
            else //IWC
            {
                string[] session = SessionID.Split('|');
                ISyncMessagePosterService smps = m_registry.RequestModuleInterface <ISyncMessagePosterService>();
                //Forward it on
                result = smps.Get(message, UUID.Parse(session[0]), ulong.Parse(session[1]));
            }

            return(result);
        }
        public void KickUser(UUID avatarID, string message)
        {
            //Get required interfaces
            IClientCapsService client = m_capsService.GetClientCapsService(avatarID);

            if (client != null)
            {
                IRegionClientCapsService regionClient = client.GetRootCapsService();
                if (regionClient != null)
                {
                    //Send the message to the client
                    m_messagePost.Get(regionClient.Region.ServerURI,
                                      BuildRequest("KickUserMessage", message, regionClient.AgentID.ToString()),
                                      (resp) =>
                    {
                        IAgentProcessing agentProcessor =
                            m_registry.RequestModuleInterface <IAgentProcessing>();
                        if (agentProcessor != null)
                        {
                            agentProcessor.LogoutAgent(regionClient, true);
                        }
                        MainConsole.Instance.Info("User has been kicked.");
                    });

                    return;
                }
            }
            MainConsole.Instance.Info("Could not find user to send message to.");
        }
Beispiel #3
0
        public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out CreateAgentResponse response)
        {
            response = null;
            if (destination == null)
            {
                response         = new CreateAgentResponse();
                response.Reason  = "Could not connect to destination";
                response.Success = false;
                return(false);
            }
            CreateAgentRequest request = new CreateAgentRequest();

            request.CircuitData   = aCircuit;
            request.Destination   = destination;
            request.TeleportFlags = teleportFlags;

            AutoResetEvent resetEvent = new AutoResetEvent(false);
            OSDMap         result     = null;

            MainConsole.Instance.DebugFormat("[Simulation Service Connector]: Sending Create Agent to " + destination.ServerURI);
            m_syncMessagePoster.Get(destination.ServerURI, request.ToOSD(), (osdresp) =>
            {
                result = osdresp;
                resetEvent.Set();
            });
            bool success = resetEvent.WaitOne(10000);

            if (!success || result == null)
            {
                response         = new CreateAgentResponse();
                response.Reason  = "Could not connect to destination";
                response.Success = false;
                return(false);
            }

            response = new CreateAgentResponse();
            response.FromOSD(result);

            if (!response.Success)
            {
                return(false);
            }
            return(response.Success);
        }
        public OSDMap GetExternalCaps(UUID agentID, GridRegion region)
        {
            if (m_registry == null)
            {
                return(new OSDMap());
            }
            OSDMap resp = new OSDMap();

            if (m_registry.RequestModuleInterface <IGridServerInfoService>() != null)
            {
                m_servers = m_registry.RequestModuleInterface <IGridServerInfoService>().GetGridURIs("SyncMessageServerURI");
                OSDMap req = new OSDMap();
                req["AgentID"] = agentID;
                req["Region"]  = region.ToOSD();
                req["Method"]  = "GetCaps";

                List <ManualResetEvent> events = new List <ManualResetEvent>();
                foreach (string uri in m_servers.Where((u) => (!u.Contains(MainServer.Instance.Port.ToString()))))
                {
                    ManualResetEvent even = new ManualResetEvent(false);
                    m_syncPoster.Get(uri, req, (r) =>
                    {
                        if (r == null)
                        {
                            return;
                        }
                        foreach (KeyValuePair <string, OSD> kvp in r)
                        {
                            resp.Add(kvp.Key, kvp.Value);
                        }
                        even.Set();
                    });
                    events.Add(even);
                }
                if (events.Count > 0)
                {
                    ManualResetEvent.WaitAll(events.ToArray());
                }
            }
            foreach (var h in GetHandlers(agentID, region.RegionID))
            {
                if (m_allowedCapsModules.Contains(h.Name))
                {
                    h.IncomingCapsRequest(agentID, region, m_registry.RequestModuleInterface <ISimulationBase>(), ref resp);
                }
            }
            return(resp);
        }
Beispiel #5
0
        private void m_timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            ISyncMessagePosterService syncMessagePoster =
                m_scenes[0].RequestModuleInterface <ISyncMessagePosterService>();

            if (syncMessagePoster != null)
            {
                List <IScene> FailedScenes = new List <IScene>();
                foreach (IScene scene in m_scenes)
                {
                    OSDMap map = new OSDMap();
                    map["Method"]    = "RegisterHandlers";
                    map["SessionID"] = scene.RegionInfo.RegionHandle.ToString();
                    OSDMap resp = syncMessagePoster.Get(map, UUID.Zero, scene.RegionInfo.RegionHandle);
                    if (resp != null && resp["Reregistered"].AsBoolean())
                    {
                        MainConsole.Instance.Info("[GridRegService]: Successfully reregistered with the grid service");
                    }
                    else
                    {
                        //It failed
                        MainConsole.Instance.Error("[GridRegService]: Failed to successfully reregistered with the grid service");
                        IGridService GridService = scene.RequestModuleInterface <IGridService>();
                        if (
                            !GridService.DeregisterRegion(scene.RegionInfo.RegionHandle, scene.RegionInfo.RegionID,
                                                          scene.RegionInfo.GridSecureSessionID))
                        {
                            MainConsole.Instance.Error("------------- REGION " + scene.RegionInfo.RegionName +
                                                       " IS DEAD ---------------");
                        }
                        else
                        {
                            //Register again...
                            MainConsole.Instance.Error("[GridRegService]: Forcefully reregistered with the grid service... standby");
                            if (!RegisterRegionWithGrid(scene, true))
                            {
                                MainConsole.Instance.Error("------------- REGION " + scene.RegionInfo.RegionName +
                                                           " IS DEAD ---------------");
                            }
                        }
                    }
                }
            }
            else
            {
                MainConsole.Instance.ErrorFormat("[RegisterRegionWithGrid]: ISyncMessagePosterService was null in m_timer_Elapsed;");
            }
        }
Beispiel #6
0
        public LandData ParcelDetailsRegionPostHandler(Aurora.Framework.Services.GridRegion region, UUID agentid)
        {
            OSDMap map = new OSDMap();

            map["AgentID"] = agentid;
            bool   complete = false;
            OSDMap result   = null;

            m_syncMessagePosterService.Get(region.ServerURI, map, (r) => { result = r; complete = true; });
            while (!complete)
            {
                Thread.Sleep(50);
            }

            if (result == null || result.Type != OSDType.Map)
            {
                return(null);
            }
            LandData data = new LandData();

            data.FromOSD((OSDMap)result);
            return(data);
        }
Beispiel #7
0
        public XmlRpcResponse PreflightBuyLandPrepFunc(XmlRpcRequest request, IPEndPoint ep)
        {
            Hashtable      requestData = (Hashtable)request.Params[0];
            XmlRpcResponse ret         = new XmlRpcResponse();
            Hashtable      retparam    = new Hashtable();

            Hashtable membershiplevels = new Hashtable();

            membershiplevels.Add("levels", membershiplevels);

            Hashtable landuse = new Hashtable();

            Hashtable level = new Hashtable
            {
                { "id", "00000000-0000-0000-0000-000000000000" },
                { m_connector.GetConfig().UpgradeMembershipUri, "Premium Membership" }
            };

            if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
            {
                UUID agentId;
                UUID.TryParse((string)requestData["agentId"], out agentId);
                UserCurrency     currency = m_connector.GetUserCurrency(agentId);
                IUserProfileInfo profile  =
                    DataManager.RequestPlugin <IProfileConnector>("IProfileConnector").GetUserProfile(agentId);

                OSDMap   replyData = null;
                bool     response  = false;
                UserInfo user      = m_agentInfoService.GetUserInfo(agentId.ToString());
                if (user == null)
                {
                    landuse.Add("action", false);

                    retparam.Add("success", false);
                    retparam.Add("currency", currency);
                    retparam.Add("membership", level);
                    retparam.Add("landuse", landuse);
                    retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                    ret.Value = retparam;
                }
                else
                {
                    OSDMap map = new OSDMap();
                    map["Method"]  = "GetLandData";
                    map["AgentID"] = agentId;
                    m_syncMessagePoster.Get(user.CurrentRegionURI, map, (o) =>
                    {
                        replyData = o;
                        response  = true;
                    });
                    while (!response)
                    {
                        Thread.Sleep(10);
                    }
                    if (replyData == null || replyData["Success"] == false)
                    {
                        landuse.Add("action", false);

                        retparam.Add("success", false);
                        retparam.Add("currency", currency);
                        retparam.Add("membership", level);
                        retparam.Add("landuse", landuse);
                        retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                        ret.Value = retparam;
                    }
                    else
                    {
                        if (replyData.ContainsKey("SalePrice"))
                        {
                            int  landTierNeeded = (int)(currency.LandInUse + replyData["Area"].AsInteger());
                            bool needsUpgrade   = false;
                            switch (profile.MembershipGroup)
                            {
                            case "Premium":
                            case "":
                                needsUpgrade = landTierNeeded >= currency.Tier;
                                break;

                            case "Banned":
                                needsUpgrade = true;
                                break;
                            }

                            landuse.Add("action", needsUpgrade);

                            retparam.Add("success", true);
                            retparam.Add("currency", currency);
                            retparam.Add("membership", level);
                            retparam.Add("landuse", landuse);
                            retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                            ret.Value = retparam;
                        }
                    }
                }
            }

            return(ret);
        }
Beispiel #8
0
        public XmlRpcResponse PreflightBuyLandPrepFunc(XmlRpcRequest request, IPEndPoint ep)
        {
            Hashtable      requestData = (Hashtable)request.Params[0];
            XmlRpcResponse ret         = new XmlRpcResponse();
            Hashtable      retparam    = new Hashtable();

            Hashtable membershiplevels = new Hashtable();

            membershiplevels.Add("levels", membershiplevels);

            Hashtable landuse = new Hashtable();

            Hashtable level = new Hashtable
            {
                { "id", "00000000-0000-0000-0000-000000000000" },
                { m_connector.GetConfig().UpgradeMembershipUri, "Premium Membership" }
            };

            if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
            {
                UUID agentId;
                UUID.TryParse((string)requestData["agentId"], out agentId);
                UserCurrency     currency = m_connector.GetUserCurrency(agentId);
                IUserProfileInfo profile  =
                    Framework.Utilities.DataManager.RequestPlugin <IProfileConnector>("IProfileConnector").GetUserProfile(agentId);


                //IClientCapsService client = m_dustCurrencyService.Registry.RequestModuleInterface<ICapsService>().GetClientCapsService(agentId);
                OSDMap   replyData = null;
                bool     response  = false;
                UserInfo user      = m_agentInfoService.GetUserInfo(agentId.ToString());
                if (user == null)
                {
                    landuse.Add("action", false);

                    retparam.Add("success", false);
                    retparam.Add("currency", currency);
                    retparam.Add("membership", level);
                    retparam.Add("landuse", landuse);
                    retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                    ret.Value = retparam;
                }
                else
                {
                    OSDMap map = new OSDMap();
                    map["Method"]  = "GetLandData";
                    map["AgentID"] = agentId;
                    m_syncMessagePoster.Get(user.CurrentRegionURI, map, (o) =>
                    {
                        replyData = o;
                        response  = true;
                    });
                    while (!response)
                    {
                        Thread.Sleep(10);
                    }
                    if (replyData == null || replyData["Success"] == false)
                    {
                        landuse.Add("action", false);

                        retparam.Add("success", false);
                        retparam.Add("currency", currency);
                        retparam.Add("membership", level);
                        retparam.Add("landuse", landuse);
                        retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                        ret.Value = retparam;
                    }
                    else
                    {
                        //if (client != null)
                        //    m_dustCurrencyService.SendGridMessage(agentId, String.Format(m_dustCurrencyService.m_options.MessgeBeforeBuyLand, profile.DisplayName, replyData.ContainsKey("SalePrice")), false, UUID.Zero);
                        if (replyData.ContainsKey("SalePrice"))
                        {
                            // I think, this might be usable if they don't have the money
                            // Hashtable currencytable = new Hashtable { { "estimatedCost", replyData["SalePrice"].AsInteger() } };

                            int  landTierNeeded = (int)(currency.LandInUse + replyData["Area"].AsInteger());
                            bool needsUpgrade   = false;
                            switch (profile.MembershipGroup)
                            {
                            case "Premium":
                            case "":
                                needsUpgrade = landTierNeeded >= currency.Tier;
                                break;

                            case "Banned":
                                needsUpgrade = true;
                                break;
                            }
                            // landuse.Add("action", m_DustCurrencyService.m_options.upgradeMembershipUri);
                            landuse.Add("action", needsUpgrade);

                            retparam.Add("success", true);
                            retparam.Add("currency", currency);
                            retparam.Add("membership", level);
                            retparam.Add("landuse", landuse);
                            retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                            ret.Value = retparam;
                        }
                    }
                }
            }

            return(ret);
        }
Beispiel #9
0
        /// <summary>
        /// This Closes child agents on neighboring regions
        /// Calls an asynchronous method to do so..  so it doesn't lag the sim.
        /// </summary>
        protected IScenePresence CrossAgentToNewRegionAsync(IScenePresence agent, Vector3 pos,
                                                            GridRegion crossingRegion, bool isFlying)
        {
            m_log.DebugFormat("[EntityTransferModule]: Crossing agent {0} to region {1}", agent.Name, crossingRegion.RegionName);

            IScene m_scene = agent.Scene;

            if (crossingRegion != null)
            {
                //Make sure that all attachments are ready for the teleport
                IAttachmentsModule attModule = agent.Scene.RequestModuleInterface <IAttachmentsModule>();
                if (attModule != null)
                {
                    attModule.ValidateAttachments(agent.UUID);
                }

                int xOffset = crossingRegion.RegionLocX - m_scene.RegionInfo.RegionLocX;
                int yOffset = crossingRegion.RegionLocY - m_scene.RegionInfo.RegionLocY;

                if (xOffset < 0)
                {
                    pos.X += m_scene.RegionInfo.RegionSizeX;
                }
                else if (xOffset > 0)
                {
                    pos.X -= m_scene.RegionInfo.RegionSizeX;
                }

                if (yOffset < 0)
                {
                    pos.Y += m_scene.RegionInfo.RegionSizeY;
                }
                else if (yOffset > 0)
                {
                    pos.Y -= m_scene.RegionInfo.RegionSizeY;
                }

                //Make sure that they are within bounds (velocity can push it out of bounds)
                if (pos.X < 0)
                {
                    pos.X = 1;
                }
                if (pos.Y < 0)
                {
                    pos.Y = 1;
                }

                if (pos.X > crossingRegion.RegionSizeX)
                {
                    pos.X = crossingRegion.RegionSizeX - 1;
                }
                if (pos.Y > crossingRegion.RegionSizeY)
                {
                    pos.Y = crossingRegion.RegionSizeY - 1;
                }

                AgentData cAgent = new AgentData();
                agent.CopyTo(cAgent);
                cAgent.Position = pos;
                if (isFlying)
                {
                    cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
                }

                AgentCircuitData agentCircuit = agent.ControllingClient.RequestClientInfo();
                agentCircuit.startpos = pos;
                agentCircuit.child    = false;
                IAvatarAppearanceModule appearance = agent.RequestModuleInterface <IAvatarAppearanceModule> ();
                if (appearance != null)
                {
                    agentCircuit.Appearance = appearance.Appearance;
                }

                IEventQueueService eq = agent.Scene.RequestModuleInterface <IEventQueueService>();
                if (eq != null)
                {
                    //This does UpdateAgent and closing of child agents
                    //  messages if they need to be called
                    ISyncMessagePosterService syncPoster = agent.Scene.RequestModuleInterface <ISyncMessagePosterService>();
                    if (syncPoster != null)
                    {
                        OSDMap map = syncPoster.Get(SyncMessageHelper.CrossAgent(crossingRegion, pos,
                                                                                 agent.Velocity, agentCircuit, cAgent, agent.Scene.RegionInfo.RegionHandle),
                                                    agent.Scene.RegionInfo.RegionHandle);
                        bool result = map["Success"].AsBoolean();
                        if (!result)
                        {
                            agent.ControllingClient.SendTeleportFailed(map["Reason"].AsString());
                            return(agent);
                        }
                    }
                }

                agent.MakeChildAgent();

                //Revolution- We already were in this region... we don't need updates about the avatars we already know about, right?
                // OLD: now we have a child agent in this region. Request and send all interesting data about (root) agents in the sim
                //agent.SendOtherAgentsAvatarDataToMe();
                //agent.SendOtherAgentsAppearanceToMe();

                //Kill the groups here, otherwise they will become ghost attachments
                //  and stay in the sim, they'll get readded below into the new sim
                KillAttachments(agent);
            }
            return(agent);
        }
Beispiel #10
0
        public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags)
        {
            sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
            if (finalDestination == null)
            {
                sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
                return;
            }

            m_log.DebugFormat(
                "[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}/{2}",
                finalDestination.ServerURI, finalDestination.RegionName, position);

            sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");

            // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
            // both regions
            if (sp.ParentID != UUID.Zero)
            {
                sp.StandUp();
            }

            //Make sure that all attachments are ready for the teleport
            IAttachmentsModule attModule = sp.Scene.RequestModuleInterface <IAttachmentsModule>();

            if (attModule != null)
            {
                attModule.ValidateAttachments(sp.UUID);
            }

            AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();

            agentCircuit.startpos = position;
            //The agent will be a root agent
            agentCircuit.child = false;
            //Make sure the appearnace is right
            IAvatarAppearanceModule appearance = sp.RequestModuleInterface <IAvatarAppearanceModule> ();

            agentCircuit.Appearance = appearance.Appearance;

            AgentData agent = new AgentData();

            sp.CopyTo(agent);
            //Fix the position
            agent.Position = position;

            IEventQueueService eq = sp.Scene.RequestModuleInterface <IEventQueueService>();

            if (eq != null)
            {
                ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface <ISyncMessagePosterService>();
                if (syncPoster != null)
                {
                    //This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
                    //  messages if they need to be called and deals with the callback
                    OSDMap map = syncPoster.Get(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance,
                                                                                agentCircuit, agent, teleportFlags, finalDestination, sp.Scene.RegionInfo.RegionHandle),
                                                sp.Scene.RegionInfo.RegionHandle);
                    bool result = map["Success"].AsBoolean();
                    if (!result)
                    {
                        // Fix the agent status
                        sp.IsChildAgent = false;
                        sp.ControllingClient.SendTeleportFailed(map["Reason"].AsString());
                        return;
                    }
                }
            }

            //Kill the groups here, otherwise they will become ghost attachments
            //  and stay in the sim, they'll get readded below into the new sim
            KillAttachments(sp);

            // Well, this is it. The agent is over there.
            KillEntity(sp.Scene, sp);

            //Make it a child agent for now... the grid will kill us later if we need to close
            sp.MakeChildAgent();
        }