private void OnClientClosed(UUID agentID, Scene scene) { ScenePresence sp = scene.GetScenePresence(agentID); if (sp != null && !sp.IsChildAgent) { // do this for root agents closing out StatusChange(agentID, false); } /* check if there is still an agent somewhere in that case we keep the cache stored */ try { m_Scenes.ForEach(delegate(Scene s) { s.TryGetScenePresence(agentID, out sp); if ((sp != null) && !sp.IsChildAgent && (s != scene)) { throw new ThreadedClasses.ReturnValueException <bool>(true); } }); } catch (ThreadedClasses.ReturnValueException <bool> ) { /* still somewhere that agent */ return; } m_Friends.Remove(agentID); }
void OnClientClosed(UUID clientID, Scene scene) { try { m_Scenes.ForEach(delegate(Scene s) { ScenePresence sp; s.TryGetScenePresence(clientID, out sp); if ((sp != null) && !sp.IsChildAgent && (s != scene)) { m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping inventoryURL in cache", scene.RegionInfo.RegionName, clientID); throw new ThreadedClasses.ReturnValueException <bool>(true); } }); } catch (ThreadedClasses.ReturnValueException <bool> ) { /* still somewhere that agent */ return; } string url; if (m_InventoryURLs.Remove(clientID, out url)) { m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Removed {0} from the cache of inventory URLs for agent {1}", url, clientID.ToString()); } }
public virtual void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) { UUID toAgentID = new UUID(im.toAgentID); try { // Try root avatar only first m_Scenes.ForEach(delegate(Scene scene) { // m_log.DebugFormat( // "[INSTANT MESSAGE]: Looking for root agent {0} in {1}", // toAgentID.ToString(), scene.RegionInfo.RegionName); ScenePresence sp = scene.GetScenePresence(toAgentID); if (sp != null && !sp.IsChildAgent) { // Local message // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", sp.Name, toAgentID); sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); throw new ThreadedClasses.ReturnValueException <bool>(true); } }); // try child avatar second m_Scenes.ForEach(delegate(Scene scene) { // m_log.DebugFormat( // "[INSTANT MESSAGE]: Looking for child of {0} in {1}", toAgentID, scene.RegionInfo.RegionName); ScenePresence sp = scene.GetScenePresence(toAgentID); if (sp != null) { // Local message // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", sp.Name, toAgentID); sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); throw new ThreadedClasses.ReturnValueException <bool>(true); } }); } catch (ThreadedClasses.ReturnValueException <bool> ) { return; } // m_log.DebugFormat("[INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID); SendGridInstantMessageViaXMLRPC(im, result); }
public void CheckSenseRepeaterEvents() { // Go through all timers SenseRepeaters.ForEach(delegate(SensorInfo ts) { // Time has passed? if (ts.next.ToUniversalTime() < DateTime.Now.ToUniversalTime()) { // set next interval ts.next = DateTime.Now.ToUniversalTime().AddSeconds(ts.interval); SensorSweep(ts); } }); }
public bool IsAuthorizedForRegion( string userID, string firstName, string lastName, string regionID, out string message) { m_log.InfoFormat( "[REMOTE AUTHORIZATION CONNECTOR]: IsAuthorizedForRegion checking {0} for region {1}", userID, regionID); bool isAuthorized = true; message = String.Empty; // get the scene this call is being made for Scene scene = null; try { m_scenes.ForEach(delegate(Scene nextScene) { if (nextScene.RegionInfo.RegionID.ToString() == regionID) { throw new ThreadedClasses.ReturnValueException <Scene>(nextScene); } }); } catch (ThreadedClasses.ReturnValueException <Scene> e) { scene = e.Value; } if (scene != null) { string mail = String.Empty; UserAccount account = scene.UserAccountService.GetUserAccount(UUID.Zero, new UUID(userID)); //if account not found, we assume its a foreign visitor from HG, else use account data... if (account != null) { mail = account.Email; firstName = account.FirstName; lastName = account.LastName; } isAuthorized = IsAuthorizedForRegion( userID, firstName, lastName, mail, scene.RegionInfo.RegionName, regionID, out message); } else { message = "Region ID not found"; m_log.ErrorFormat( "[REMOTE AUTHORIZATION CONNECTOR] IsAuthorizedForRegion, can't find scene to match region id of {0}", regionID); } return(isAuthorized); }
/// <summary> /// Iterates through all Scenes, doing a deep scan through assets /// to update the access time of all assets present in the scene or referenced by assets /// in the scene. /// </summary> /// <param name="storeUncached"> /// If true, then assets scanned which are not found in cache are added to the cache. /// </param> /// <returns>Number of distinct asset references found in the scene.</returns> private int TouchAllSceneAssets(bool storeUncached) { UuidGatherer gatherer = new UuidGatherer(m_AssetService); HashSet <UUID> uniqueUuids = new HashSet <UUID>(); m_Scenes.ForEach(delegate(Scene s) { StampRegionStatusFile(s.RegionInfo.RegionID); s.ForEachSOG(delegate(SceneObjectGroup e) { gatherer.AddForInspection(e); gatherer.GatherAll(); IDictionary <UUID, sbyte> assets = gatherer.GatheredUuids; foreach (UUID assetID in assets.Keys) { string filename = GetFileName(assetID.ToString()); if (File.Exists(filename)) { if (!uniqueUuids.Contains(assetID)) { File.SetLastAccessTime(filename, DateTime.Now); } } else if (storeUncached) { AssetBase cachedAsset = null; if (!uniqueUuids.Contains(assetID)) { cachedAsset = m_AssetService.Get(assetID.ToString()); } if (cachedAsset == null && assets[assetID] != (sbyte)AssetType.Unknown) { m_log.DebugFormat( "[FLOTSAM ASSET CACHE]: Could not find asset {0}, type {1} referenced by object {2} at {3} in scene {4} when pre-caching all scene assets", assetID, assets[assetID], e.Name, e.AbsolutePosition, s.Name); } } uniqueUuids.Add(assetID); } assets.Clear(); }); }); return(uniqueUuids.Count); }
private Scene GetClientScene(UUID agentId) { try { m_Scenes.ForEach(delegate(Scene scene) { ScenePresence presence = scene.GetScenePresence(agentId); if (presence != null) { if (!presence.IsChildAgent) { throw new ThreadedClasses.ReturnValueException <Scene>(scene); } } }); } catch (ThreadedClasses.ReturnValueException <Scene> e) { return(e.Value); } return(null); }
// Get the constraint between two bodies. There can be only one. // Return 'true' if a constraint was found. public bool TryGetConstraint(BulletBody body1, BulletBody body2, out BSConstraint returnConstraint) { uint lookingID1 = body1.ID; uint lookingID2 = body2.ID; try { m_constraints.ForEach(delegate(BSConstraint constrain) { if ((constrain.Body1.ID == lookingID1 && constrain.Body2.ID == lookingID2) || (constrain.Body1.ID == lookingID2 && constrain.Body2.ID == lookingID1)) { throw new ThreadedClasses.ReturnValueException <BSConstraint>(constrain); } }); } catch (ThreadedClasses.ReturnValueException <BSConstraint> e) { returnConstraint = e.Value; return(true); } returnConstraint = default(BSConstraint); return(false); }
public void Stop() { IsRunning = false; // m_timeout = -10000; // cause all to expire Thread.Sleep(1000); // let the world move foreach (Thread t in m_workerThreads) { Watchdog.AbortThread(t.ManagedThreadId); } PollServiceHttpRequest wreq; if (m_longPollRequests.Count > 0 && IsRunning) { m_longPollRequests.ForEach(req => m_requests.Enqueue(req)); } try { while (true) { wreq = m_requests.Dequeue(0); ResponsesProcessed++; try { wreq.DoHTTPGruntWork( m_server, wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id)); } catch { } } } catch { } m_longPollRequests.Clear(); m_requests.Clear(); }
public void SendForceObjectSelect(int local_id, int request_type, List <UUID> returnIDs, IClientAPI remote_client) { if (m_scene.Permissions.CanEditParcelProperties(remote_client.AgentId, this, GroupPowers.LandOptions)) { List <uint> resultLocalIDs = new List <uint>(); try { primsOverMe.ForEach(delegate(SceneObjectGroup obj) { if (obj.LocalId > 0) { if (request_type == LandChannel.LAND_SELECT_OBJECTS_OWNER && obj.OwnerID == LandData.OwnerID) { resultLocalIDs.Add(obj.LocalId); } else if (request_type == LandChannel.LAND_SELECT_OBJECTS_GROUP && obj.GroupID == LandData.GroupID && LandData.GroupID != UUID.Zero) { resultLocalIDs.Add(obj.LocalId); } else if (request_type == LandChannel.LAND_SELECT_OBJECTS_OTHER && obj.OwnerID != remote_client.AgentId) { resultLocalIDs.Add(obj.LocalId); } else if (request_type == (int)ObjectReturnType.List && returnIDs.Contains(obj.OwnerID)) { resultLocalIDs.Add(obj.LocalId); } } }); } catch (InvalidOperationException) { m_log.Error("[LAND]: Unable to force select the parcel objects. Arr."); } remote_client.SendForceClientSelectObjects(resultLocalIDs); } }
public void SendInstantMessage(GridInstantMessage im, MessageResultNotification result) { UUID toAgentID = new UUID(im.toAgentID); try { // Try root avatar only first m_Scenes.ForEach(delegate(Scene scene) { // m_log.DebugFormat( // "[HG INSTANT MESSAGE]: Looking for root agent {0} in {1}", // toAgentID.ToString(), scene.RegionInfo.RegionName); ScenePresence sp = scene.GetScenePresence(toAgentID); if (sp != null && !sp.IsChildAgent) { // Local message // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to root agent {0} {1}", user.Name, toAgentID); sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); throw new ThreadedClasses.ReturnValueException <bool>(true); } }); // try child avatar second m_Scenes.ForEach(delegate(Scene scene) { // m_log.DebugFormat( // "[HG INSTANT MESSAGE]: Looking for child of {0} in {1}", // toAgentID, scene.RegionInfo.RegionName); ScenePresence sp = scene.GetScenePresence(toAgentID); if (sp != null) { // Local message // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to child agent {0} {1}", user.Name, toAgentID); sp.ControllingClient.SendInstantMessage(im); // Message sent result(true); throw new ThreadedClasses.ReturnValueException <bool>(true); } }); } catch (ThreadedClasses.ReturnValueException <bool> ) { return; } // m_log.DebugFormat("[HG INSTANT MESSAGE]: Delivering IM to {0} via XMLRPC", im.toAgentID); // Is the user a local user? string url = string.Empty; bool foreigner = false; byte dialog = im.dialog; if (dialog == (byte)InstantMessageDialog.MessageFromObject && !m_EnableObjectIM) { return; } if (UserManagementModule != null && !UserManagementModule.IsLocalGridUser(toAgentID)) // foreign user { url = UserManagementModule.GetUserServerURL(toAgentID, "IMServerURI"); foreigner = true; } Util.FireAndForget(delegate { bool success = false; if (foreigner && url == string.Empty) // we don't know about this user { string recipientUUI = TryGetRecipientUUI(new UUID(im.fromAgentID), toAgentID); m_log.DebugFormat("[HG MESSAGE TRANSFER]: Got UUI {0}", recipientUUI); if (recipientUUI != string.Empty) { UUID id; string u = string.Empty, first = string.Empty, last = string.Empty, secret = string.Empty; if (Util.ParseUniversalUserIdentifier(recipientUUI, out id, out u, out first, out last, out secret)) { success = m_IMService.OutgoingInstantMessage(im, u, true); if (success) { UserManagementModule.AddUser(toAgentID, u + ";" + first + " " + last); } } } } else { success = m_IMService.OutgoingInstantMessage(im, url, foreigner); } if (!success && !foreigner) { HandleUndeliveredMessage(im, result); } else { result(success); } }); return; }
// A single watch dog monitors extant connectors and makes sure that they // are re-connected as necessary. If a connector IS connected, then it is // pinged, but only if a PING period has elapsed. protected static void WatchdogHandler(Object source, ElapsedEventArgs args) { // m_log.InfoFormat("[IRC-Watchdog] Status scan, pdk = {0}, icc = {1}", _pdk_, _icc_); _pdk_ = (_pdk_ + 1) % PING_PERIOD; // cycle the ping trigger _icc_++; // increment the inter-consecutive-connect-delay counter m_connectors.ForEach(delegate(IRCConnector connector) { // m_log.InfoFormat("[IRC-Watchdog] Scanning {0}", connector); if (connector.Enabled) { if (!connector.Connected) { try { // m_log.DebugFormat("[IRC-Watchdog] Connecting {1}:{2}", connector.idn, connector.m_server, connector.m_ircChannel); connector.Connect(); } catch (Exception e) { m_log.ErrorFormat("[IRC-Watchdog] Exception on connector {0}: {1} ", connector.idn, e.Message); } } else { if (connector.m_pending) { if (connector.m_timeout == 0) { m_log.ErrorFormat("[IRC-Watchdog] Login timed-out for connector {0}, reconnecting", connector.idn); connector.Reconnect(); } else { connector.m_timeout--; } } // Being marked connected is not enough to ping. Socket establishment can sometimes take a long // time, in which case the watch dog might try to ping the server before the socket has been // set up, with nasty side-effects. else if (_pdk_ == 0) { try { connector.m_writer.WriteLine(String.Format("PING :{0}", connector.m_server)); connector.m_writer.Flush(); } catch (Exception e) { m_log.ErrorFormat("[IRC-PingRun] Exception on connector {0}: {1} ", connector.idn, e.Message); m_log.Debug(e); connector.Reconnect(); } } } } }); // m_log.InfoFormat("[IRC-Watchdog] Status scan completed"); }