aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Concierge
diff options
context:
space:
mode:
authorDr Scofield2008-10-03 14:53:11 +0000
committerDr Scofield2008-10-03 14:53:11 +0000
commit5c0a0bc2e0951745fd52f5c01f2ee2c0aee49a3a (patch)
tree529c2c8e3ea8f1193f2495f905e542ff1462adb6 /OpenSim/Region/Environment/Modules/Avatar/Concierge
parent* minor: remove warnings (the code cleaners strike again) (diff)
downloadopensim-SC-5c0a0bc2e0951745fd52f5c01f2ee2c0aee49a3a.zip
opensim-SC-5c0a0bc2e0951745fd52f5c01f2ee2c0aee49a3a.tar.gz
opensim-SC-5c0a0bc2e0951745fd52f5c01f2ee2c0aee49a3a.tar.bz2
opensim-SC-5c0a0bc2e0951745fd52f5c01f2ee2c0aee49a3a.tar.xz
This changeset changes the way chat from client is routed:
old way: each region module interested in chat from client had to - subscribe to scene.EventManager.OnNewClient - then in its OnNewClient delegate it would subscribe to client.OnChatFromViewer to capture chat messages coming new way: ChatModule is the only region module that uses the "old way" approach but is now forwarding all client chat via scene.EventManager.OnChatFromClient - each region module interested in chat from client now only subscribes to scene.EventManager.OnChatFromClient this not only simplifies code, but also allows us to substitute ChatModule with derived classes (ConciergeModule is going to be one example). Also, this changeset changes ChatFromViewer to ChatFromClient as it doesn't necessarily have to be a viewer that is a chat source. i've taken great care to only comment out those OnNewClient delegates that were only used for getting at the client chat --- hope it's not breaking anything.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Concierge')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs66
1 files changed, 40 insertions, 26 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs
index 0c0f553..d9730dd 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
50 private int _conciergeChannel = 42; 50 private int _conciergeChannel = 42;
51 private List<Scene> _scenes = new List<Scene>(); 51 private List<Scene> _scenes = new List<Scene>();
52 private IConfig _config; 52 private IConfig _config;
53 private string _whoami = null; 53 private string _whoami = "conferencier";
54 54
55 internal object _syncy = new object(); 55 internal object _syncy = new object();
56 56
@@ -78,8 +78,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
78 return; 78 return;
79 } 79 }
80 80
81 _conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", _conciergeChannel); 81 if (_config != null)
82 _whoami = _config.GetString("concierge_name", "conferencier"); 82 {
83 _conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", _conciergeChannel);
84 _whoami = _config.GetString("whoami", "conferencier");
85 }
86 _log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", _whoami);
83 87
84 lock (_syncy) 88 lock (_syncy)
85 { 89 {
@@ -88,8 +92,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
88 _scenes.Add(scene); 92 _scenes.Add(scene);
89 // subscribe to NewClient events 93 // subscribe to NewClient events
90 scene.EventManager.OnNewClient += OnNewClient; 94 scene.EventManager.OnNewClient += OnNewClient;
95 scene.EventManager.OnNewClient += OnNewClient;
91 96
92 // subscribe to *Chat events 97 // subscribe to *Chat events and FilterChat* events
93 scene.EventManager.OnChatFromWorld += OnSimChat; 98 scene.EventManager.OnChatFromWorld += OnSimChat;
94 scene.EventManager.OnChatBroadcast += OnSimBroadcast; 99 scene.EventManager.OnChatBroadcast += OnSimBroadcast;
95 100
@@ -124,18 +129,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
124 #region ISimChat Members 129 #region ISimChat Members
125 public void OnSimBroadcast(Object sender, OSChatMessage c) 130 public void OnSimBroadcast(Object sender, OSChatMessage c)
126 { 131 {
127 if (_conciergeChannel == c.Channel) 132 // log to buffer?
128 {
129 // concierge request: interpret
130 return;
131 }
132
133 if (0 == c.Channel || DEBUG_CHANNEL == c.Channel)
134 {
135 // log as avatar/prim chat
136 return;
137 }
138
139 return; 133 return;
140 } 134 }
141 135
@@ -149,6 +143,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
149 143
150 if (0 == c.Channel || DEBUG_CHANNEL == c.Channel) 144 if (0 == c.Channel || DEBUG_CHANNEL == c.Channel)
151 { 145 {
146 // if (_amplify)
147 // {
148
149 // }
150
152 // log as avatar/prim chat 151 // log as avatar/prim chat
153 return; 152 return;
154 } 153 }
@@ -161,14 +160,20 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
161 160
162 public void OnNewClient(IClientAPI client) 161 public void OnNewClient(IClientAPI client)
163 { 162 {
164 try 163 client.OnLogout += OnClientLoggedOut;
165 { 164 client.OnConnectionClosed += OnClientLoggedOut;
166 client.OnChatFromViewer += OnSimChat; 165
167 } 166 _log.DebugFormat("[Concierge] {0} logs on to {1}", client.Name, client.Scene.RegionInfo.RegionName);
168 catch (Exception ex) 167 AnnounceToAgentsRegion(client, String.Format("{0} logs on to {1}", client.Name, client.Scene.RegionInfo.RegionName));
169 { 168 }
170 _log.Error("[Concierge]: NewClient exception trap:" + ex.ToString()); 169
171 } 170 public void OnClientLoggedOut(IClientAPI client)
171 {
172 client.OnLogout -= OnClientLoggedOut;
173 client.OnConnectionClosed -= OnClientLoggedOut;
174
175 _log.DebugFormat("[Concierge] {0} logs off from {1}", client.Name, client.Scene.RegionInfo.RegionName);
176 AnnounceToAgentsRegion(client, String.Format("{0} logs off from {1}", client.Name, client.Scene.RegionInfo.RegionName));
172 } 177 }
173 178
174 179
@@ -188,13 +193,22 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
188 193
189 public void ClientLoggedOut(IClientAPI client) 194 public void ClientLoggedOut(IClientAPI client)
190 { 195 {
191 string clientName = String.Format("{0} {1}", client.FirstName, client.LastName); 196 _log.DebugFormat("[Concierge] {0} logs out of {1}", client.Name, client.Scene.RegionInfo.RegionName);
192 _log.DebugFormat("[CONCIERGE] {0} logging off.", clientName); 197 AnnounceToAgentsRegion(client, String.Format("{0} logs out of {1}", client.Name, client.Scene.RegionInfo.RegionName));
193 } 198 }
194 199
195 200
196 static private Vector3 posOfGod = new Vector3(128, 128, 9999); 201 static private Vector3 posOfGod = new Vector3(128, 128, 9999);
197 202
203 protected void AnnounceToAgentsRegion(IClientAPI client, string msg)
204 {
205 ScenePresence agent = null;
206 if ((client.Scene is Scene) && (client.Scene as Scene).TryGetAvatar(client.AgentId, out agent))
207 AnnounceToAgentsRegion(agent, msg);
208 else
209 _log.DebugFormat("[Concierge] could not find an agent for client {0}", client.Name);
210 }
211
198 protected void AnnounceToAgentsRegion(ScenePresence scenePresence, string msg) 212 protected void AnnounceToAgentsRegion(ScenePresence scenePresence, string msg)
199 { 213 {
200 OSChatMessage c = new OSChatMessage(); 214 OSChatMessage c = new OSChatMessage();