diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs | 85 |
1 files changed, 54 insertions, 31 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs index 6265698..213ae96 100644 --- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs +++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChannelState.cs | |||
@@ -256,20 +256,25 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
256 | // values that, while independent of the IRC connetion, do still distinguish | 256 | // values that, while independent of the IRC connetion, do still distinguish |
257 | // this region's behavior. | 257 | // this region's behavior. |
258 | 258 | ||
259 | foreach (ChannelState xcs in IRCBridgeModule.m_channels) | 259 | lock (IRCBridgeModule.m_channels) |
260 | { | 260 | { |
261 | if (cs.IsAPerfectMatchFor(xcs)) | 261 | |
262 | { | 262 | foreach (ChannelState xcs in IRCBridgeModule.m_channels) |
263 | m_log.DebugFormat("[IRC-Channel-{0}] Channel state matched", cs.idn); | ||
264 | cs = xcs; | ||
265 | break; | ||
266 | } | ||
267 | if (cs.IsAConnectionMatchFor(xcs)) | ||
268 | { | 263 | { |
269 | m_log.DebugFormat("[IRC-Channel-{0}] Channel matched", cs.idn); | 264 | if (cs.IsAPerfectMatchFor(xcs)) |
270 | cs.irc = xcs.irc; | 265 | { |
271 | break; | 266 | m_log.DebugFormat("[IRC-Channel-{0}] Channel state matched", cs.idn); |
267 | cs = xcs; | ||
268 | break; | ||
269 | } | ||
270 | if (cs.IsAConnectionMatchFor(xcs)) | ||
271 | { | ||
272 | m_log.DebugFormat("[IRC-Channel-{0}] Channel matched", cs.idn); | ||
273 | cs.irc = xcs.irc; | ||
274 | break; | ||
275 | } | ||
272 | } | 276 | } |
277 | |||
273 | } | 278 | } |
274 | 279 | ||
275 | // No entry was found, so this is going to be a new entry. | 280 | // No entry was found, so this is going to be a new entry. |
@@ -281,6 +286,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
281 | 286 | ||
282 | if ((cs.irc = new IRCConnector(cs)) != null) | 287 | if ((cs.irc = new IRCConnector(cs)) != null) |
283 | { | 288 | { |
289 | |||
284 | IRCBridgeModule.m_channels.Add(cs); | 290 | IRCBridgeModule.m_channels.Add(cs); |
285 | 291 | ||
286 | m_log.InfoFormat("[IRC-Channel-{0}] New channel initialized for {1}, nick: {2}, commands {3}, private channels {4}", | 292 | m_log.InfoFormat("[IRC-Channel-{0}] New channel initialized for {1}, nick: {2}, commands {3}, private channels {4}", |
@@ -302,11 +308,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
302 | cs.idn, rs.Region, cs.IrcChannel, cs.Server, cs.Port); | 308 | cs.idn, rs.Region, cs.IrcChannel, cs.Server, cs.Port); |
303 | } | 309 | } |
304 | 310 | ||
305 | m_log.InfoFormat("[IRC-Channel-{0}] Region {1} connected to channel {2} on server {3}:{4}", | 311 | m_log.InfoFormat("[IRC-Channel-{0}] Region {1} associated with channel {2} on server {3}:{4}", |
306 | cs.idn, rs.Region, cs.IrcChannel, cs.Server, cs.Port); | 312 | cs.idn, rs.Region, cs.IrcChannel, cs.Server, cs.Port); |
307 | 313 | ||
308 | // We're finally ready to commit ourselves | 314 | // We're finally ready to commit ourselves |
309 | 315 | ||
316 | |||
310 | return cs; | 317 | return cs; |
311 | 318 | ||
312 | } | 319 | } |
@@ -443,6 +450,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
443 | // Repeatedly scan the string until all possible | 450 | // Repeatedly scan the string until all possible |
444 | // substitutions have been performed. | 451 | // substitutions have been performed. |
445 | 452 | ||
453 | // m_log.DebugFormat("[IRC-Channel] Parse[1]: {0}", result); | ||
454 | |||
446 | while (arg.IsMatch(result)) | 455 | while (arg.IsMatch(result)) |
447 | { | 456 | { |
448 | 457 | ||
@@ -476,28 +485,26 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
476 | result = result.Replace(vvar, rs.config.GetString(var,var)); | 485 | result = result.Replace(vvar, rs.config.GetString(var,var)); |
477 | break; | 486 | break; |
478 | } | 487 | } |
488 | // m_log.DebugFormat("[IRC-Channel] Parse[2]: {0}", result); | ||
479 | } | 489 | } |
480 | 490 | ||
491 | // m_log.DebugFormat("[IRC-Channel] Parse[3]: {0}", result); | ||
481 | return result; | 492 | return result; |
482 | 493 | ||
483 | } | 494 | } |
484 | 495 | ||
485 | public void Close() | 496 | public void Close() |
486 | { | 497 | { |
487 | 498 | m_log.InfoFormat("[IRC-Channel-{0}] Closing channel <{1}> to server <{2}:{3}>", | |
488 | m_log.InfoFormat("[IRC-Channel-{0}] Closing channel <{1} to server <{2}:{3}>", | ||
489 | idn, IrcChannel, Server, Port); | 499 | idn, IrcChannel, Server, Port); |
490 | |||
491 | m_log.InfoFormat("[IRC-Channel-{0}] There are {1} active clients", | 500 | m_log.InfoFormat("[IRC-Channel-{0}] There are {1} active clients", |
492 | idn, clientregions.Count); | 501 | idn, clientregions.Count); |
493 | |||
494 | irc.Close(); | 502 | irc.Close(); |
495 | |||
496 | } | 503 | } |
497 | 504 | ||
498 | public void Open() | 505 | public void Open() |
499 | { | 506 | { |
500 | m_log.InfoFormat("[IRC-Channel-{0}] Opening channel <{1} to server <{2}:{3}>", | 507 | m_log.InfoFormat("[IRC-Channel-{0}] Opening channel <{1}> to server <{2}:{3}>", |
501 | idn, IrcChannel, Server, Port); | 508 | idn, IrcChannel, Server, Port); |
502 | 509 | ||
503 | irc.Open(); | 510 | irc.Open(); |
@@ -514,16 +521,30 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
514 | Open(); | 521 | Open(); |
515 | } | 522 | } |
516 | 523 | ||
524 | // Close is called to ensure that the IRC session is terminated if this is the | ||
525 | // only client. | ||
526 | |||
517 | public void Close(RegionState rs) | 527 | public void Close(RegionState rs) |
518 | { | 528 | { |
519 | RemoveRegion(rs); | 529 | RemoveRegion(rs); |
530 | lock (IRCBridgeModule.m_channels) | ||
531 | { | ||
532 | if (clientregions.Count == 0) | ||
533 | { | ||
534 | Close(); | ||
535 | IRCBridgeModule.m_channels.Remove(this); | ||
536 | m_log.InfoFormat("[IRC-Channel-{0}] Region {1} is last user of channel <{2}> to server <{3}:{4}>", | ||
537 | idn, rs.Region, IrcChannel, Server, Port); | ||
538 | m_log.InfoFormat("[IRC-Channel-{0}] Removed", idn); | ||
539 | } | ||
540 | } | ||
520 | } | 541 | } |
521 | 542 | ||
522 | // Add a client region to this channel if it is not already known | 543 | // Add a client region to this channel if it is not already known |
523 | 544 | ||
524 | public void AddRegion(RegionState rs) | 545 | public void AddRegion(RegionState rs) |
525 | { | 546 | { |
526 | m_log.InfoFormat("[IRC-Channel-{0}] Adding region {1} to channel <{2} to server <{3}:{4}>", | 547 | m_log.InfoFormat("[IRC-Channel-{0}] Adding region {1} to channel <{2}> to server <{3}:{4}>", |
527 | idn, rs.Region, IrcChannel, Server, Port); | 548 | idn, rs.Region, IrcChannel, Server, Port); |
528 | if (!clientregions.Contains(rs)) | 549 | if (!clientregions.Contains(rs)) |
529 | { | 550 | { |
@@ -568,28 +589,30 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat | |||
568 | // Note that this code is responsible for completing some of the | 589 | // Note that this code is responsible for completing some of the |
569 | // settings for the inbound OSChatMessage | 590 | // settings for the inbound OSChatMessage |
570 | 591 | ||
571 | foreach (ChannelState cs in IRCBridgeModule.m_channels) | 592 | lock (IRCBridgeModule.m_channels) |
572 | { | 593 | { |
573 | if ( p_irc == cs.irc) | 594 | foreach (ChannelState cs in IRCBridgeModule.m_channels) |
574 | { | 595 | { |
596 | if ( p_irc == cs.irc) | ||
597 | { | ||
575 | 598 | ||
576 | // This non-IRC differentiator moved to here | 599 | // This non-IRC differentiator moved to here |
577 | 600 | ||
578 | if (cmsg && !cs.ClientReporting) | 601 | if (cmsg && !cs.ClientReporting) |
579 | continue; | 602 | continue; |
580 | 603 | ||
581 | // This non-IRC differentiator moved to here | 604 | // This non-IRC differentiator moved to here |
582 | 605 | ||
583 | c.Channel = (cs.RelayPrivateChannels ? cs.RelayChannel : 0); | 606 | c.Channel = (cs.RelayPrivateChannels ? cs.RelayChannel : 0); |
584 | 607 | ||
585 | foreach (RegionState region in cs.clientregions) | 608 | foreach (RegionState region in cs.clientregions) |
586 | { | 609 | { |
587 | region.OSChat(cs.irc, c); | 610 | region.OSChat(cs.irc, c); |
588 | } | 611 | } |
589 | 612 | ||
613 | } | ||
590 | } | 614 | } |
591 | } | 615 | } |
592 | |||
593 | } | 616 | } |
594 | catch (Exception ex) | 617 | catch (Exception ex) |
595 | { | 618 | { |