From f427433c85608cbe7dc5ec085cbee2742b04d057 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 19 Oct 2007 23:20:57 +0000 Subject: * ChatModule is now shared between all scenes. (May be buggy.) --- OpenSim/Region/Environment/Modules/ChatModule.cs | 42 ++++++++++++++---------- 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'OpenSim/Region/Environment') diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 594d5b4..3b08db3 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -30,6 +30,7 @@ using System; using System.IO; using System.Net.Sockets; using System.Threading; +using System.Collections.Generic; using libsecondlife; using OpenSim.Framework.Interfaces; using OpenSim.Framework.Utilities; @@ -40,8 +41,8 @@ using OpenSim.Region.Environment.Scenes; namespace OpenSim.Region.Environment.Modules { public class ChatModule : IRegionModule, ISimChat - { - private Scene m_scene; + { + private List m_scenes = new List(); private LogBase m_log; private string m_server = null; @@ -84,12 +85,14 @@ namespace OpenSim.Region.Environment.Modules } } catch (Exception e) { Console.WriteLine("No IRC config information, skipping IRC bridge configuration"); + } + + if (!m_scenes.Contains(scene)) + { + m_scenes.Add(scene); + scene.EventManager.OnNewClient += NewClient; + scene.RegisterModuleInterface(this); } - - m_scene = scene; - m_scene.EventManager.OnNewClient += NewClient; - - m_scene.RegisterModuleInterface(this); } public void PostInitialise() @@ -137,7 +140,7 @@ namespace OpenSim.Region.Environment.Modules public bool IsSharedModule { - get { return false; } + get { return true; } } public void NewClient(IClientAPI client) @@ -166,13 +169,16 @@ namespace OpenSim.Region.Environment.Modules Console.WriteLine(inputLine); if (inputLine.Contains(m_channel)) { - string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); - m_scene.Broadcast(delegate(IClientAPI client) - { - client.SendChatMessage( - Helpers.StringToField(mess), 255, pos, "IRC:", - LLUUID.Zero); - }); + string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); + foreach (Scene m_scene in m_scenes) + { + m_scene.Broadcast(delegate(IClientAPI client) + { + client.SendChatMessage( + Helpers.StringToField(mess), 255, pos, "IRC:", + LLUUID.Zero); + }); + } } } } @@ -187,7 +193,7 @@ namespace OpenSim.Region.Environment.Modules //TODO: Remove the need for this check if (scene == null) - scene = m_scene; + scene = m_scenes[0]; // Filled in since it's easier than rewriting right now. LLVector3 fromPos = e.Position; @@ -227,11 +233,11 @@ namespace OpenSim.Region.Environment.Modules break; } - m_log.Verbose("CHAT", fromName + " (" + e.Channel + ") " + typeName + ": " + e.Message); + m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message); if (connected) { - m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + + m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " + e.Message); m_ircWriter.Flush(); } -- cgit v1.1