* 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;
@ -40,8 +41,8 @@ using OpenSim.Region.Environment.Scenes;
namespace OpenSim.Region.Environment.Modules 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;
@ -84,12 +85,14 @@ namespace OpenSim.Region.Environment.Modules
} }
} catch (Exception e) { } catch (Exception e) {
Console.WriteLine("No IRC config information, skipping IRC bridge configuration"); 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<ISimChat>(this);
} }
m_scene = scene;
m_scene.EventManager.OnNewClient += NewClient;
m_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)
@ -166,13 +169,16 @@ namespace OpenSim.Region.Environment.Modules
Console.WriteLine(inputLine); Console.WriteLine(inputLine);
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));
m_scene.Broadcast(delegate(IClientAPI client) foreach (Scene m_scene in m_scenes)
{ {
client.SendChatMessage( m_scene.Broadcast(delegate(IClientAPI client)
Helpers.StringToField(mess), 255, pos, "IRC:", {
LLUUID.Zero); 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 //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();
} }