aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDr Scofield2008-09-30 16:14:47 +0000
committerDr Scofield2008-09-30 16:14:47 +0000
commita57533b6d76d2c19cf53f16dc76f603d2fdb571a (patch)
tree2f639acff51d8cfbf208e0cfe2f36e1c456e1ab8
parent- a couple of minor code cleanups in RestInventoryServices (diff)
downloadopensim-SC-a57533b6d76d2c19cf53f16dc76f603d2fdb571a.zip
opensim-SC-a57533b6d76d2c19cf53f16dc76f603d2fdb571a.tar.gz
opensim-SC-a57533b6d76d2c19cf53f16dc76f603d2fdb571a.tar.bz2
opensim-SC-a57533b6d76d2c19cf53f16dc76f603d2fdb571a.tar.xz
initial version of a meeting concierge module.
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs213
1 files changed, 213 insertions, 0 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs
new file mode 100644
index 0000000..0c0f553
--- /dev/null
+++ b/OpenSim/Region/Environment/Modules/Avatar/Concierge/ConciergeModule.cs
@@ -0,0 +1,213 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Net.Sockets;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using System.Threading;
35using log4net;
36using Nini.Config;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Region.Environment.Interfaces;
40using OpenSim.Region.Environment.Scenes;
41
42namespace OpenSim.Region.Environment.Modules.Avatar.Concierge
43{
44 public class ConciergeModule : IRegionModule
45 {
46 private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47
48 private const int DEBUG_CHANNEL = 2147483647;
49
50 private int _conciergeChannel = 42;
51 private List<Scene> _scenes = new List<Scene>();
52 private IConfig _config;
53 private string _whoami = null;
54
55 internal object _syncy = new object();
56
57 #region IRegionModule Members
58 public void Initialise(Scene scene, IConfigSource config)
59 {
60 try
61 {
62 if ((_config = config.Configs["Concierge"]) == null)
63 {
64 _log.InfoFormat("[Concierge] no configuration section [Concierge] in OpenSim.ini: module not configured");
65 return;
66 }
67
68 if (!_config.GetBoolean("enabled", false))
69 {
70 _log.InfoFormat("[Concierge] module disabled by OpenSim.ini configuration");
71 return;
72 }
73
74 }
75 catch (Exception)
76 {
77 _log.Info("[Concierge] module not configured");
78 return;
79 }
80
81 _conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", _conciergeChannel);
82 _whoami = _config.GetString("concierge_name", "conferencier");
83
84 lock (_syncy)
85 {
86 if (!_scenes.Contains(scene))
87 {
88 _scenes.Add(scene);
89 // subscribe to NewClient events
90 scene.EventManager.OnNewClient += OnNewClient;
91
92 // subscribe to *Chat events
93 scene.EventManager.OnChatFromWorld += OnSimChat;
94 scene.EventManager.OnChatBroadcast += OnSimBroadcast;
95
96 // subscribe to agent change events
97 scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
98 scene.EventManager.OnMakeChildAgent += OnMakeChildAgent;
99 }
100 }
101 _log.InfoFormat("[Concierge] initialized for {0}", scene.RegionInfo.RegionName);
102 }
103
104 public void PostInitialise()
105 {
106 }
107
108 public void Close()
109 {
110 }
111
112 public string Name
113 {
114 get { return "ConciergeModule"; }
115 }
116
117 public bool IsSharedModule
118 {
119 get { return true; }
120 }
121
122 #endregion
123
124 #region ISimChat Members
125 public void OnSimBroadcast(Object sender, OSChatMessage c)
126 {
127 if (_conciergeChannel == c.Channel)
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;
140 }
141
142 public void OnSimChat(Object sender, OSChatMessage c)
143 {
144 if (_conciergeChannel == c.Channel)
145 {
146 // concierge request: interpret
147 return;
148 }
149
150 if (0 == c.Channel || DEBUG_CHANNEL == c.Channel)
151 {
152 // log as avatar/prim chat
153 return;
154 }
155
156 return;
157 }
158
159 #endregion
160
161
162 public void OnNewClient(IClientAPI client)
163 {
164 try
165 {
166 client.OnChatFromViewer += OnSimChat;
167 }
168 catch (Exception ex)
169 {
170 _log.Error("[Concierge]: NewClient exception trap:" + ex.ToString());
171 }
172 }
173
174
175 public void OnMakeRootAgent(ScenePresence agent)
176 {
177 _log.DebugFormat("[Concierge] {0} enters {1}", agent.Name, agent.Scene.RegionInfo.RegionName);
178 AnnounceToAgentsRegion(agent, String.Format("{0} enters {1}", agent.Name, agent.Scene.RegionInfo.RegionName));
179 }
180
181
182 public void OnMakeChildAgent(ScenePresence agent)
183 {
184 _log.DebugFormat("[Concierge] {0} leaves {1}", agent.Name, agent.Scene.RegionInfo.RegionName);
185 AnnounceToAgentsRegion(agent, String.Format("{0} leaves {1}", agent.Name, agent.Scene.RegionInfo.RegionName));
186 }
187
188
189 public void ClientLoggedOut(IClientAPI client)
190 {
191 string clientName = String.Format("{0} {1}", client.FirstName, client.LastName);
192 _log.DebugFormat("[CONCIERGE] {0} logging off.", clientName);
193 }
194
195
196 static private Vector3 posOfGod = new Vector3(128, 128, 9999);
197
198 protected void AnnounceToAgentsRegion(ScenePresence scenePresence, string msg)
199 {
200 OSChatMessage c = new OSChatMessage();
201 c.Message = msg;
202 c.Type = ChatTypeEnum.Say;
203 c.Channel = 0;
204 c.Position = posOfGod;
205 c.From = _whoami;
206 c.Sender = null;
207 c.SenderUUID = UUID.Zero;
208 c.Scene = scenePresence.Scene;
209
210 scenePresence.Scene.EventManager.TriggerOnChatBroadcast(this, c);
211 }
212 }
213} \ No newline at end of file