bool ForwardIMToGrid(string url, GridInstantMessage im, UUID toAgentID, bool foreigner)
        {
            if (InstantMessageServiceConnector.SendInstantMessage(url, im, m_messageKey))
            {
                // IM delivery successful, so store the Agent's location in our local cache.
                lock (m_UserLocationMap)
                {
                    if (m_UserLocationMap.ContainsKey(toAgentID))
                    {
                        m_UserLocationMap[toAgentID] = url;
                    }
                    else
                    {
                        m_UserLocationMap.Add(toAgentID, url);
                    }
                }

                return(true);
            }
            else
            {
                // try again, but lookup user this time.

                // This is recursive!!!!!
                return(TrySendInstantMessage(im, url, false, foreigner));
            }
        }
Example #2
0
        public static void Main(string[] args)
        {
            ConsoleAppender consoleAppender = new ConsoleAppender();

            consoleAppender.Layout =
                new PatternLayout("%date [%thread] %-5level %logger [%property{NDC}] - %message%newline");
            log4net.Config.BasicConfigurator.Configure(consoleAppender);

            string             serverURI = "http://127.0.0.1:8002";
            GridInstantMessage im        = new GridInstantMessage();

            im.fromAgentID = new Guid();
            im.toAgentID   = new Guid();
            im.message     = "Hello";
            im.imSessionID = new Guid();

            bool success = InstantMessageServiceConnector.SendInstantMessage(serverURI, im);

            if (success)
            {
                m_log.InfoFormat("[IM CLIENT]: Successfully IMed {0}", serverURI);
            }
            else
            {
                m_log.InfoFormat("[IM CLIENT]: failed to IM {0}", serverURI);
            }

            System.Console.WriteLine("\n");
        }
        bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID, bool foreigner)
        {
            bool       imresult = false;
            GridRegion reginfo  = null;

            if (!m_RegionCache.TryGetValue(upd.RegionID, out reginfo))
            {
                reginfo = m_GridService.GetRegionByUUID(UUID.Zero /*!!!*/, upd.RegionID);
                if (reginfo != null)
                {
                    m_RegionCache.AddOrUpdate(upd.RegionID, reginfo, CACHE_EXPIRATION_SECONDS);
                }
            }

            if (reginfo != null)
            {
                imresult = InstantMessageServiceConnector.SendInstantMessage(reginfo.ServerURI, im, m_messageKey);
            }
            else
            {
                m_log.DebugFormat("[HG IM SERVICE]: Failed to deliver message to {0}", reginfo.ServerURI);
                return(false);
            }

            if (imresult)
            {
                // IM delivery successful, so store the Agent's location in our local cache.
                lock (m_UserLocationMap)
                {
                    if (m_UserLocationMap.ContainsKey(toAgentID))
                    {
                        m_UserLocationMap[toAgentID] = upd;
                    }
                    else
                    {
                        m_UserLocationMap.Add(toAgentID, upd);
                    }
                }
                return(true);
            }
            else
            {
                // try again, but lookup user this time.
                // Warning, this must call the Async version
                // of this method or we'll be making thousands of threads
                // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
                // The version that spawns the thread is SendGridInstantMessageViaXMLRPC

                // This is recursive!!!!!
                return(TrySendInstantMessage(im, upd, false, foreigner));
            }
        }
Example #4
0
        public void HGIM_001()
        {
            GridInstantMessage im = new GridInstantMessage();

            im.fromAgentID = new Guid();
            im.toAgentID   = new Guid();
            im.message     = "Hello";
            im.imSessionID = new Guid();

            bool success = InstantMessageServiceConnector.SendInstantMessage(DemonServer.Address, im, String.Empty);

            Assert.IsFalse(success, "Sending of IM succeeded, but it should have failed");
        }
Example #5
0
        private bool SendAgentGodKillToRegion(UUID scopeID, UUID agentID, GridUserInfo guinfo)
        {
            UUID       regionID = guinfo.LastRegionID;
            GridRegion regInfo  = m_GridService.GetRegionByUUID(scopeID, regionID);

            if (regInfo == null)
            {
                return(false);
            }

            string regURL = regInfo.ServerURI;

            if (String.IsNullOrEmpty(regURL))
            {
                return(false);
            }

            UUID guuid = new UUID("6571e388-6218-4574-87db-f9379718315e");

            GridInstantMessage msg = new GridInstantMessage();

            msg.imSessionID    = UUID.Zero.Guid;
            msg.fromAgentID    = guuid.Guid;
            msg.toAgentID      = agentID.Guid;
            msg.timestamp      = (uint)Util.UnixTimeSinceEpoch();
            msg.fromAgentName  = "GRID";
            msg.message        = string.Format("New login detected");
            msg.dialog         = 250; // God kick
            msg.fromGroup      = false;
            msg.offline        = (byte)0;
            msg.ParentEstateID = 0;
            msg.Position       = Vector3.Zero;
            msg.RegionID       = scopeID.Guid;
            msg.binaryBucket   = new byte[1] {
                0
            };
            InstantMessageServiceConnector.SendInstantMessage(regURL, msg, m_messageKey);

            m_GridUserService.LoggedOut(agentID.ToString(),
                                        UUID.Zero, guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt);

            return(true);
        }
Example #6
0
        bool SendIMToRegion(PresenceInfo upd, GridInstantMessage im, UUID toAgentID, bool foreigner)
        {
            GridRegion reginfo = null;

            if (!m_RegionCache.TryGetValue(upd.RegionID, REGIONCACHE_EXPIRATION, out reginfo))
            {
                reginfo = m_GridService.GetRegionByUUID(UUID.Zero /*!!!*/, upd.RegionID);
                m_RegionCache.AddOrUpdate(upd.RegionID, reginfo, reginfo == null ? 60000 : REGIONCACHE_EXPIRATION);
            }

            if (reginfo == null)
            {
                return(false);
            }

            bool imresult = InstantMessageServiceConnector.SendInstantMessage(reginfo.ServerURI, im, m_messageKey);

            if (imresult)
            {
                // IM delivery successful, so store the Agent's location in our local cache.
                lock (m_UserLocationMap)
                    m_UserLocationMap[toAgentID] = upd;
                return(true);
            }
            else
            {
                // try again, but lookup user this time.
                // Warning, this must call the Async version
                // of this method or we'll be making thousands of threads
                // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
                // The version that spawns the thread is SendGridInstantMessageViaXMLRPC

                // This is recursive!!!!!
                return(TrySendInstantMessage(im, upd, false, foreigner));
            }
        }