aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs58
1 files changed, 25 insertions, 33 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
index 6985371..ffbebe7 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
@@ -97,14 +97,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
97 97
98 // How many regions depend upon this connection 98 // How many regions depend upon this connection
99 // This count is updated by the ChannelState object and reflects the sum 99 // This count is updated by the ChannelState object and reflects the sum
100 // of the region clients associated with the set of associated channel 100 // of the region clients associated with the set of associated channel
101 // state instances. That's why it cannot be managed here. 101 // state instances. That's why it cannot be managed here.
102 102
103 internal int depends = 0; 103 internal int depends = 0;
104 104
105 // This variable counts the number of resets that have been performed 105 // This variable counts the number of resets that have been performed
106 // on the connector. When a listener thread terminates, it checks to 106 // on the connector. When a listener thread terminates, it checks to
107 // see of the reset count has changed before it schedules another 107 // see of the reset count has changed before it schedules another
108 // reset. 108 // reset.
109 109
110 internal int m_resetk = 0; 110 internal int m_resetk = 0;
@@ -270,7 +270,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
270 270
271 public void Close() 271 public void Close()
272 { 272 {
273
274 m_log.InfoFormat("[IRC-Connector-{0}] Closing", idn); 273 m_log.InfoFormat("[IRC-Connector-{0}] Closing", idn);
275 274
276 lock (msyncConnect) 275 lock (msyncConnect)
@@ -295,7 +294,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
295 } 294 }
296 catch (Exception) { } 295 catch (Exception) { }
297 296
298
299 m_connected = false; 297 m_connected = false;
300 298
301 try { m_writer.Close(); } 299 try { m_writer.Close(); }
@@ -308,10 +306,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
308 catch (Exception) { } 306 catch (Exception) { }
309 307
310 } 308 }
311
312 lock (m_connectors) 309 lock (m_connectors)
313 m_connectors.Remove(this); 310 m_connectors.Remove(this);
314
315 } 311 }
316 } 312 }
317 313
@@ -327,25 +323,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
327 323
328 public void Connect() 324 public void Connect()
329 { 325 {
330
331 if (!m_enabled) 326 if (!m_enabled)
332 return; 327 return;
333 328
334 // Delay until next WD cycle if this is too close to the last start attempt 329 // Delay until next WD cycle if this is too close to the last start attempt
335 330 if(_icc_ < ICCD_PERIOD)
336 while (_icc_ < ICCD_PERIOD)
337 return; 331 return;
338 332
339 m_log.DebugFormat("[IRC-Connector-{0}]: Connection request for {1} on {2}:{3}", idn, m_nick, m_server, m_ircChannel); 333 m_log.DebugFormat("[IRC-Connector-{0}]: Connection request for {1} on {2}:{3}", idn, m_nick, m_server, m_ircChannel);
340 334
335 _icc_ = 0;
336
341 lock (msyncConnect) 337 lock (msyncConnect)
342 { 338 {
343
344 _icc_ = 0;
345
346 try 339 try
347 { 340 {
348
349 if (m_connected) return; 341 if (m_connected) return;
350 342
351 m_connected = true; 343 m_connected = true;
@@ -368,11 +360,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
368 m_writer.Flush(); 360 m_writer.Flush();
369 m_writer.WriteLine(m_user); 361 m_writer.WriteLine(m_user);
370 m_writer.Flush(); 362 m_writer.Flush();
371 m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel));
372 m_writer.Flush();
373
374 m_log.InfoFormat("[IRC-Connector-{0}]: {1} has asked to join {2}", idn, m_nick, m_ircChannel);
375
376 } 363 }
377 catch (Exception e) 364 catch (Exception e)
378 { 365 {
@@ -384,11 +371,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
384 // expires. By leaving them as they are, the connection will be retried 371 // expires. By leaving them as they are, the connection will be retried
385 // when the login timeout expires. Which is preferred. 372 // when the login timeout expires. Which is preferred.
386 } 373 }
387
388 } 374 }
389 375
390 return; 376 return;
391
392 } 377 }
393 378
394 // Reconnect is used to force a re-cycle of the IRC connection. Should generally 379 // Reconnect is used to force a re-cycle of the IRC connection. Should generally
@@ -443,7 +428,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
443 public void PrivMsg(string pattern, string from, string region, string msg) 428 public void PrivMsg(string pattern, string from, string region, string msg)
444 { 429 {
445 430
446 // m_log.DebugFormat("[IRC-Connector-{0}] PrivMsg to IRC from {1}: <{2}>", idn, from, 431 // m_log.DebugFormat("[IRC-Connector-{0}] PrivMsg to IRC from {1}: <{2}>", idn, from,
447 // String.Format(pattern, m_ircChannel, from, region, msg)); 432 // String.Format(pattern, m_ircChannel, from, region, msg));
448 433
449 // One message to the IRC server 434 // One message to the IRC server
@@ -521,11 +506,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
521 c.Message = data["msg"]; 506 c.Message = data["msg"];
522 c.Type = ChatTypeEnum.Region; 507 c.Type = ChatTypeEnum.Region;
523 c.Position = CenterOfRegion; 508 c.Position = CenterOfRegion;
524 c.From = data["nick"]; 509 c.From = data["nick"] + "@IRC";
525 c.Sender = null; 510 c.Sender = null;
526 c.SenderUUID = UUID.Zero; 511 c.SenderUUID = UUID.Zero;
527 512
528 // Is message "\001ACTION foo bar\001"? 513 // Is message "\001ACTION foo bar\001"?
529 // Then change to: "/me foo bar" 514 // Then change to: "/me foo bar"
530 515
531 if ((1 == c.Message[0]) && c.Message.Substring(1).StartsWith("ACTION")) 516 if ((1 == c.Message[0]) && c.Message.Substring(1).StartsWith("ACTION"))
@@ -623,8 +608,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
623 string parms = String.Empty; 608 string parms = String.Empty;
624 609
625 // ":" indicates that a prefix is present 610 // ":" indicates that a prefix is present
626 // There are NEVER more than 17 real 611 // There are NEVER more than 17 real
627 // fields. A parameter that starts with 612 // fields. A parameter that starts with
628 // ":" indicates that the remainder of the 613 // ":" indicates that the remainder of the
629 // line is a single parameter value. 614 // line is a single parameter value.
630 615
@@ -659,6 +644,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
659 version = commArgs[2]; 644 version = commArgs[2];
660 usermod = commArgs[3]; 645 usermod = commArgs[3];
661 chanmod = commArgs[4]; 646 chanmod = commArgs[4];
647
648 m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel));
649 m_writer.Flush();
650 m_log.InfoFormat("[IRC-Connector-{0}]: sent request to join {1} ", idn, m_ircChannel);
651
662 break; 652 break;
663 case "005": // Server information 653 case "005": // Server information
664 break; 654 break;
@@ -721,11 +711,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
721 case "PONG": 711 case "PONG":
722 break; 712 break;
723 case "JOIN": 713 case "JOIN":
724 if (m_pending) 714
725 {
726 m_log.InfoFormat("[IRC-Connector-{0}] [{1}] Connected", idn, cmd);
727 m_pending = false;
728 }
729 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms); 715 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
730 eventIrcJoin(pfx, cmd, parms); 716 eventIrcJoin(pfx, cmd, parms);
731 break; 717 break;
@@ -767,7 +753,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
767 if (IrcChannel.StartsWith(":")) 753 if (IrcChannel.StartsWith(":"))
768 IrcChannel = IrcChannel.Substring(1); 754 IrcChannel = IrcChannel.Substring(1);
769 755
770 m_log.DebugFormat("[IRC-Connector-{0}] Event: IRCJoin {1}:{2}", idn, m_server, m_ircChannel); 756 if(IrcChannel == m_ircChannel)
757 {
758 m_log.InfoFormat("[IRC-Connector-{0}] Joined requested channel {1} at {2}", idn, IrcChannel,m_server);
759 m_pending = false;
760 }
761 else
762 m_log.InfoFormat("[IRC-Connector-{0}] Joined unknown channel {1} at {2}", idn, IrcChannel,m_server);
771 BroadcastSim(IrcUser, "/me joins {0}", IrcChannel); 763 BroadcastSim(IrcUser, "/me joins {0}", IrcChannel);
772 } 764 }
773 765
@@ -881,7 +873,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
881 } 873 }
882 874
883 // Being marked connected is not enough to ping. Socket establishment can sometimes take a long 875 // Being marked connected is not enough to ping. Socket establishment can sometimes take a long
884 // time, in which case the watch dog might try to ping the server before the socket has been 876 // time, in which case the watch dog might try to ping the server before the socket has been
885 // set up, with nasty side-effects. 877 // set up, with nasty side-effects.
886 878
887 else if (_pdk_ == 0) 879 else if (_pdk_ == 0)