29 using System.Collections;
30 using System.Collections.Generic;
32 using System.Reflection;
37 using OpenSim.Framework;
38 using OpenSim.Framework.Servers;
39 using OpenSim.Region.Framework.Interfaces;
40 using OpenSim.Region.Framework.Scenes;
44 [Extension(Path =
"/OpenSim/RegionModules", NodeName =
"RegionModule", Id =
"IRCBridgeModule")]
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 internal static bool Enabled =
false;
50 internal static IConfig m_config = null;
52 internal static List<ChannelState> m_channels =
new List<ChannelState>();
53 internal static List<RegionState> m_regions =
new List<RegionState>();
55 internal static string m_password = String.Empty;
56 internal RegionState m_region = null;
58 #region INonSharedRegionModule Members
60 public Type ReplaceableInterface
67 get {
return "IRCBridgeModule"; }
72 m_config = config.Configs[
"IRC"];
79 if (!m_config.GetBoolean(
"enabled",
false))
86 if (config.Configs[
"RemoteAdmin"] != null)
88 m_password = config.Configs[
"RemoteAdmin"].GetString(
"access_password", m_password);
93 m_log.InfoFormat(
"[IRC-Bridge]: Module is enabled");
102 m_log.InfoFormat(
"[IRC-Bridge] Connecting region {0}", scene.RegionInfo.RegionName);
104 if (!
String.IsNullOrEmpty(m_password))
107 m_region =
new RegionState(scene, m_config);
109 m_regions.Add(m_region);
114 m_log.WarnFormat(
"[IRC-Bridge] Region {0} not connected to IRC : {1}", scene.RegionInfo.RegionName, e.Message);
134 if (m_region == null)
137 if (!
String.IsNullOrEmpty(m_password))
142 if (m_regions.Contains(m_region))
144 lock (m_regions) m_regions.Remove(m_region);
155 m_log.Debug(
"[IRC-Bridge]: XML RPC Admin Entry");
157 XmlRpcResponse response =
new XmlRpcResponse();
158 Hashtable responseData =
new Hashtable();
162 Hashtable requestData = (Hashtable)request.Params[0];
164 string region =
String.Empty;
166 if (m_password !=
String.Empty)
168 if (!requestData.ContainsKey(
"password"))
169 throw new Exception(
"Invalid request");
170 if ((
string)requestData[
"password"] != m_password)
171 throw new Exception(
"Invalid request");
174 if (!requestData.ContainsKey(
"region"))
175 throw new Exception(
"No region name specified");
176 region = (string)requestData[
"region"];
178 foreach (RegionState rs
in m_regions)
180 if (rs.Region == region)
182 responseData[
"server"] = rs.cs.Server;
183 responseData[
"port"] = (int)rs.cs.Port;
184 responseData[
"user"] = rs.cs.User;
185 responseData[
"channel"] = rs.cs.IrcChannel;
186 responseData[
"enabled"] = rs.cs.irc.Enabled;
187 responseData[
"connected"] = rs.cs.irc.Connected;
188 responseData[
"nickname"] = rs.cs.irc.Nick;
194 if (!found)
throw new Exception(
String.Format(
"Region <{0}> not found", region));
196 responseData[
"success"] =
true;
200 m_log.ErrorFormat(
"[IRC-Bridge] XML RPC Admin request failed : {0}", e.Message);
202 responseData[
"success"] =
"false";
203 responseData[
"error"] = e.Message;
207 response.Value = responseData;
210 m_log.Debug(
"[IRC-Bridge]: XML RPC Admin Exit");
static XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request, IPEndPoint remoteClient)
void RemoveRegion(Scene scene)
This is called whenever a Scene is removed. For shared modules, this can happen several times...
void AddRegion(Scene scene)
This is called whenever a Scene is added. For shared modules, this can happen several times...
static BaseHttpServer Instance
Set the main HTTP server instance.
void Initialise(IConfigSource config)
This is called to initialize the region module. For shared modules, this is called exactly once...
void RegionLoaded(Scene scene)
This will be called once for every scene loaded. In a shared module this will be multiple times in on...
void Close()
This is the inverse to Initialise. After a Close(), this instance won't be usable anymore...