Example #1
0
        private void ReportAgent(IScenePresence presence)
        {
            IAgentInfoService aservice = m_scene.RequestModuleInterface <IAgentInfoService>();

            if (aservice != null)
            {
                aservice.SetLoggedIn(presence.UUID.ToString(), true, false, presence.Scene.RegionInfo.RegionID);
            }
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "login";

            sendData["UserID"]          = presence.UUID.ToString();
            sendData["SessionID"]       = presence.ControllingClient.SessionId.ToString();
            sendData["SecureSessionID"] = presence.ControllingClient.SecureSessionId.ToString();

            string        reqString = WebUtils.BuildQueryString(sendData);
            List <string> urls      = m_scene.RequestModuleInterface <IConfigurationService>().FindValueOf("PresenceServerURI");

            foreach (string url in urls)
            {
                SynchronousRestFormsRequester.MakeRequest("POST",
                                                          url,
                                                          reqString);
            }

            sendData = new Dictionary <string, object>();
            //sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "report";

            sendData["SessionID"] = presence.ControllingClient.SessionId.ToString();
            sendData["RegionID"]  = presence.Scene.RegionInfo.RegionID.ToString();

            reqString = WebUtils.BuildQueryString(sendData);
            // MainConsole.Instance.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
            foreach (string url in urls)
            {
                SynchronousRestFormsRequester.MakeRequest("POST",
                                                          url,
                                                          reqString);
            }
            if (aservice != null)
            {
                aservice.SetLastPosition(presence.UUID.ToString(), presence.Scene.RegionInfo.RegionID, presence.AbsolutePosition, Vector3.Zero);
            }
        }
Example #2
0
        void m_presenceUpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            IAgentInfoService service = m_scenes[0].RequestModuleInterface <IAgentInfoService> ();

            if (service == null)
            {
                return;
            }
            foreach (Scene scene in m_scenes)
            {
                foreach (IScenePresence sp in scene.GetScenePresences())
                {
                    //Setting the last position updates the 1 hour presence timer, so send this ~ every hour so that the agent does not get logged out
                    service.SetLastPosition(sp.UUID.ToString(), scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
                }
            }
        }
Example #3
0
        protected void SendChildAgentUpdateAsync(AgentPosition agentpos, IRegionClientCapsService regionCaps)
        {
            //We need to send this update out to all the child agents this region has
            INeighborService service = m_registry.RequestModuleInterface <INeighborService>();

            if (service != null)
            {
                ISimulationService SimulationService = m_registry.RequestModuleInterface <ISimulationService>();
                if (SimulationService != null)
                {
                    //Set the last location in the database
                    IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>();
                    if (agentInfoService != null)
                    {
                        //Find the lookAt vector
                        Vector3 lookAt = new Vector3(agentpos.AtAxis.X, agentpos.AtAxis.Y, 0);

                        if (lookAt != Vector3.Zero)
                        {
                            lookAt = Util.GetNormalizedVector(lookAt);
                        }
                        //Update the database
                        agentInfoService.SetLastPosition(regionCaps.AgentID.ToString(), regionCaps.Region.RegionID,
                                                         agentpos.Position, lookAt);
                    }

                    //Also update the service itself
                    regionCaps.LastPosition = agentpos.Position;

                    //Tell all neighbor regions about the new position as well
                    List <GridRegion> ourNeighbors = service.GetNeighbors(regionCaps.Region);
                    foreach (GridRegion region in ourNeighbors)
                    {
                        //Update all the neighbors that we have
                        if (!SimulationService.UpdateAgent(region, agentpos))
                        {
                            m_log.Info("[AgentProcessing]: Failed to inform " + region.RegionName + " about updating agent. ");
                        }
                    }
                }
            }
        }
Example #4
0
 public void SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
 {
     m_localService.SetLastPosition(userID, regionID, lastPosition, lastLookAt);
 }
        public bool LoginAgentToGrid(AgentCircuitData agentCircuit, GridRegion gatekeeper, GridRegion finalDestination, IPEndPoint clientIP, out string reason)
        {
            MainConsole.Instance.DebugFormat("[USER AGENT SERVICE]: Request to login user {0} (@{1}) to grid {2}",
                                             agentCircuit.AgentID, ((clientIP == null) ? "stored IP" : clientIP.Address.ToString()), gatekeeper.ServerURI);
            // Take the IP address + port of the gatekeeper (reg) plus the info of finalDestination
            GridRegion region = new GridRegion();

            region.FromOSD(gatekeeper.ToOSD());
            region.ServerURI        = gatekeeper.ServerURI;
            region.ExternalHostName = finalDestination.ExternalHostName;
            region.InternalEndPoint = finalDestination.InternalEndPoint;
            region.RegionName       = finalDestination.RegionName;
            region.RegionID         = finalDestination.RegionID;
            region.RegionLocX       = finalDestination.RegionLocX;
            region.RegionLocY       = finalDestination.RegionLocY;

            // Generate a new service session
            agentCircuit.ServiceSessionID = region.ServerURI + ";" + UUID.Random();
            TravelingAgentInfo old = UpdateTravelInfo(agentCircuit, region);

            bool   success      = false;
            string myExternalIP = string.Empty;
            string gridName     = gatekeeper.ServerURI;

            MainConsole.Instance.DebugFormat("[USER AGENT SERVICE]: this grid: {0}, desired grid: {1}", m_GridName, gridName);

            if (m_GridName == gridName)
            {
                success = m_GatekeeperService.LoginAgent(agentCircuit, finalDestination, out reason);
            }
            else
            {
                success = m_GatekeeperConnector.CreateAgent(region, agentCircuit, (uint)TeleportFlags.ViaLogin, out myExternalIP, out reason);
                if (success)
                {
                    // Report them as nowhere with the LOGIN_STATUS_LOCKED so that they don't get logged out automatically after an hour of not responding via HG
                    m_PresenceService.SetLastPosition(agentCircuit.AgentID.ToString(), AgentInfoHelpers.LOGIN_STATUS_LOCKED, Vector3.Zero, Vector3.Zero);
                }
            }

            if (!success)
            {
                MainConsole.Instance.DebugFormat("[USER AGENT SERVICE]: Unable to login user {0} to grid {1}, reason: {2}",
                                                 agentCircuit.AgentID, region.ServerURI, reason);

                // restore the old travel info
                lock (m_TravelingAgents)
                {
                    if (old == null)
                    {
                        m_TravelingAgents.Remove(agentCircuit.SessionID);
                    }
                    else
                    {
                        m_TravelingAgents[agentCircuit.SessionID] = old;
                    }
                }

                return(false);
            }
            else
            {
                reason = "";
            }

            MainConsole.Instance.DebugFormat("[USER AGENT SERVICE]: Gatekeeper sees me as {0}", myExternalIP);
            // else set the IP addresses associated with this client
            if (clientIP != null)
            {
                m_TravelingAgents[agentCircuit.SessionID].ClientIPAddress = clientIP.Address.ToString();
            }
            m_TravelingAgents[agentCircuit.SessionID].MyIpAddress = myExternalIP;

            return(true);
        }