* ChatModule is now shared between all scenes. (May be buggy.)

afrisby
Adam Frisby 2007-10-19 23:20:57 +00:00
parent 1313544ac7
commit f427433c85
1 changed files with 24 additions and 18 deletions

View File

@ -30,6 +30,7 @@ using System;
using System.IO; using System.IO;
using System.Net.Sockets; using System.Net.Sockets;
using System.Threading; using System.Threading;
using System.Collections.Generic;
using libsecondlife; using libsecondlife;
using OpenSim.Framework.Interfaces; using OpenSim.Framework.Interfaces;
using OpenSim.Framework.Utilities; using OpenSim.Framework.Utilities;
@ -41,7 +42,7 @@ namespace OpenSim.Region.Environment.Modules
{ {
public class ChatModule : IRegionModule, ISimChat public class ChatModule : IRegionModule, ISimChat
{ {
private Scene m_scene; private List<Scene> m_scenes = new List<Scene>();
private LogBase m_log; private LogBase m_log;
private string m_server = null; private string m_server = null;
@ -86,10 +87,12 @@ namespace OpenSim.Region.Environment.Modules
Console.WriteLine("No IRC config information, skipping IRC bridge configuration"); Console.WriteLine("No IRC config information, skipping IRC bridge configuration");
} }
m_scene = scene; if (!m_scenes.Contains(scene))
m_scene.EventManager.OnNewClient += NewClient; {
m_scenes.Add(scene);
m_scene.RegisterModuleInterface<ISimChat>(this); scene.EventManager.OnNewClient += NewClient;
scene.RegisterModuleInterface<ISimChat>(this);
}
} }
public void PostInitialise() public void PostInitialise()
@ -137,7 +140,7 @@ namespace OpenSim.Region.Environment.Modules
public bool IsSharedModule public bool IsSharedModule
{ {
get { return false; } get { return true; }
} }
public void NewClient(IClientAPI client) public void NewClient(IClientAPI client)
@ -167,6 +170,8 @@ namespace OpenSim.Region.Environment.Modules
if (inputLine.Contains(m_channel)) if (inputLine.Contains(m_channel))
{ {
string mess = inputLine.Substring(inputLine.IndexOf(m_channel)); string mess = inputLine.Substring(inputLine.IndexOf(m_channel));
foreach (Scene m_scene in m_scenes)
{
m_scene.Broadcast(delegate(IClientAPI client) m_scene.Broadcast(delegate(IClientAPI client)
{ {
client.SendChatMessage( client.SendChatMessage(
@ -177,6 +182,7 @@ namespace OpenSim.Region.Environment.Modules
} }
} }
} }
}
public void SimChat(Object sender, ChatFromViewerArgs e) public void SimChat(Object sender, ChatFromViewerArgs e)
{ {
@ -187,7 +193,7 @@ namespace OpenSim.Region.Environment.Modules
//TODO: Remove the need for this check //TODO: Remove the need for this check
if (scene == null) if (scene == null)
scene = m_scene; scene = m_scenes[0];
// Filled in since it's easier than rewriting right now. // Filled in since it's easier than rewriting right now.
LLVector3 fromPos = e.Position; LLVector3 fromPos = e.Position;
@ -227,11 +233,11 @@ namespace OpenSim.Region.Environment.Modules
break; 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) if (connected)
{ {
m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + ">: " + m_ircWriter.WriteLine("PRIVMSG " + m_channel + " :" + "<" + fromName + " in " + scene.RegionInfo.RegionName + ">: " +
e.Message); e.Message);
m_ircWriter.Flush(); m_ircWriter.Flush();
} }