void OnIncomingInstantMessage(GridInstantMessage im)
        {
            if (im.dialog == (byte)InstantMessageDialog.RequestTeleport ||
                im.dialog == (byte)InstantMessageDialog.GodLikeRequestTeleport)
            {
                UUID sessionID = new UUID(im.imSessionID);

                if (!m_PendingLures.Contains(sessionID))
                {
                    m_log.DebugFormat("[HG LURE MODULE]: RequestTeleport sessionID={0}, regionID={1}, message={2}", im.imSessionID, im.RegionID, im.message);
                    m_PendingLures.Add(sessionID, im, 7200000); // 2 hours
                }

                // Forward. We do this, because the IM module explicitly rejects
                // IMs of this type
                if (m_TransferModule != null)
                {
                    m_TransferModule.SendInstantMessage(im, delegate(bool success) { });
                }
            }
            else if (im.dialog == (byte)InstantMessageDialog.RequestLure)
            {
                if (m_TransferModule != null)
                {
                    m_TransferModule.SendInstantMessage(im, delegate(bool success) { });
                }
            }
        }
        public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID)
        {
            bool inCache = ByUserCache.TryGetValue(userID, out PresenceData prevUser);

            if (!inCache)
            {
                PresenceData[] dataprv = m_Database.Get("UserID", userID);
                if (dataprv.Length > 0)
                {
                    prevUser = dataprv[0];
                }
            }

            if (!m_allowDuplicatePresences && (prevUser != null))
            {
                m_Database.Delete("UserID", userID.ToString());
                if (inCache)
                {
                    BySessionCache.Remove(prevUser.SessionID);
                    ByUserCache.Remove(userID);
                }
            }

            PresenceData data = new PresenceData();

            data.UserID    = userID;
            data.RegionID  = UUID.Zero;
            data.SessionID = sessionID;
            data.Data      = new Dictionary <string, string>();
            data.Data["SecureSessionID"] = secureSessionID.ToString();

            m_Database.Store(data);
            BySessionCache.Add(sessionID, data, EXPIREMS);
            ByUserCache.Add(userID, data, EXPIREMS);

            string prevUserStr = "";

            if (prevUser != null)
            {
                prevUserStr = string.Format(". This user was already logged-in: session {0}, region {1}", prevUser.SessionID, prevUser.RegionID);
            }

            m_log.DebugFormat("[PRESENCE SERVICE]: LoginAgent: session {0}, user {1}, region {2}, secure session {3}{4}",
                              data.SessionID, data.UserID, data.RegionID, secureSessionID, prevUserStr);

            return(true);
        }
Пример #3
0
        private AssetServicesConnector GetConnector(string url)
        {
            AssetServicesConnector connector = null;

            lock (m_connectors)
            {
                if (!m_connectors.TryGetValue(url, 60000, out connector))
                {
                    connector = new AssetServicesConnector(url);
                    m_connectors.Add(url, connector);
                }
            }
            return(connector);
        }
Пример #4
0
        public void Cache(UUID userID, FolderType type, InventoryFolderBase folder)
        {
            if (!m_FolderTypes.TryGetValue(userID, out Dictionary <FolderType, InventoryFolderBase> ff))
            {
                ff = new Dictionary <FolderType, InventoryFolderBase>();
                m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION);
            }

            // We need to lock here since two threads could potentially retrieve the same dictionary
            // and try to add a folder for that type simultaneously.  Dictionary<>.Add() is not described as thread-safe in the SDK
            // even if the folders are identical.
            lock (ff)
            {
                if (!ff.ContainsKey(type))
                {
                    ff.Add(type, folder);
                }
            }
        }
Пример #5
0
        private GridUserData GetGridUserData(string userID)
        {
            if (userID.Length > 36)
            {
                userID = userID.Substring(0, 36);
            }

            if (cache.TryGetValue(userID, out GridUserData d))
            {
                return(d);
            }

            GridUserData[] ds = m_Database.GetAll(userID);
            if (ds == null || ds.Length == 0)
            {
                cache.Add(userID, null, 300000);
                return(null);
            }

            d = ds[0];
            if (ds.Length > 1)
            {
                // try find most recent record
                try
                {
                    int tsta = int.Parse(d.Data["Login"]);
                    int tstb = int.Parse(d.Data["Logout"]);
                    int cur  = tstb > tsta? tstb : tsta;

                    for (int i = 1; i < ds.Length; ++i)
                    {
                        GridUserData dd = ds[i];
                        tsta = int.Parse(dd.Data["Login"]);
                        tstb = int.Parse(dd.Data["Logout"]);
                        if (tsta > tstb)
                        {
                            tstb = tsta;
                        }
                        if (tstb > cur)
                        {
                            cur = tstb;
                            d   = dd;
                        }
                    }
                }
                catch { }
            }
            cache.Add(userID, d, 300000);
            return(d);
        }