aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs82
1 files changed, 18 insertions, 64 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs
index 47d3265..49c4a06 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/IRCBridgeModule.cs
@@ -49,11 +49,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
49 internal static bool enabled = false; 49 internal static bool enabled = false;
50 internal static IConfig m_config = null; 50 internal static IConfig m_config = null;
51 51
52 internal static List<RegionState> m_regions = new List<RegionState>();
53 internal static List<ChannelState> m_channels = new List<ChannelState>(); 52 internal static List<ChannelState> m_channels = new List<ChannelState>();
53 internal static List<RegionState> m_regions = new List<RegionState>();
54 54
55 internal static string password = String.Empty; 55 internal static string password = String.Empty;
56 56
57 internal RegionState region = null;
58
57 #region IRegionModule Members 59 #region IRegionModule Members
58 60
59 public string Name 61 public string Name
@@ -63,7 +65,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
63 65
64 public bool IsSharedModule 66 public bool IsSharedModule
65 { 67 {
66 get { return true; } 68 get { return false; }
67 } 69 }
68 70
69 public void Initialise(Scene scene, IConfigSource config) 71 public void Initialise(Scene scene, IConfigSource config)
@@ -110,13 +112,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
110 // Iff the IRC bridge is enabled, then each new region may be 112 // Iff the IRC bridge is enabled, then each new region may be
111 // connected to IRC. But it should NOT be obligatory (and it 113 // connected to IRC. But it should NOT be obligatory (and it
112 // is not). 114 // is not).
115 // We have to do ALL of the startup here because PostInitialize
116 // is not called when a region gets created in-flight from the
117 // command line.
113 118
114 if (enabled) 119 if (enabled)
115 { 120 {
116 try 121 try
117 { 122 {
118 m_log.InfoFormat("[IRC-Bridge] Connecting region {0}", scene.RegionInfo.RegionName); 123 m_log.InfoFormat("[IRC-Bridge] Connecting region {0}", scene.RegionInfo.RegionName);
119 m_regions.Add(new RegionState(scene, m_config)); 124 region = new RegionState(scene, m_config);
125 lock(m_regions) m_regions.Add(region);
126 region.Open();
120 } 127 }
121 catch (Exception e) 128 catch (Exception e)
122 { 129 {
@@ -131,37 +138,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
131 138
132 } 139 }
133 140
134 // Called after all region modules have been loaded. 141 // This module can be called in-flight in which case PostInitialize
135 // Iff the IRC bridge is enabled, then start all of the 142 // is not called following Initialize. So no use is made of this
136 // configured channels. The set of channels is a side 143 // call.
137 // effect of RegionState creation.
138 144
139 public void PostInitialise() 145 public void PostInitialise()
140 { 146 {
141 147
142 if (!enabled)
143 return;
144
145 foreach (RegionState region in m_regions)
146 {
147 m_log.InfoFormat("[IRC-Bridge] Opening connection for {0}:{1} on IRC server {2}:{3}",
148 region.Region, region.cs.BaseNickname, region.cs.Server, region.cs.IrcChannel);
149 try
150 {
151 region.Open();
152 }
153 catch (Exception e)
154 {
155 m_log.ErrorFormat("[IRC-Bridge] Open failed for {0}:{1} on IRC server {2}:{3} : {4}",
156 region.Region, region.cs.BaseNickname, region.cs.Server, region.cs.IrcChannel,
157 e.Message);
158 }
159 }
160
161 } 148 }
162 149
163 // Called immediately before the region module is unloaded. Close all 150 // Called immediately before the region module is unloaded. Cleanup
164 // associated channels. 151 // the region.
165 152
166 public void Close() 153 public void Close()
167 { 154 {
@@ -169,47 +156,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
169 if (!enabled) 156 if (!enabled)
170 return; 157 return;
171 158
172 // Stop each of the region sessions 159 region.Close();
173 160 lock(m_regions) m_regions.Remove(region);
174 foreach (RegionState region in m_regions)
175 {
176 m_log.InfoFormat("[IRC-Bridge] Closing connection for {0}:{1} on IRC server {2}:{3}",
177 region.Region, region.cs.BaseNickname, region.cs.Server, region.cs.IrcChannel);
178 try
179 {
180 region.Close();
181 }
182 catch (Exception e)
183 {
184 m_log.ErrorFormat("[IRC-Bridge] Close failed for {0}:{1} on IRC server {2}:{3} : {4}",
185 region.Region, region.cs.BaseNickname, region.cs.Server, region.cs.IrcChannel,
186 e.Message);
187 }
188 }
189
190 // Perform final cleanup of the channels (they now have no active clients)
191
192 foreach (ChannelState channel in m_channels)
193 {
194 m_log.InfoFormat("[IRC-Bridge] Closing connection for {0} on IRC server {1}:{2}",
195 channel.BaseNickname, channel.Server, channel.IrcChannel);
196 try
197 {
198 channel.Close();
199 }
200 catch (Exception e)
201 {
202 m_log.ErrorFormat("[IRC-Bridge] Close failed for {0} on IRC server {1}:{2} : {3}",
203 channel.BaseNickname, channel.Server, channel.IrcChannel,
204 e.Message);
205 }
206 }
207 161
208 } 162 }
209 163
210 #endregion 164 #endregion
211 165
212 public XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request) 166 public static XmlRpcResponse XmlRpcAdminMethod(XmlRpcRequest request)
213 { 167 {
214 168
215 m_log.Info("[IRC-Bridge]: XML RPC Admin Entry"); 169 m_log.Info("[IRC-Bridge]: XML RPC Admin Entry");