diff options
author | Adam Frisby | 2007-10-19 23:20:57 +0000 |
---|---|---|
committer | Adam Frisby | 2007-10-19 23:20:57 +0000 |
commit | f427433c85608cbe7dc5ec085cbee2742b04d057 (patch) | |
tree | 7d01df1d83f4988de7a32af0a8a1674edae421c8 | |
parent | * Major structural change: Begun converting Events to use (caller, args) synt... (diff) | |
download | opensim-SC_OLD-f427433c85608cbe7dc5ec085cbee2742b04d057.zip opensim-SC_OLD-f427433c85608cbe7dc5ec085cbee2742b04d057.tar.gz opensim-SC_OLD-f427433c85608cbe7dc5ec085cbee2742b04d057.tar.bz2 opensim-SC_OLD-f427433c85608cbe7dc5ec085cbee2742b04d057.tar.xz |
* ChatModule is now shared between all scenes. (May be buggy.)
-rw-r--r-- | OpenSim/Region/Environment/Modules/ChatModule.cs | 42 |
1 files changed, 24 insertions, 18 deletions
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; | |||
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Net.Sockets; | 31 | using System.Net.Sockets; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using System.Collections.Generic; | ||
33 | using libsecondlife; | 34 | using libsecondlife; |
34 | using OpenSim.Framework.Interfaces; | 35 | using OpenSim.Framework.Interfaces; |
35 | using OpenSim.Framework.Utilities; | 36 | using OpenSim.Framework.Utilities; |
@@ -40,8 +41,8 @@ using OpenSim.Region.Environment.Scenes; | |||
40 | namespace OpenSim.Region.Environment.Modules | 41 | namespace OpenSim.Region.Environment.Modules |
41 | { | 42 | { |
42 | public class ChatModule : IRegionModule, ISimChat | 43 | public class ChatModule : IRegionModule, ISimChat |
43 | { | 44 | { |
44 | private Scene m_scene; | 45 | private List<Scene> m_scenes = new List<Scene>(); |
45 | private LogBase m_log; | 46 | private LogBase m_log; |
46 | 47 | ||
47 | private string m_server = null; | 48 | private string m_server = null; |
@@ -84,12 +85,14 @@ namespace OpenSim.Region.Environment.Modules | |||
84 | } | 85 | } |
85 | } catch (Exception e) { | 86 | } catch (Exception e) { |
86 | Console.WriteLine("No IRC config information, skipping IRC bridge configuration"); | 87 | Console.WriteLine("No IRC config information, skipping IRC bridge configuration"); |
88 | } | ||
89 | |||
90 | if (!m_scenes.Contains(scene)) | ||
91 | { | ||
92 | m_scenes.Add(scene); | ||
93 | scene.EventManager.OnNewClient += NewClient; | ||
94 | scene.RegisterModuleInterface<ISimChat>(this); | ||
87 | } | 95 | } |
88 | |||
89 | m_scene = scene; | ||
90 | m_scene.EventManager.OnNewClient += NewClient; | ||
91 | |||
92 | m_scene.RegisterModuleInterface<ISimChat>(this); | ||
93 | } | 96 | } |
94 | 97 | ||
95 | public void PostInitialise() | 98 | public void PostInitialise() |
@@ -137,7 +140,7 @@ namespace OpenSim.Region.Environment.Modules | |||
137 | 140 | ||
138 | public bool IsSharedModule | 141 | public bool IsSharedModule |
139 | { | 142 | { |
140 | get { return false; } | 143 | get { return true; } |
141 | } | 144 | } |
142 | 145 | ||
143 | public void NewClient(IClientAPI client) | 146 | public void NewClient(IClientAPI client) |
@@ -166,13 +169,16 @@ namespace OpenSim.Region.Environment.Modules | |||
166 | Console.WriteLine(inputLine); | 169 | Console.WriteLine(inputLine); |
167 | if (inputLine.Contains(m_channel)) | 170 | if (inputLine.Contains(m_channel)) |
168 | { | 171 | { |
169 | string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); | 172 | string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); |
170 | m_scene.Broadcast(delegate(IClientAPI client) | 173 | foreach (Scene m_scene in m_scenes) |
171 | { | 174 | { |
172 | client.SendChatMessage( | 175 | m_scene.Broadcast(delegate(IClientAPI client) |
173 | Helpers.StringToField(mess), 255, pos, "IRC:", | 176 | { |
174 | LLUUID.Zero); | 177 | client.SendChatMessage( |
175 | }); | 178 | Helpers.StringToField(mess), 255, pos, "IRC:", |
179 | LLUUID.Zero); | ||
180 | }); | ||
181 | } | ||
176 | } | 182 | } |
177 | } | 183 | } |
178 | } | 184 | } |
@@ -187,7 +193,7 @@ namespace OpenSim.Region.Environment.Modules | |||
187 | 193 | ||
188 | //TODO: Remove the need for this check | 194 | //TODO: Remove the need for this check |
189 | if (scene == null) | 195 | if (scene == null) |
190 | scene = m_scene; | 196 | scene = m_scenes[0]; |
191 | 197 | ||
192 | // Filled in since it's easier than rewriting right now. | 198 | // Filled in since it's easier than rewriting right now. |
193 | LLVector3 fromPos = e.Position; | 199 | LLVector3 fromPos = e.Position; |
@@ -227,11 +233,11 @@ namespace OpenSim.Region.Environment.Modules | |||
227 | break; | 233 | break; |
228 | } | 234 | } |
229 | 235 | ||
230 | m_log.Verbose("CHAT", fromName + " (" + e.Channel + ") " + typeName + ": " + e.Message); | 236 | m_log.Verbose("CHAT", fromName + " (" + e.Channel + " @ " + scene.RegionInfo.RegionName + ") " + typeName + ": " + e.Message); |
231 | 237 | ||
232 | if (connected) | 238 | if (connected) |
233 | { | 239 | { |
234 | m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + | 240 | m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " + |
235 | e.Message); | 241 | e.Message); |
236 | m_ircWriter.Flush(); | 242 | m_ircWriter.Flush(); |
237 | } | 243 | } |