aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs60
1 files changed, 46 insertions, 14 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
index 9a68749..ab141eb 100644
--- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -24,6 +24,7 @@
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27using System;
27using System.Collections.Generic; 28using System.Collections.Generic;
28using System.Reflection; 29using System.Reflection;
29using log4net; 30using log4net;
@@ -36,9 +37,10 @@ using OpenSim.Region.Framework.Scenes;
36 37
37namespace OpenSim.Region.CoreModules.Avatar.InstantMessage 38namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
38{ 39{
39 public class InstantMessageModule : IRegionModule 40 public class InstantMessageModule : ISharedRegionModule
40 { 41 {
41 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(
43 MethodBase.GetCurrentMethod().DeclaringType);
42 44
43 /// <value> 45 /// <value>
44 /// Is this module enabled? 46 /// Is this module enabled?
@@ -51,7 +53,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
51 53
52 private IMessageTransferModule m_TransferModule = null; 54 private IMessageTransferModule m_TransferModule = null;
53 55
54 public void Initialise(Scene scene, IConfigSource config) 56 public void Initialise(IConfigSource config)
55 { 57 {
56 if (config.Configs["Messaging"] != null) 58 if (config.Configs["Messaging"] != null)
57 { 59 {
@@ -62,6 +64,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
62 } 64 }
63 65
64 m_enabled = true; 66 m_enabled = true;
67 }
68
69 public void AddRegion(Scene scene)
70 {
71 if (!m_enabled)
72 return;
65 73
66 lock (m_scenes) 74 lock (m_scenes)
67 { 75 {
@@ -74,6 +82,39 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
74 } 82 }
75 } 83 }
76 84
85 public void RegionLoaded(Scene scene)
86 {
87 if (!m_enabled)
88 return;
89
90 if (m_TransferModule == null)
91 {
92 m_TransferModule =
93 scene.RequestModuleInterface<IMessageTransferModule>();
94
95 if (m_TransferModule == null)
96 {
97 m_log.Error("[INSTANT MESSAGE]: No message transfer module, IM will not work!");
98 scene.EventManager.OnClientConnect -= OnClientConnect;
99 scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
100
101 m_scenes.Clear();
102 m_enabled = false;
103 }
104 }
105 }
106
107 public void RemoveRegion(Scene scene)
108 {
109 if (!m_enabled)
110 return;
111
112 lock (m_scenes)
113 {
114 m_scenes.Remove(scene);
115 }
116 }
117
77 void OnClientConnect(IClientCore client) 118 void OnClientConnect(IClientCore client)
78 { 119 {
79 IClientIM clientIM; 120 IClientIM clientIM;
@@ -85,15 +126,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
85 126
86 public void PostInitialise() 127 public void PostInitialise()
87 { 128 {
88 if (!m_enabled)
89 return;
90
91 m_TransferModule =
92 m_scenes[0].RequestModuleInterface<IMessageTransferModule>();
93
94 if (m_TransferModule == null)
95 m_log.Error("[INSTANT MESSAGE]: No message transfer module, "+
96 "IM will not work!");
97 } 129 }
98 130
99 public void Close() 131 public void Close()
@@ -105,9 +137,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
105 get { return "InstantMessageModule"; } 137 get { return "InstantMessageModule"; }
106 } 138 }
107 139
108 public bool IsSharedModule 140 public Type ReplaceableInterface
109 { 141 {
110 get { return true; } 142 get { return null; }
111 } 143 }
112 144
113 #endregion 145 #endregion