diff options
author | opensim mirror account | 2010-11-21 15:40:03 -0800 |
---|---|---|
committer | opensim mirror account | 2010-11-21 15:40:03 -0800 |
commit | dd67175edfbad3055c9316c146d21a6ef56e1dc1 (patch) | |
tree | 26a1ea878201f41a3d49f6f11a2d8c9c4d420198 | |
parent | Merge branch 'master' of /var/git/opensim/ (diff) | |
parent | Convert the Freeswitch module to new style (diff) | |
download | opensim-SC_OLD-dd67175edfbad3055c9316c146d21a6ef56e1dc1.zip opensim-SC_OLD-dd67175edfbad3055c9316c146d21a6ef56e1dc1.tar.gz opensim-SC_OLD-dd67175edfbad3055c9316c146d21a6ef56e1dc1.tar.bz2 opensim-SC_OLD-dd67175edfbad3055c9316c146d21a6ef56e1dc1.tar.xz |
Merge branch 'master' of /var/git/opensim/
-rw-r--r-- | OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | 191 |
1 files changed, 98 insertions, 93 deletions
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs index cceaa9b..4095674 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs | |||
@@ -41,6 +41,7 @@ using log4net; | |||
41 | using Nini.Config; | 41 | using Nini.Config; |
42 | using Nwc.XmlRpc; | 42 | using Nwc.XmlRpc; |
43 | using OpenSim.Framework; | 43 | using OpenSim.Framework; |
44 | using Mono.Addins; | ||
44 | 45 | ||
45 | using OpenSim.Framework.Capabilities; | 46 | using OpenSim.Framework.Capabilities; |
46 | using OpenSim.Framework.Servers; | 47 | using OpenSim.Framework.Servers; |
@@ -52,7 +53,8 @@ using System.Text.RegularExpressions; | |||
52 | 53 | ||
53 | namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | 54 | namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice |
54 | { | 55 | { |
55 | public class FreeSwitchVoiceModule : IRegionModule, IVoiceModule | 56 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FreeSwitchVoiceModule")] |
57 | public class FreeSwitchVoiceModule : INonSharedRegionModule, IVoiceModule | ||
56 | { | 58 | { |
57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 59 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
58 | 60 | ||
@@ -64,8 +66,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
64 | private static readonly string m_chatSessionRequestPath = "0009/"; | 66 | private static readonly string m_chatSessionRequestPath = "0009/"; |
65 | 67 | ||
66 | // Control info | 68 | // Control info |
67 | private static bool m_WOF = true; | 69 | private static bool m_Enabled = false; |
68 | private static bool m_pluginEnabled = false; | ||
69 | 70 | ||
70 | // FreeSwitch server is going to contact us and ask us all | 71 | // FreeSwitch server is going to contact us and ask us all |
71 | // sorts of things. | 72 | // sorts of things. |
@@ -104,9 +105,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
104 | 105 | ||
105 | private IConfig m_config; | 106 | private IConfig m_config; |
106 | 107 | ||
107 | public void Initialise(Scene scene, IConfigSource config) | 108 | public void Initialise(IConfigSource config) |
108 | { | 109 | { |
109 | m_scene = scene; | ||
110 | m_config = config.Configs["FreeSwitchVoice"]; | 110 | m_config = config.Configs["FreeSwitchVoice"]; |
111 | 111 | ||
112 | if (null == m_config) | 112 | if (null == m_config) |
@@ -121,86 +121,106 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
121 | return; | 121 | return; |
122 | } | 122 | } |
123 | 123 | ||
124 | // This is only done the FIRST time this method is invoked. | 124 | m_Enabled = true; |
125 | if (m_WOF) | ||
126 | { | ||
127 | m_pluginEnabled = true; | ||
128 | m_WOF = false; | ||
129 | 125 | ||
130 | try | 126 | try |
127 | { | ||
128 | m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); | ||
129 | m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); | ||
130 | m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); | ||
131 | |||
132 | // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) | ||
133 | |||
134 | string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); | ||
135 | int servicePort = m_config.GetInt("freeswitch_service_port", 80); | ||
136 | IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); | ||
137 | // m_FreeSwitchServiceIP = new IPEndPoint(serviceIPAddress, servicePort); | ||
138 | m_freeSwitchServicePort = servicePort; | ||
139 | m_freeSwitchRealm = m_config.GetString("freeswitch_realm", String.Empty); | ||
140 | m_freeSwitchSIPProxy = m_config.GetString("freeswitch_sip_proxy", m_freeSwitchRealm); | ||
141 | m_freeSwitchAttemptUseSTUN = m_config.GetBoolean("freeswitch_attempt_stun", true); | ||
142 | // m_freeSwitchSTUNServer = m_config.GetString("freeswitch_stun_server", m_freeSwitchRealm); | ||
143 | m_freeSwitchEchoServer = m_config.GetString("freeswitch_echo_server", m_freeSwitchRealm); | ||
144 | m_freeSwitchEchoPort = m_config.GetInt("freeswitch_echo_port", 50505); | ||
145 | m_freeSwitchDefaultWellKnownIP = m_config.GetString("freeswitch_well_known_ip", m_freeSwitchRealm); | ||
146 | m_openSimWellKnownHTTPAddress = m_config.GetString("opensim_well_known_http_address", serviceIPAddress.ToString()); | ||
147 | m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); | ||
148 | // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); | ||
149 | m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); | ||
150 | m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); | ||
151 | |||
152 | if (String.IsNullOrEmpty(m_freeSwitchServerUser) || | ||
153 | String.IsNullOrEmpty(m_freeSwitchServerPass) || | ||
154 | String.IsNullOrEmpty(m_freeSwitchRealm) || | ||
155 | String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) | ||
131 | { | 156 | { |
132 | m_freeSwitchServerUser = m_config.GetString("freeswitch_server_user", String.Empty); | 157 | m_log.Error("[FreeSwitchVoice] plugin mis-configured"); |
133 | m_freeSwitchServerPass = m_config.GetString("freeswitch_server_pass", String.Empty); | 158 | m_log.Info("[FreeSwitchVoice] plugin disabled: incomplete configuration"); |
134 | m_freeSwitchAPIPrefix = m_config.GetString("freeswitch_api_prefix", String.Empty); | 159 | return; |
135 | 160 | } | |
136 | // XXX: get IP address of HTTP server. (This can be this OpenSim server or another, or could be a dedicated grid service or may live on the freeswitch server) | ||
137 | |||
138 | string serviceIP = m_config.GetString("freeswitch_service_server", String.Empty); | ||
139 | int servicePort = m_config.GetInt("freeswitch_service_port", 80); | ||
140 | IPAddress serviceIPAddress = IPAddress.Parse(serviceIP); | ||
141 | // m_FreeSwitchServiceIP = new IPEndPoint(serviceIPAddress, servicePort); | ||
142 | m_freeSwitchServicePort = servicePort; | ||
143 | m_freeSwitchRealm = m_config.GetString("freeswitch_realm", String.Empty); | ||
144 | m_freeSwitchSIPProxy = m_config.GetString("freeswitch_sip_proxy", m_freeSwitchRealm); | ||
145 | m_freeSwitchAttemptUseSTUN = m_config.GetBoolean("freeswitch_attempt_stun", true); | ||
146 | // m_freeSwitchSTUNServer = m_config.GetString("freeswitch_stun_server", m_freeSwitchRealm); | ||
147 | m_freeSwitchEchoServer = m_config.GetString("freeswitch_echo_server", m_freeSwitchRealm); | ||
148 | m_freeSwitchEchoPort = m_config.GetInt("freeswitch_echo_port", 50505); | ||
149 | m_freeSwitchDefaultWellKnownIP = m_config.GetString("freeswitch_well_known_ip", m_freeSwitchRealm); | ||
150 | m_openSimWellKnownHTTPAddress = m_config.GetString("opensim_well_known_http_address", serviceIPAddress.ToString()); | ||
151 | m_freeSwitchDefaultTimeout = m_config.GetInt("freeswitch_default_timeout", 5000); | ||
152 | // m_freeSwitchSubscribeRetry = m_config.GetInt("freeswitch_subscribe_retry", 120); | ||
153 | m_freeSwitchUrlResetPassword = m_config.GetString("freeswitch_password_reset_url", String.Empty); | ||
154 | m_freeSwitchContext = m_config.GetString("freeswitch_context", "default"); | ||
155 | |||
156 | if (String.IsNullOrEmpty(m_freeSwitchServerUser) || | ||
157 | String.IsNullOrEmpty(m_freeSwitchServerPass) || | ||
158 | String.IsNullOrEmpty(m_freeSwitchRealm) || | ||
159 | String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) | ||
160 | { | ||
161 | m_log.Error("[FreeSwitchVoice] plugin mis-configured"); | ||
162 | m_log.Info("[FreeSwitchVoice] plugin disabled: incomplete configuration"); | ||
163 | return; | ||
164 | } | ||
165 | 161 | ||
166 | // set up http request handlers for | 162 | // set up http request handlers for |
167 | // - prelogin: viv_get_prelogin.php | 163 | // - prelogin: viv_get_prelogin.php |
168 | // - signin: viv_signin.php | 164 | // - signin: viv_signin.php |
169 | // - buddies: viv_buddy.php | 165 | // - buddies: viv_buddy.php |
170 | // - ???: viv_watcher.php | 166 | // - ???: viv_watcher.php |
171 | // - signout: viv_signout.php | 167 | // - signout: viv_signout.php |
172 | MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), | 168 | MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), |
173 | FreeSwitchSLVoiceGetPreloginHTTPHandler); | 169 | FreeSwitchSLVoiceGetPreloginHTTPHandler); |
174 | 170 | ||
175 | // RestStreamHandler h = new | 171 | // RestStreamHandler h = new |
176 | // RestStreamHandler("GET", | 172 | // RestStreamHandler("GET", |
177 | // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); | 173 | // String.Format("{0}/viv_get_prelogin.php", m_freeSwitchAPIPrefix), FreeSwitchSLVoiceGetPreloginHTTPHandler); |
178 | // MainServer.Instance.AddStreamHandler(h); | 174 | // MainServer.Instance.AddStreamHandler(h); |
179 | 175 | ||
180 | 176 | ||
181 | 177 | ||
182 | MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), | 178 | MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_signin.php", m_freeSwitchAPIPrefix), |
183 | FreeSwitchSLVoiceSigninHTTPHandler); | 179 | FreeSwitchSLVoiceSigninHTTPHandler); |
184 | 180 | ||
185 | MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), | 181 | MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), |
186 | FreeSwitchSLVoiceBuddyHTTPHandler); | 182 | FreeSwitchSLVoiceBuddyHTTPHandler); |
187 | 183 | ||
188 | m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); | 184 | m_log.InfoFormat("[FreeSwitchVoice] using FreeSwitch server {0}", m_freeSwitchRealm); |
189 | 185 | ||
190 | m_pluginEnabled = true; | 186 | m_Enabled = true; |
191 | m_WOF = false; | 187 | |
188 | m_log.Info("[FreeSwitchVoice] plugin enabled"); | ||
189 | } | ||
190 | catch (Exception e) | ||
191 | { | ||
192 | m_log.ErrorFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.Message); | ||
193 | m_log.DebugFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.ToString()); | ||
194 | return; | ||
195 | } | ||
192 | 196 | ||
193 | m_log.Info("[FreeSwitchVoice] plugin enabled"); | 197 | // This here is a region module trying to make a global setting. |
198 | // Not really a good idea but it's Windows only, so I can't test. | ||
199 | try | ||
200 | { | ||
201 | ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation; | ||
202 | } | ||
203 | catch (NotImplementedException) | ||
204 | { | ||
205 | try | ||
206 | { | ||
207 | #pragma warning disable 0612, 0618 | ||
208 | // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! | ||
209 | ServicePointManager.CertificatePolicy = new MonoCert(); | ||
210 | #pragma warning restore 0612, 0618 | ||
194 | } | 211 | } |
195 | catch (Exception e) | 212 | catch (Exception) |
196 | { | 213 | { |
197 | m_log.ErrorFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.Message); | 214 | //m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); |
198 | m_log.DebugFormat("[FreeSwitchVoice] plugin initialization failed: {0}", e.ToString()); | ||
199 | return; | ||
200 | } | 215 | } |
201 | } | 216 | } |
217 | } | ||
218 | |||
219 | public void AddRegion(Scene scene) | ||
220 | { | ||
221 | m_scene = scene; | ||
202 | 222 | ||
203 | if (m_pluginEnabled) | 223 | if (m_Enabled) |
204 | { | 224 | { |
205 | // we need to capture scene in an anonymous method | 225 | // we need to capture scene in an anonymous method |
206 | // here as we need it later in the callbacks | 226 | // here as we need it later in the callbacks |
@@ -208,36 +228,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
208 | { | 228 | { |
209 | OnRegisterCaps(scene, agentID, caps); | 229 | OnRegisterCaps(scene, agentID, caps); |
210 | }; | 230 | }; |
211 | |||
212 | try | ||
213 | { | ||
214 | ServicePointManager.ServerCertificateValidationCallback += CustomCertificateValidation; | ||
215 | } | ||
216 | catch (NotImplementedException) | ||
217 | { | ||
218 | try | ||
219 | { | ||
220 | #pragma warning disable 0612, 0618 | ||
221 | // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! | ||
222 | ServicePointManager.CertificatePolicy = new MonoCert(); | ||
223 | #pragma warning restore 0612, 0618 | ||
224 | } | ||
225 | catch (Exception) | ||
226 | { | ||
227 | m_log.Error("[FreeSwitchVoice]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); | ||
228 | } | ||
229 | } | ||
230 | } | 231 | } |
231 | } | 232 | } |
232 | 233 | ||
233 | public void PostInitialise() | 234 | public void RemoveRegion(Scene scene) |
235 | { | ||
236 | } | ||
237 | |||
238 | public void RegionLoaded(Scene scene) | ||
234 | { | 239 | { |
235 | if (m_pluginEnabled) | 240 | if (m_Enabled) |
236 | { | 241 | { |
237 | m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); | 242 | m_log.Info("[FreeSwitchVoice] registering IVoiceModule with the scene"); |
238 | 243 | ||
239 | // register the voice interface for this module, so the script engine can call us | 244 | // register the voice interface for this module, so the script engine can call us |
240 | m_scene.RegisterModuleInterface<IVoiceModule>(this); | 245 | scene.RegisterModuleInterface<IVoiceModule>(this); |
241 | } | 246 | } |
242 | } | 247 | } |
243 | 248 | ||
@@ -250,9 +255,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice | |||
250 | get { return "FreeSwitchVoiceModule"; } | 255 | get { return "FreeSwitchVoiceModule"; } |
251 | } | 256 | } |
252 | 257 | ||
253 | public bool IsSharedModule | 258 | public Type ReplaceableInterface |
254 | { | 259 | { |
255 | get { return true; } | 260 | get { return null; } |
256 | } | 261 | } |
257 | 262 | ||
258 | // <summary> | 263 | // <summary> |