diff options
author | onefang | 2019-05-19 21:24:15 +1000 |
---|---|---|
committer | onefang | 2019-05-19 21:24:15 +1000 |
commit | 5e4d6cab00cb29cd088ab7b62ab13aff103b64cb (patch) | |
tree | a9fbc62df9eb2d1d9ba2698d8552eae71eca20d8 /OpenSim/Region/OptionalModules/Avatar/Concierge | |
parent | Add a build script. (diff) | |
download | opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.zip opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.gz opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.bz2 opensim-SC-5e4d6cab00cb29cd088ab7b62ab13aff103b64cb.tar.xz |
Dump OpenSim 0.9.0.1 into it's own branch.
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/Concierge')
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs | 87 |
1 files changed, 41 insertions, 46 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs index c48e585..a5dc0ad 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs | |||
@@ -53,15 +53,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
53 | { | 53 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 55 | ||
56 | private const int DEBUG_CHANNEL = 2147483647; | 56 | // private const int DEBUG_CHANNEL = 2147483647; use base value |
57 | 57 | ||
58 | private List<IScene> m_scenes = new List<IScene>(); | 58 | private new List<IScene> m_scenes = new List<IScene>(); |
59 | private List<IScene> m_conciergedScenes = new List<IScene>(); | 59 | private List<IScene> m_conciergedScenes = new List<IScene>(); |
60 | 60 | ||
61 | private bool m_replacingChatModule = false; | 61 | private bool m_replacingChatModule = false; |
62 | 62 | ||
63 | private IConfig m_config; | ||
64 | |||
65 | private string m_whoami = "conferencier"; | 63 | private string m_whoami = "conferencier"; |
66 | private Regex m_regions = null; | 64 | private Regex m_regions = null; |
67 | private string m_welcomes = null; | 65 | private string m_welcomes = null; |
@@ -72,63 +70,62 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
72 | private string m_brokerURI = String.Empty; | 70 | private string m_brokerURI = String.Empty; |
73 | private int m_brokerUpdateTimeout = 300; | 71 | private int m_brokerUpdateTimeout = 300; |
74 | 72 | ||
75 | internal object m_syncy = new object(); | 73 | internal new object m_syncy = new object(); |
76 | 74 | ||
77 | internal bool m_enabled = false; | 75 | internal new bool m_enabled = false; |
78 | 76 | ||
79 | #region ISharedRegionModule Members | 77 | #region ISharedRegionModule Members |
80 | public override void Initialise(IConfigSource config) | 78 | public override void Initialise(IConfigSource configSource) |
81 | { | 79 | { |
82 | m_config = config.Configs["Concierge"]; | 80 | IConfig config = configSource.Configs["Concierge"]; |
83 | 81 | ||
84 | if (null == m_config) | 82 | if (config == null) |
85 | return; | 83 | return; |
86 | 84 | ||
87 | if (!m_config.GetBoolean("enabled", false)) | 85 | if (!config.GetBoolean("enabled", false)) |
88 | return; | 86 | return; |
89 | 87 | ||
90 | m_enabled = true; | 88 | m_enabled = true; |
91 | 89 | ||
92 | |||
93 | // check whether ChatModule has been disabled: if yes, | 90 | // check whether ChatModule has been disabled: if yes, |
94 | // then we'll "stand in" | 91 | // then we'll "stand in" |
95 | try | 92 | try |
96 | { | 93 | { |
97 | if (config.Configs["Chat"] == null) | 94 | if (configSource.Configs["Chat"] == null) |
98 | { | 95 | { |
99 | // if Chat module has not been configured it's | 96 | // if Chat module has not been configured it's |
100 | // enabled by default, so we are not going to | 97 | // enabled by default, so we are not going to |
101 | // replace it. | 98 | // replace it. |
102 | m_replacingChatModule = false; | 99 | m_replacingChatModule = false; |
103 | } | 100 | } |
104 | else | 101 | else |
105 | { | 102 | { |
106 | m_replacingChatModule = !config.Configs["Chat"].GetBoolean("enabled", true); | 103 | m_replacingChatModule = !configSource.Configs["Chat"].GetBoolean("enabled", true); |
107 | } | 104 | } |
108 | } | 105 | } |
109 | catch (Exception) | 106 | catch (Exception) |
110 | { | 107 | { |
111 | m_replacingChatModule = false; | 108 | m_replacingChatModule = false; |
112 | } | 109 | } |
113 | 110 | ||
114 | m_log.InfoFormat("[Concierge] {0} ChatModule", m_replacingChatModule ? "replacing" : "not replacing"); | 111 | m_log.InfoFormat("[Concierge] {0} ChatModule", m_replacingChatModule ? "replacing" : "not replacing"); |
115 | 112 | ||
116 | // take note of concierge channel and of identity | 113 | // take note of concierge channel and of identity |
117 | m_conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", m_conciergeChannel); | 114 | m_conciergeChannel = configSource.Configs["Concierge"].GetInt("concierge_channel", m_conciergeChannel); |
118 | m_whoami = m_config.GetString("whoami", "conferencier"); | 115 | m_whoami = config.GetString("whoami", "conferencier"); |
119 | m_welcomes = m_config.GetString("welcomes", m_welcomes); | 116 | m_welcomes = config.GetString("welcomes", m_welcomes); |
120 | m_announceEntering = m_config.GetString("announce_entering", m_announceEntering); | 117 | m_announceEntering = config.GetString("announce_entering", m_announceEntering); |
121 | m_announceLeaving = m_config.GetString("announce_leaving", m_announceLeaving); | 118 | m_announceLeaving = config.GetString("announce_leaving", m_announceLeaving); |
122 | m_xmlRpcPassword = m_config.GetString("password", m_xmlRpcPassword); | 119 | m_xmlRpcPassword = config.GetString("password", m_xmlRpcPassword); |
123 | m_brokerURI = m_config.GetString("broker", m_brokerURI); | 120 | m_brokerURI = config.GetString("broker", m_brokerURI); |
124 | m_brokerUpdateTimeout = m_config.GetInt("broker_timeout", m_brokerUpdateTimeout); | 121 | m_brokerUpdateTimeout = config.GetInt("broker_timeout", m_brokerUpdateTimeout); |
125 | 122 | ||
126 | m_log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", m_whoami); | 123 | m_log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", m_whoami); |
127 | 124 | ||
128 | // calculate regions Regex | 125 | // calculate regions Regex |
129 | if (m_regions == null) | 126 | if (m_regions == null) |
130 | { | 127 | { |
131 | string regions = m_config.GetString("regions", String.Empty); | 128 | string regions = config.GetString("regions", String.Empty); |
132 | if (!String.IsNullOrEmpty(regions)) | 129 | if (!String.IsNullOrEmpty(regions)) |
133 | { | 130 | { |
134 | m_regions = new Regex(@regions, RegexOptions.Compiled | RegexOptions.IgnoreCase); | 131 | m_regions = new Regex(@regions, RegexOptions.Compiled | RegexOptions.IgnoreCase); |
@@ -136,7 +133,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
136 | } | 133 | } |
137 | } | 134 | } |
138 | 135 | ||
139 | |||
140 | public override void AddRegion(Scene scene) | 136 | public override void AddRegion(Scene scene) |
141 | { | 137 | { |
142 | if (!m_enabled) return; | 138 | if (!m_enabled) return; |
@@ -211,7 +207,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
211 | { | 207 | { |
212 | } | 208 | } |
213 | 209 | ||
214 | new public Type ReplaceableInterface | 210 | new public Type ReplaceableInterface |
215 | { | 211 | { |
216 | get { return null; } | 212 | get { return null; } |
217 | } | 213 | } |
@@ -282,7 +278,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
282 | // range of chat to cover the whole | 278 | // range of chat to cover the whole |
283 | // region. however, we don't do this for whisper | 279 | // region. however, we don't do this for whisper |
284 | // (got to have some privacy) | 280 | // (got to have some privacy) |
285 | if (c.Type != ChatTypeEnum.Whisper) | 281 | if (c.Type != ChatTypeEnum.Whisper) |
286 | { | 282 | { |
287 | base.OnChatBroadcast(sender, c); | 283 | base.OnChatBroadcast(sender, c); |
288 | return; | 284 | return; |
@@ -300,17 +296,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
300 | { | 296 | { |
301 | client.OnLogout += OnClientLoggedOut; | 297 | client.OnLogout += OnClientLoggedOut; |
302 | 298 | ||
303 | if (m_replacingChatModule) | 299 | if (m_replacingChatModule) |
304 | client.OnChatFromClient += OnChatFromClient; | 300 | client.OnChatFromClient += OnChatFromClient; |
305 | } | 301 | } |
306 | 302 | ||
307 | 303 | ||
308 | 304 | ||
309 | public void OnClientLoggedOut(IClientAPI client) | 305 | public void OnClientLoggedOut(IClientAPI client) |
310 | { | 306 | { |
311 | client.OnLogout -= OnClientLoggedOut; | 307 | client.OnLogout -= OnClientLoggedOut; |
312 | client.OnConnectionClosed -= OnClientLoggedOut; | 308 | client.OnConnectionClosed -= OnClientLoggedOut; |
313 | 309 | ||
314 | if (m_conciergedScenes.Contains(client.Scene)) | 310 | if (m_conciergedScenes.Contains(client.Scene)) |
315 | { | 311 | { |
316 | Scene scene = client.Scene as Scene; | 312 | Scene scene = client.Scene as Scene; |
@@ -328,7 +324,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
328 | Scene scene = agent.Scene; | 324 | Scene scene = agent.Scene; |
329 | m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName); | 325 | m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName); |
330 | WelcomeAvatar(agent, scene); | 326 | WelcomeAvatar(agent, scene); |
331 | AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name, | 327 | AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name, |
332 | scene.RegionInfo.RegionName, scene.GetRootAgentCount())); | 328 | scene.RegionInfo.RegionName, scene.GetRootAgentCount())); |
333 | UpdateBroker(scene); | 329 | UpdateBroker(scene); |
334 | } | 330 | } |
@@ -341,7 +337,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
341 | { | 337 | { |
342 | Scene scene = agent.Scene; | 338 | Scene scene = agent.Scene; |
343 | m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName); | 339 | m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName); |
344 | AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name, | 340 | AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name, |
345 | scene.RegionInfo.RegionName, scene.GetRootAgentCount())); | 341 | scene.RegionInfo.RegionName, scene.GetRootAgentCount())); |
346 | UpdateBroker(scene); | 342 | UpdateBroker(scene); |
347 | } | 343 | } |
@@ -378,7 +374,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
378 | 374 | ||
379 | scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 375 | scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
380 | { | 376 | { |
381 | list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID)); | 377 | list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID)); |
382 | }); | 378 | }); |
383 | 379 | ||
384 | list.Append("</avatars>"); | 380 | list.Append("</avatars>"); |
@@ -441,7 +437,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
441 | private void UpdateBrokerDone(IAsyncResult result) | 437 | private void UpdateBrokerDone(IAsyncResult result) |
442 | { | 438 | { |
443 | BrokerState bs = null; | 439 | BrokerState bs = null; |
444 | try | 440 | try |
445 | { | 441 | { |
446 | bs = result.AsyncState as BrokerState; | 442 | bs = result.AsyncState as BrokerState; |
447 | HttpWebRequest updatePost = bs.Poster; | 443 | HttpWebRequest updatePost = bs.Poster; |
@@ -454,19 +450,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
454 | catch (WebException we) | 450 | catch (WebException we) |
455 | { | 451 | { |
456 | m_log.ErrorFormat("[Concierge] broker update to {0} failed with status {1}", bs.Uri, we.Status); | 452 | m_log.ErrorFormat("[Concierge] broker update to {0} failed with status {1}", bs.Uri, we.Status); |
457 | if (null != we.Response) | 453 | if (null != we.Response) |
458 | { | 454 | { |
459 | using (HttpWebResponse resp = we.Response as HttpWebResponse) | 455 | using (HttpWebResponse resp = we.Response as HttpWebResponse) |
460 | { | 456 | { |
461 | m_log.ErrorFormat("[Concierge] response from {0} status code: {1}", bs.Uri, resp.StatusCode); | 457 | m_log.ErrorFormat("[Concierge] response from {0} status code: {1}", bs.Uri, resp.StatusCode); |
462 | m_log.ErrorFormat("[Concierge] response from {0} status desc: {1}", bs.Uri, resp.StatusDescription); | 458 | m_log.ErrorFormat("[Concierge] response from {0} status desc: {1}", bs.Uri, resp.StatusDescription); |
463 | m_log.ErrorFormat("[Concierge] response from {0} server: {1}", bs.Uri, resp.Server); | 459 | m_log.ErrorFormat("[Concierge] response from {0} server: {1}", bs.Uri, resp.Server); |
464 | 460 | ||
465 | if (resp.ContentLength > 0) | 461 | if (resp.ContentLength > 0) |
466 | { | 462 | { |
467 | StreamReader content = new StreamReader(resp.GetResponseStream()); | 463 | using(StreamReader content = new StreamReader(resp.GetResponseStream())) |
468 | m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd()); | 464 | m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd()); |
469 | content.Close(); | ||
470 | } | 465 | } |
471 | } | 466 | } |
472 | } | 467 | } |
@@ -480,12 +475,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
480 | // welcome file there: if yes, send it to the agent | 475 | // welcome file there: if yes, send it to the agent |
481 | if (!String.IsNullOrEmpty(m_welcomes)) | 476 | if (!String.IsNullOrEmpty(m_welcomes)) |
482 | { | 477 | { |
483 | string[] welcomes = new string[] { | 478 | string[] welcomes = new string[] { |
484 | Path.Combine(m_welcomes, agent.Scene.RegionInfo.RegionName), | 479 | Path.Combine(m_welcomes, agent.Scene.RegionInfo.RegionName), |
485 | Path.Combine(m_welcomes, "DEFAULT")}; | 480 | Path.Combine(m_welcomes, "DEFAULT")}; |
486 | foreach (string welcome in welcomes) | 481 | foreach (string welcome in welcomes) |
487 | { | 482 | { |
488 | if (File.Exists(welcome)) | 483 | if (File.Exists(welcome)) |
489 | { | 484 | { |
490 | try | 485 | try |
491 | { | 486 | { |
@@ -504,7 +499,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
504 | { | 499 | { |
505 | m_log.ErrorFormat("[Concierge]: welcome file {0} is malformed: {1}", welcome, fe); | 500 | m_log.ErrorFormat("[Concierge]: welcome file {0} is malformed: {1}", welcome, fe); |
506 | } | 501 | } |
507 | } | 502 | } |
508 | return; | 503 | return; |
509 | } | 504 | } |
510 | m_log.DebugFormat("[Concierge]: no welcome message for region {0}", scene.RegionInfo.RegionName); | 505 | m_log.DebugFormat("[Concierge]: no welcome message for region {0}", scene.RegionInfo.RegionName); |
@@ -516,7 +511,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
516 | // protected void AnnounceToAgentsRegion(Scene scene, string msg) | 511 | // protected void AnnounceToAgentsRegion(Scene scene, string msg) |
517 | // { | 512 | // { |
518 | // ScenePresence agent = null; | 513 | // ScenePresence agent = null; |
519 | // if ((client.Scene is Scene) && (client.Scene as Scene).TryGetScenePresence(client.AgentId, out agent)) | 514 | // if ((client.Scene is Scene) && (client.Scene as Scene).TryGetScenePresence(client.AgentId, out agent)) |
520 | // AnnounceToAgentsRegion(agent, msg); | 515 | // AnnounceToAgentsRegion(agent, msg); |
521 | // else | 516 | // else |
522 | // m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name); | 517 | // m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name); |
@@ -591,7 +586,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
591 | 586 | ||
592 | string regionName = (string)requestData["region"]; | 587 | string regionName = (string)requestData["region"]; |
593 | IScene scene = m_scenes.Find(delegate(IScene s) { return s.RegionInfo.RegionName == regionName; }); | 588 | IScene scene = m_scenes.Find(delegate(IScene s) { return s.RegionInfo.RegionName == regionName; }); |
594 | if (scene == null) | 589 | if (scene == null) |
595 | throw new Exception(String.Format("unknown region \"{0}\"", regionName)); | 590 | throw new Exception(String.Format("unknown region \"{0}\"", regionName)); |
596 | 591 | ||
597 | if (!m_conciergedScenes.Contains(scene)) | 592 | if (!m_conciergedScenes.Contains(scene)) |