aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Concierge
diff options
context:
space:
mode:
authorDr Scofield2008-10-20 17:31:54 +0000
committerDr Scofield2008-10-20 17:31:54 +0000
commit72a388a7b6dfba8f93ffc5c5c45db4c44bb46480 (patch)
treedb9ab06f6820806d8c2b3fc32029383971e955b7 /OpenSim/Region/Environment/Modules/Avatar/Concierge
parentMantis #2438 (diff)
downloadopensim-SC_OLD-72a388a7b6dfba8f93ffc5c5c45db4c44bb46480.zip
opensim-SC_OLD-72a388a7b6dfba8f93ffc5c5c45db4c44bb46480.tar.gz
opensim-SC_OLD-72a388a7b6dfba8f93ffc5c5c45db4c44bb46480.tar.bz2
opensim-SC_OLD-72a388a7b6dfba8f93ffc5c5c45db4c44bb46480.tar.xz
cleaning up IRCBridgeModule to allow for configuration from in-world,
chat relaying via private channels, and old IRCBridgeModule behaviour. also cleaning up IRCBridgeModule's OpenSim.ini configuration variable names (still supporting "old" variable names). refactored IRCChatModule into IRCConnector and incorporating watchdog from IRCBridgeModule into IRCConnector. enabling ChatModule to be used as a super-class and utilizing it in ConciergeModule.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Concierge')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs181
1 files changed, 139 insertions, 42 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs
index d9730dd..6cc622e 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs
@@ -38,24 +38,28 @@ using OpenMetaverse;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Region.Environment.Interfaces; 39using OpenSim.Region.Environment.Interfaces;
40using OpenSim.Region.Environment.Scenes; 40using OpenSim.Region.Environment.Scenes;
41using OpenSim.Region.Environment.Modules.Avatar.Chat;
41 42
42namespace OpenSim.Region.Environment.Modules.Avatar.Concierge 43namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
43{ 44{
44 public class ConciergeModule : IRegionModule 45 public class ConciergeModule : ChatModule, IRegionModule
45 { 46 {
46 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 48
48 private const int DEBUG_CHANNEL = 2147483647; 49 private const int DEBUG_CHANNEL = 2147483647;
49 50
50 private int _conciergeChannel = 42; 51 private int _conciergeChannel = 42;
51 private List<Scene> _scenes = new List<Scene>(); 52 private List<IScene> _scenes = new List<IScene>();
53 private List<IScene> _conciergedScenes = new List<IScene>();
52 private IConfig _config; 54 private IConfig _config;
53 private string _whoami = "conferencier"; 55 private string _whoami = "conferencier";
56 private bool _replacingChatModule = false;
57 private Regex _regions = null;
54 58
55 internal object _syncy = new object(); 59 internal object _syncy = new object();
56 60
57 #region IRegionModule Members 61 #region IRegionModule Members
58 public void Initialise(Scene scene, IConfigSource config) 62 public override void Initialise(Scene scene, IConfigSource config)
59 { 63 {
60 try 64 try
61 { 65 {
@@ -78,25 +82,58 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
78 return; 82 return;
79 } 83 }
80 84
81 if (_config != null) 85 // check whether ChatModule has been disabled: if yes,
86 // then we'll "stand in"
87 try
88 {
89 if (config.Configs["Chat"] == null)
90 {
91 _replacingChatModule = false;
92 }
93 else
94 {
95 _replacingChatModule = !config.Configs["Chat"].GetBoolean("enabled", true);
96 }
97 }
98 catch (Exception)
82 { 99 {
83 _conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", _conciergeChannel); 100 _replacingChatModule = false;
84 _whoami = _config.GetString("whoami", "conferencier");
85 } 101 }
102 _log.InfoFormat("[Concierge] {0} ChatModule", _replacingChatModule ? "replacing" : "not replacing");
103
104
105 // take note of concierge channel and of identity
106 _conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", _conciergeChannel);
107 _whoami = _config.GetString("whoami", "conferencier");
86 _log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", _whoami); 108 _log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", _whoami);
87 109
110 // calculate regions Regex
111 if (_regions == null)
112 {
113 string regions = _config.GetString("regions", String.Empty);
114 if (!String.IsNullOrEmpty(regions))
115 {
116 _regions = new Regex(regions, RegexOptions.Compiled | RegexOptions.IgnoreCase);
117 }
118 }
119
88 lock (_syncy) 120 lock (_syncy)
89 { 121 {
90 if (!_scenes.Contains(scene)) 122 if (!_scenes.Contains(scene))
91 { 123 {
92 _scenes.Add(scene); 124 _scenes.Add(scene);
125
126 if (_regions.IsMatch(scene.RegionInfo.RegionName))
127 _conciergedScenes.Add(scene);
128
93 // subscribe to NewClient events 129 // subscribe to NewClient events
94 scene.EventManager.OnNewClient += OnNewClient; 130 scene.EventManager.OnNewClient += OnNewClient;
95 scene.EventManager.OnNewClient += OnNewClient;
96 131
97 // subscribe to *Chat events and FilterChat* events 132 // subscribe to *Chat events
98 scene.EventManager.OnChatFromWorld += OnSimChat; 133 scene.EventManager.OnChatFromWorld += OnChatFromWorld;
99 scene.EventManager.OnChatBroadcast += OnSimBroadcast; 134 if (!_replacingChatModule)
135 scene.EventManager.OnChatFromClient += OnChatFromClient;
136 scene.EventManager.OnChatBroadcast += OnChatBroadcast;
100 137
101 // subscribe to agent change events 138 // subscribe to agent change events
102 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent; 139 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
@@ -106,20 +143,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
106 _log.InfoFormat("[Concierge] initialized for {0}", scene.RegionInfo.RegionName); 143 _log.InfoFormat("[Concierge] initialized for {0}", scene.RegionInfo.RegionName);
107 } 144 }
108 145
109 public void PostInitialise() 146 public override void PostInitialise()
110 { 147 {
111 } 148 }
112 149
113 public void Close() 150 public override void Close()
114 { 151 {
115 } 152 }
116 153
117 public string Name 154 public override string Name
118 { 155 {
119 get { return "ConciergeModule"; } 156 get { return "ConciergeModule"; }
120 } 157 }
121 158
122 public bool IsSharedModule 159 public override bool IsSharedModule
123 { 160 {
124 get { return true; } 161 get { return true; }
125 } 162 }
@@ -127,44 +164,90 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
127 #endregion 164 #endregion
128 165
129 #region ISimChat Members 166 #region ISimChat Members
130 public void OnSimBroadcast(Object sender, OSChatMessage c) 167 public override void OnChatBroadcast(Object sender, OSChatMessage c)
131 { 168 {
132 // log to buffer? 169 if (_replacingChatModule)
170 {
171 // distribute chat message to each and every avatar in
172 // the region
173 base.OnChatBroadcast(sender, c);
174 }
175
176 // TODO: capture logic
133 return; 177 return;
134 } 178 }
135 179
136 public void OnSimChat(Object sender, OSChatMessage c) 180 public override void OnChatFromClient(Object sender, OSChatMessage c)
137 { 181 {
138 if (_conciergeChannel == c.Channel) 182 if (_replacingChatModule)
139 {
140 // concierge request: interpret
141 return;
142 }
143
144 if (0 == c.Channel || DEBUG_CHANNEL == c.Channel)
145 { 183 {
146 // if (_amplify) 184 if (_conciergedScenes.Contains(c.Scene))
147 // { 185 {
148 186 // replacing ChatModule: need to redistribute
149 // } 187 // ChatFromClient to interested subscribers
188 Scene scene = (Scene)c.Scene;
189 scene.EventManager.TriggerOnChatFromClient(sender, c);
190
191 // when we are replacing ChatModule, we treat
192 // OnChatFromClient like OnChatBroadcast for
193 // concierged regions, effectively extending the
194 // range of chat to cover the whole
195 // region. however, we don't do this for whisper
196 // (got to have some privacy)
197 if (c.Type != ChatTypeEnum.Whisper)
198 {
199 base.OnChatBroadcast(sender, c);
200 return;
201 }
202 }
150 203
151 // log as avatar/prim chat 204 // redistribution will be done by base class
152 return; 205 base.OnChatFromClient(sender, c);
153 } 206 }
154 207
208 // TODO: capture chat
155 return; 209 return;
156 } 210 }
157 211
212 public override void OnChatFromWorld(Object sender, OSChatMessage c)
213 {
214 if (_replacingChatModule)
215 {
216 if (_conciergedScenes.Contains(c.Scene))
217 {
218 // when we are replacing ChatModule, we treat
219 // OnChatFromClient like OnChatBroadcast for
220 // concierged regions, effectively extending the
221 // range of chat to cover the whole
222 // region. however, we don't do this for whisper
223 // (got to have some privacy)
224 if (c.Type != ChatTypeEnum.Whisper)
225 {
226 base.OnChatBroadcast(sender, c);
227 return;
228 }
229 }
230
231 base.OnChatFromWorld(sender, c);
232 }
233 return;
234 }
158 #endregion 235 #endregion
159 236
160 237
161 public void OnNewClient(IClientAPI client) 238 public override void OnNewClient(IClientAPI client)
162 { 239 {
163 client.OnLogout += OnClientLoggedOut; 240 client.OnLogout += OnClientLoggedOut;
164 client.OnConnectionClosed += OnClientLoggedOut; 241 client.OnConnectionClosed += OnClientLoggedOut;
242 if (_replacingChatModule)
243 client.OnChatFromClient += OnChatFromClient;
165 244
166 _log.DebugFormat("[Concierge] {0} logs on to {1}", client.Name, client.Scene.RegionInfo.RegionName); 245 if (_conciergedScenes.Contains(client.Scene))
167 AnnounceToAgentsRegion(client, String.Format("{0} logs on to {1}", client.Name, client.Scene.RegionInfo.RegionName)); 246 {
247 _log.DebugFormat("[Concierge] {0} logs on to {1}", client.Name, client.Scene.RegionInfo.RegionName);
248 AnnounceToAgentsRegion(client, String.Format("{0} logs on to {1}", client.Name,
249 client.Scene.RegionInfo.RegionName));
250 }
168 } 251 }
169 252
170 public void OnClientLoggedOut(IClientAPI client) 253 public void OnClientLoggedOut(IClientAPI client)
@@ -172,32 +255,46 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
172 client.OnLogout -= OnClientLoggedOut; 255 client.OnLogout -= OnClientLoggedOut;
173 client.OnConnectionClosed -= OnClientLoggedOut; 256 client.OnConnectionClosed -= OnClientLoggedOut;
174 257
175 _log.DebugFormat("[Concierge] {0} logs off from {1}", client.Name, client.Scene.RegionInfo.RegionName); 258 if (_conciergedScenes.Contains(client.Scene))
176 AnnounceToAgentsRegion(client, String.Format("{0} logs off from {1}", client.Name, client.Scene.RegionInfo.RegionName)); 259 {
260 _log.DebugFormat("[Concierge] {0} logs off from {1}", client.Name, client.Scene.RegionInfo.RegionName);
261 AnnounceToAgentsRegion(client, String.Format("{0} logs off from {1}", client.Name,
262 client.Scene.RegionInfo.RegionName));
263 }
177 } 264 }
178 265
179 266
180 public void OnMakeRootAgent(ScenePresence agent) 267 public void OnMakeRootAgent(ScenePresence agent)
181 { 268 {
182 _log.DebugFormat("[Concierge] {0} enters {1}", agent.Name, agent.Scene.RegionInfo.RegionName); 269 if (_conciergedScenes.Contains(agent.Scene))
183 AnnounceToAgentsRegion(agent, String.Format("{0} enters {1}", agent.Name, agent.Scene.RegionInfo.RegionName)); 270 {
271 _log.DebugFormat("[Concierge] {0} enters {1}", agent.Name, agent.Scene.RegionInfo.RegionName);
272 AnnounceToAgentsRegion(agent, String.Format("{0} enters {1}", agent.Name,
273 agent.Scene.RegionInfo.RegionName));
274 }
184 } 275 }
185 276
186 277
187 public void OnMakeChildAgent(ScenePresence agent) 278 public void OnMakeChildAgent(ScenePresence agent)
188 { 279 {
189 _log.DebugFormat("[Concierge] {0} leaves {1}", agent.Name, agent.Scene.RegionInfo.RegionName); 280 if (_conciergedScenes.Contains(agent.Scene))
190 AnnounceToAgentsRegion(agent, String.Format("{0} leaves {1}", agent.Name, agent.Scene.RegionInfo.RegionName)); 281 {
282 _log.DebugFormat("[Concierge] {0} leaves {1}", agent.Name, agent.Scene.RegionInfo.RegionName);
283 AnnounceToAgentsRegion(agent, String.Format("{0} leaves {1}", agent.Name,
284 agent.Scene.RegionInfo.RegionName));
285 }
191 } 286 }
192 287
193 288
194 public void ClientLoggedOut(IClientAPI client) 289 public void ClientLoggedOut(IClientAPI client)
195 { 290 {
196 _log.DebugFormat("[Concierge] {0} logs out of {1}", client.Name, client.Scene.RegionInfo.RegionName); 291 if (_conciergedScenes.Contains(client.Scene))
197 AnnounceToAgentsRegion(client, String.Format("{0} logs out of {1}", client.Name, client.Scene.RegionInfo.RegionName)); 292 {
293 _log.DebugFormat("[Concierge] {0} logs out of {1}", client.Name, client.Scene.RegionInfo.RegionName);
294 AnnounceToAgentsRegion(client, String.Format("{0} logs out of {1}", client.Name, client.Scene.RegionInfo.RegionName));
295 }
198 } 296 }
199 297
200
201 static private Vector3 posOfGod = new Vector3(128, 128, 9999); 298 static private Vector3 posOfGod = new Vector3(128, 128, 9999);
202 299
203 protected void AnnounceToAgentsRegion(IClientAPI client, string msg) 300 protected void AnnounceToAgentsRegion(IClientAPI client, string msg)