diff options
author | Sean Dague | 2008-01-31 17:15:41 +0000 |
---|---|---|
committer | Sean Dague | 2008-01-31 17:15:41 +0000 |
commit | 61ed12c4d8c527cba34123e1009622aa8a88188b (patch) | |
tree | 82c50896bccbae919a6e012be91768bb51cbd8a1 /OpenSim/Region/Environment/Modules | |
parent | * setting some readonlies (diff) | |
download | opensim-SC-61ed12c4d8c527cba34123e1009622aa8a88188b.zip opensim-SC-61ed12c4d8c527cba34123e1009622aa8a88188b.tar.gz opensim-SC-61ed12c4d8c527cba34123e1009622aa8a88188b.tar.bz2 opensim-SC-61ed12c4d8c527cba34123e1009622aa8a88188b.tar.xz |
revert last IRC bridge changes as this broke chat on my test environment.
Going to sift through the diff later to sort out what the root cause is here.
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
-rw-r--r-- | OpenSim/Region/Environment/Modules/ChatModule.cs | 103 |
1 files changed, 23 insertions, 80 deletions
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 9aea977..d6df978 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs | |||
@@ -163,12 +163,6 @@ namespace OpenSim.Region.Environment.Modules | |||
163 | fromAgentID = e.Sender.AgentId; | 163 | fromAgentID = e.Sender.AgentId; |
164 | } | 164 | } |
165 | 165 | ||
166 | // Try to reconnect to server if not connected | ||
167 | if ((m_irc.Enabled)&&(!m_irc.Connected)) | ||
168 | { | ||
169 | m_irc.Connect(m_scenes); | ||
170 | } | ||
171 | |||
172 | if (e.Message.Length > 0) | 166 | if (e.Message.Length > 0) |
173 | { | 167 | { |
174 | if (m_irc.Connected && (avatar != null)) // this is to keep objects from talking to IRC | 168 | if (m_irc.Connected && (avatar != null)) // this is to keep objects from talking to IRC |
@@ -211,7 +205,6 @@ namespace OpenSim.Region.Environment.Modules | |||
211 | private bool m_connected = false; | 205 | private bool m_connected = false; |
212 | 206 | ||
213 | private List<Scene> m_scenes = null; | 207 | private List<Scene> m_scenes = null; |
214 | private List<Scene> m_last_scenes = null; | ||
215 | private LogBase m_log; | 208 | private LogBase m_log; |
216 | 209 | ||
217 | public IRCChatModule(IConfigSource config) | 210 | public IRCChatModule(IConfigSource config) |
@@ -221,19 +214,6 @@ namespace OpenSim.Region.Environment.Modules | |||
221 | m_writer = null; | 214 | m_writer = null; |
222 | m_reader = null; | 215 | m_reader = null; |
223 | 216 | ||
224 | // configuration in OpenSim.ini | ||
225 | // [IRC] | ||
226 | // server = chat.freenode.net | ||
227 | // nick = OSimBot_mysim | ||
228 | // ;username = OSimBot_mysim | ||
229 | // channel = #opensim-regions | ||
230 | // port = 6667 | ||
231 | // | ||
232 | // Traps I/O disconnects so it does not crash the sim | ||
233 | // Trys to reconnect if disconnected and someone says something | ||
234 | // Tells IRC server "QUIT" when doing a close (just to be nice) | ||
235 | // Default port back to 6667 | ||
236 | |||
237 | try | 217 | try |
238 | { | 218 | { |
239 | m_server = config.Configs["IRC"].GetString("server"); | 219 | m_server = config.Configs["IRC"].GetString("server"); |
@@ -258,7 +238,7 @@ namespace OpenSim.Region.Environment.Modules | |||
258 | try | 238 | try |
259 | { | 239 | { |
260 | m_scenes = scenes; | 240 | m_scenes = scenes; |
261 | m_last_scenes = scenes; | 241 | |
262 | m_tcp = new TcpClient(m_server, (int) m_port); | 242 | m_tcp = new TcpClient(m_server, (int) m_port); |
263 | m_log.Verbose("IRC", "Connecting..."); | 243 | m_log.Verbose("IRC", "Connecting..."); |
264 | m_stream = m_tcp.GetStream(); | 244 | m_stream = m_tcp.GetStream(); |
@@ -310,20 +290,14 @@ namespace OpenSim.Region.Environment.Modules | |||
310 | m_log.Error("IRC", "Disconnected from IRC server."); | 290 | m_log.Error("IRC", "Disconnected from IRC server."); |
311 | listener.Abort(); | 291 | listener.Abort(); |
312 | pingSender.Abort(); | 292 | pingSender.Abort(); |
313 | m_writer.Close(); | ||
314 | m_reader.Close(); | ||
315 | m_tcp.Close(); | ||
316 | m_connected = false; | 293 | m_connected = false; |
317 | if (m_enabled) { Connect(m_last_scenes); } | ||
318 | } | 294 | } |
319 | } | 295 | } |
320 | 296 | ||
321 | private Dictionary<string, string> ExtractMsg(string input) | 297 | private Dictionary<string, string> ExtractMsg(string input) |
322 | { | 298 | { |
323 | m_log.Verbose("IRC", "ExtractMsg: " + input); | ||
324 | Dictionary<string, string> result = null; | 299 | Dictionary<string, string> result = null; |
325 | //string regex = @":(?<nick>\w*)!~(?<user>\S*) PRIVMSG (?<channel>\S+) :(?<msg>.*)"; | 300 | string regex = @":(?<nick>\w*)!~(?<user>\S*) PRIVMSG (?<channel>\S+) :(?<msg>.*)"; |
326 | string regex = @":(?<nick>\w*)!(?<user>\S*) PRIVMSG (?<channel>\S+) :(?<msg>.*)"; | ||
327 | Regex RE = new Regex(regex, RegexOptions.Multiline); | 301 | Regex RE = new Regex(regex, RegexOptions.Multiline); |
328 | MatchCollection matches = RE.Matches(input); | 302 | MatchCollection matches = RE.Matches(input); |
329 | // Get some direct matches $1 $4 is a | 303 | // Get some direct matches $1 $4 is a |
@@ -350,24 +324,10 @@ namespace OpenSim.Region.Environment.Modules | |||
350 | { | 324 | { |
351 | while (true) | 325 | while (true) |
352 | { | 326 | { |
353 | try | 327 | m_writer.WriteLine("PING :" + m_server); |
354 | { | 328 | m_writer.Flush(); |
355 | m_writer.WriteLine("PING :" + m_server); | 329 | Thread.Sleep(15000); |
356 | m_writer.Flush(); | 330 | } |
357 | Thread.Sleep(15000); | ||
358 | } | ||
359 | catch (IOException) | ||
360 | { | ||
361 | m_log.Error("IRC", "Disconnected from IRC server."); | ||
362 | listener.Abort(); | ||
363 | pingSender.Abort(); | ||
364 | m_writer.Close(); | ||
365 | m_reader.Close(); | ||
366 | m_tcp.Close(); | ||
367 | m_connected = false; | ||
368 | if (m_enabled) { Connect(m_last_scenes); } | ||
369 | } | ||
370 | } | ||
371 | } | 331 | } |
372 | 332 | ||
373 | public void ListenerRun() | 333 | public void ListenerRun() |
@@ -376,53 +336,36 @@ namespace OpenSim.Region.Environment.Modules | |||
376 | LLVector3 pos = new LLVector3(128, 128, 20); | 336 | LLVector3 pos = new LLVector3(128, 128, 20); |
377 | while (true) | 337 | while (true) |
378 | { | 338 | { |
379 | try | 339 | while ((inputLine = m_reader.ReadLine()) != null) |
380 | { | 340 | { |
381 | while ((inputLine = m_reader.ReadLine()) != null) | 341 | // Console.WriteLine(inputLine); |
342 | if (inputLine.Contains(m_channel)) | ||
382 | { | 343 | { |
383 | // Console.WriteLine(inputLine); | 344 | Dictionary<string, string> data = ExtractMsg(inputLine); |
384 | if (inputLine.Contains(m_channel)) | 345 | if (data != null) |
385 | { | 346 | { |
386 | Dictionary<string, string> data = ExtractMsg(inputLine); | 347 | foreach (Scene m_scene in m_scenes) |
387 | if (data != null) | ||
388 | { | 348 | { |
389 | foreach (Scene m_scene in m_scenes) | 349 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) |
390 | { | 350 | { |
391 | m_scene.ForEachScenePresence(delegate(ScenePresence avatar) | 351 | if (!avatar.IsChildAgent) |
392 | { | 352 | { |
393 | if (!avatar.IsChildAgent) | 353 | avatar.ControllingClient.SendChatMessage( |
394 | { | 354 | Helpers.StringToField(data["msg"]), 255, |
395 | avatar.ControllingClient.SendChatMessage( | 355 | pos, data["nick"], |
396 | Helpers.StringToField(data["msg"]), 255, | 356 | LLUUID.Zero); |
397 | pos, data["nick"], | 357 | } |
398 | LLUUID.Zero); | 358 | }); |
399 | } | ||
400 | }); | ||
401 | } | ||
402 | } | 359 | } |
403 | } | 360 | } |
404 | } | 361 | } |
405 | Thread.Sleep(50); | ||
406 | } | 362 | } |
407 | catch (IOException) | 363 | Thread.Sleep(50); |
408 | { | ||
409 | m_log.Error("IRC", "Disconnected from IRC server."); | ||
410 | listener.Abort(); | ||
411 | pingSender.Abort(); | ||
412 | m_writer.Close(); | ||
413 | m_reader.Close(); | ||
414 | m_tcp.Close(); | ||
415 | m_connected = false; | ||
416 | if (m_enabled) { Connect(m_last_scenes); } | ||
417 | } | ||
418 | |||
419 | } | 364 | } |
420 | } | 365 | } |
421 | 366 | ||
422 | public void Close() | 367 | public void Close() |
423 | { | 368 | { |
424 | m_writer.WriteLine("QUIT :" + m_nick+" to "+m_channel+" wormhole with "+m_server+" closing"); | ||
425 | m_writer.Flush(); | ||
426 | listener.Abort(); | 369 | listener.Abort(); |
427 | pingSender.Abort(); | 370 | pingSender.Abort(); |
428 | m_writer.Close(); | 371 | m_writer.Close(); |
@@ -430,4 +373,4 @@ namespace OpenSim.Region.Environment.Modules | |||
430 | m_tcp.Close(); | 373 | m_tcp.Close(); |
431 | } | 374 | } |
432 | } | 375 | } |
433 | } | 376 | } \ No newline at end of file |