예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="objectID"></param>
        /// <param name="sender"></param>
        /// <param name="subject"></param>
        /// <returns></returns>
        public Email GetNextEmail(UUID objectID, string sender, string subject)
        {
            EmailQueue queue = m_MailQueues.GetOrAddIfNotExists(objectID, delegate() { return(new EmailQueue()); });

            queue.m_LastCall = DateTime.Now;

            // Hopefully this isn't too time consuming.  If it is, we can always push it into a worker thread.
            DateTime now = DateTime.Now;

            foreach (UUID uuid in m_MailQueues.Keys)
            {
                if (m_MailQueues.TryGetValue(uuid, out queue))
                {
                    if ((now - queue.m_LastCall) > m_QueueTimeout)
                    {
                        m_MailQueues.Remove(uuid);
                    }
                }
            }

            queue = m_MailQueues.GetOrAddIfNotExists(objectID, delegate() { return(new EmailQueue()); });
            return(queue.m_Queue.RemoveMatch(delegate(Email m)
            {
                return ((sender == null || sender.Equals("") || sender.Equals(m.sender)) &&
                        (subject == null || subject.Equals("") || subject.Equals(m.subject)));
            }));
        }
예제 #2
0
 /// <summary>
 /// Return the xfer uploader for the given transaction.
 /// </summary>
 /// <remarks>
 /// If an uploader does not already exist for this transaction then it is created, otherwise the existing
 /// uploader is returned.
 /// </remarks>
 /// <param name="transactionID"></param>
 /// <returns>The asset xfer uploader</returns>
 public AssetXferUploader RequestXferUploader(UUID transactionID)
 {
     return(XferUploaders.GetOrAddIfNotExists(transactionID, delegate()
     {
         return new AssetXferUploader(this, m_Scene, transactionID, m_dumpAssetsToFile);
     }));
 }
예제 #3
0
        /// <summary>
        /// Get the default http server, an http server for a specific port
        /// and/or an http server bound to a specific address
        /// </summary>
        /// <remarks>
        /// If the requested HTTP server doesn't already exist then a new one is instantiated and started.
        /// </remarks>
        /// <returns></returns>
        /// <param name='port'>If 0 then the default HTTP server is returned.</param>
        /// <param name='ipaddr'>A specific IP address to bind to.  If null then the default IP address is used.</param>
        public static IHttpServer GetHttpServer(uint port, IPAddress ipaddr)
        {
            if (port == 0)
            {
                return(instance);
            }

            if (instance != null && port == instance.Port)
            {
                return(instance);
            }

            return(m_Servers.GetOrAddIfNotExists(port, delegate()
            {
                BaseHttpServer server = new BaseHttpServer(port);

                if (ipaddr != null)
                {
                    server.ListenIPAddress = ipaddr;
                }

                server.Start();
                return server;
            }));
        }
 /// <summary>
 /// Get the collection of asset transactions for the given user.
 /// If one does not already exist, it is created.
 /// </summary>
 /// <param name="userID"></param>
 /// <returns></returns>
 private AgentAssetTransactions GetUserTransactions(UUID userID)
 {
     return(AgentTransactions.GetOrAddIfNotExists(userID, delegate()
     {
         return new AgentAssetTransactions(userID, m_Scene, m_dumpAssetsToFile);
     }));
 }
예제 #5
0
        public void OnRegisterCaps(UUID agentID, Caps caps)
        {
            // Register an event queue for the client

            m_log.DebugFormat(
                "[EVENTQUEUE]: OnRegisterCaps: agentID {0} caps {1} region {2}",
                agentID, caps, m_scene.RegionInfo.RegionName);

            // Let's instantiate a Queue for this agent right now
            TryGetQueue(agentID);

            UUID eventQueueGetUUID;

            eventQueueGetUUID = m_AvatarQueueUUIDMapping.GetOrAddIfNotExists(agentID, delegate() { return(UUID.Random()); });

            m_QueueUUIDAvatarMapping[eventQueueGetUUID] = agentID;
            m_AvatarQueueUUIDMapping[agentID]           = eventQueueGetUUID;

            caps.RegisterPollHandler(
                "EventQueueGet",
                new PollServiceEventArgs(null, GenerateEqgCapPath(eventQueueGetUUID), HasEvents, GetEvents, NoEvents, agentID, SERVER_EQ_TIME_NO_EVENTS));

            Random rnd = new Random(Environment.TickCount);

            try
            {
                m_ids.AddIfNotExists(agentID, delegate() { return(rnd.Next(30000000)); });
            }
            catch (ThreadedClasses.RwLockedDictionary <UUID, int> .KeyAlreadyExistsException)
            {
            }
        }
예제 #6
0
        // -----------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        // -----------------------------------------------------------------
        public bool AttachObjectStore(UUID objectID)
        {
            if (!m_enabled)
            {
                return(false);
            }
            if (!m_enableObjectStore)
            {
                return(false);
            }

            SceneObjectPart sop = m_scene.GetSceneObjectPart(objectID);

            if (sop == null)
            {
                m_log.ErrorFormat("[JsonStore] unable to attach to unknown object; {0}", objectID);
                return(false);
            }

            m_JsonValueStore.GetOrAddIfNotExists(objectID, delegate()
            {
                return(new JsonObjectStore(m_scene, objectID));
            });

            return(true);
        }
예제 #7
0
 /// <summary>
 /// Look up the given user id to check whether it's one that is valid for this grid.
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="uuid"></param>
 /// <returns></returns>
 private bool ResolveUserUuid(Scene scene, UUID uuid)
 {
     return(m_validUserUuids.GetOrAddIfNotExists(uuid, delegate()
     {
         UserAccount account = scene.UserAccountService.GetUserAccount(scene.RegionInfo.ScopeID, uuid);
         return account != null;
     }));
 }
예제 #8
0
 /// <summary>
 ///  Always returns a valid queue
 /// </summary>
 /// <param name="agentId"></param>
 /// <returns></returns>
 private ThreadedClasses.BlockingQueue <OSD> TryGetQueue(UUID agentId)
 {
     return(queues.GetOrAddIfNotExists(agentId, delegate()
     {
         m_log.DebugFormat(
             "[EVENTQUEUE]: Adding new queue for agent {0} in region {1}",
             agentId, m_scene.RegionInfo.RegionName);
         return new ThreadedClasses.BlockingQueue <OSD>();
     }));
 }
예제 #9
0
        public int AddListener(uint localID, UUID itemID, UUID hostID,
                               int channel, string name, UUID id, string msg,
                               int regexBitfield)
        {
            // do we already have a match on this particular filter event?
            List <ListenerInfo> coll = GetListeners(itemID, channel, name, id,
                                                    msg);

            if (coll.Count > 0)
            {
                // special case, called with same filter settings, return same
                // handle (2008-05-02, tested on 1.21.1 server, still holds)
                return(coll[0].GetHandle());
            }

            if (m_curlisteners < m_maxlisteners)
            {
                lock (m_listeners) /* serialize handle creation here */
                {
                    int newHandle = GetNewHandle(itemID);

                    if (newHandle > 0)
                    {
                        ListenerInfo li = new ListenerInfo(newHandle, localID,
                                                           itemID, hostID, channel, name, id, msg,
                                                           regexBitfield);


                        ThreadedClasses.RwLockedList <ListenerInfo> listeners =
                            m_listeners.GetOrAddIfNotExists(channel, delegate()
                        {
                            return(new ThreadedClasses.RwLockedList <ListenerInfo>());
                        });
                        listeners.Add(li);
                        Interlocked.Increment(ref m_curlisteners);

                        return(newHandle);
                    }
                }
            }
            return(-1);
        }
예제 #10
0
 /// <summary>
 /// Look up the given group id to check whether it's one that is valid for this grid.
 /// </summary>
 /// <param name="uuid"></param>
 /// <returns></returns>
 private bool ResolveGroupUuid(UUID uuid)
 {
     if (m_groupsModule == null)
     {
         return(false);
     }
     return(m_validGroupUuids.GetOrAddIfNotExists(uuid, delegate()
     {
         return (m_groupsModule.GetGroupRecord(uuid) != null);
     }));
 }
 private IInventoryService GetConnector(string url)
 {
     return(m_connectors.GetOrAddIfNotExists(url, delegate()
     {
         // Still not as flexible as I would like this to be,
         // but good enough for now
         string connectorType = new HeloServicesConnector(url).Helo();
         m_log.DebugFormat("[HG INVENTORY SERVICE]: HELO returned {0}", connectorType);
         if (connectorType == "opensim-simian")
         {
             return new SimianInventoryServiceConnector(url);
         }
         else
         {
             RemoteXInventoryServicesConnector rxisc = new RemoteXInventoryServicesConnector(url);
             rxisc.Scene = m_Scenes[0];
             return rxisc;
         }
     }));
 }
예제 #12
0
        public static void Add(KeyframeMotion motion)
        {
            KeyframeTimer timer;

            if (motion.Scene == null)
            {
                return;
            }

            timer = m_timers.GetOrAddIfNotExists(motion.Scene, delegate()
            {
                timer = new KeyframeTimer(motion.Scene);

                if (!SceneManager.Instance.AllRegionsReady)
                {
                    // Start the timers only once all the regions are ready. This is required
                    // when using megaregions, because the megaregion is correctly configured
                    // only after all the regions have been loaded. (If we don't do this then
                    // when the prim moves it might think that it crossed into a region.)
                    SceneManager.Instance.OnRegionsReadyStatusChange += delegate(SceneManager sm)
                    {
                        if (sm.AllRegionsReady)
                        {
                            timer.Start();
                        }
                    };
                }

                // Check again, in case the regions were started while we were adding the event handler
                if (SceneManager.Instance.AllRegionsReady)
                {
                    timer.Start();
                }
                return(timer);
            });

            timer.m_motions[motion] = null;
        }