/// <summary> /// Occurs just before ASP.NET begins executing a handler such as a page or XML Web service. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public async Task PreRequest(object context) { if (DependencyInjection.HttpContextManager.HttpContext.GetContentType() == ContentType.AMF) { DependencyInjection.HttpContextManager.HttpContext.Clear(context); DependencyInjection.HttpContextManager.HttpContext.SetContentType(ContentType.AMF); try { AMFWebContext.Initialize(); if (messageServer != null) { await messageServer.Service(); } DependencyInjection.HttpContextManager.HttpContext.Finish(context); } catch (Exception) { DependencyInjection.HttpContextManager.HttpContext.Clear(context); DependencyInjection.HttpContextManager.HttpContext.Finish(context); } } }
/// <summary> /// Initializes the module and prepares it to handle requests. /// </summary> public void Init() { //http://support.microsoft.com/kb/911816 // Do this one time for each AppDomain. if (!_initialized) { lock (_objLock) { if (!_initialized) { _initialized = true; } } } AMFWebContext.Initialize(); if (messageServer == null) { lock (_objLock) { if (messageServer == null) { messageServer = new MessageServer(); try { messageServer.Init(); messageServer.Start(); } catch (Exception) { } } } } }