public void RemovedCallback(string key, object value, CacheItemRemovedReason callbackReason) { if (callbackReason == CacheItemRemovedReason.Expired) { lock (_objLock) { if (_subscribers.Contains(key)) { try { MessageClient messageClient = GetSubscriber(key); if (messageClient != null) { if (log.IsDebugEnabled) { log.Debug(__Res.GetString(__Res.SubscriptionManager_CacheExpired, messageClient.ClientId)); } if (_messageDestination != null) { //MessageBroker messageBroker = _messageDestination.Service.GetMessageBroker(); _TimeoutContext context = new _TimeoutContext(messageClient); FluorineWebSafeCallContext.SetData(FluorineContext.FluorineContextKey, context); messageClient.Timeout(); FluorineWebSafeCallContext.FreeNamedDataSlot(FluorineContext.FluorineContextKey); } } } catch (Exception ex) { if (log.IsErrorEnabled) { log.Error(__Res.GetString(__Res.SubscriptionManager_CacheExpired, string.Empty), ex); } } } } } }
internal void RemovedCallback(string key, object value, CacheItemRemovedReason callbackReason) { if (callbackReason == CacheItemRemovedReason.Expired) { lock (this.SyncRoot) { if (_clients.Contains(key)) { try { IClient client = LookupClient(key); if (client != null) { if (log.IsDebugEnabled) { log.Debug(__Res.GetString(__Res.ClientManager_CacheExpired, client.Id)); } _TimeoutContext context = new _TimeoutContext(client); FluorineWebSafeCallContext.SetData(FluorineContext.FluorineContextKey, context); client.Timeout(); RemoveSubscriber(client); FluorineWebSafeCallContext.FreeNamedDataSlot(FluorineContext.FluorineContextKey); } } catch (Exception ex) { if (log.IsErrorEnabled) { log.Error(__Res.GetString(__Res.ClientManager_CacheExpired, key), ex); } } } } } }
private void OnBeginPushMessageToClients(object asyncResult) { AsyncResultNoResult ar = asyncResult as AsyncResultNoResult; try { // Perform the operation; if sucessful set the result PushData pushData = ar.AsyncState as PushData; //Restore context FluorineWebSafeCallContext.SetData(FluorineContext.FluorineContextKey, pushData.Context); PushMessageToClients(pushData.Subscribers, pushData.Message); ar.SetAsCompleted(null, false); } catch (Exception ex) { // If operation fails, set the exception ar.SetAsCompleted(ex, false); } finally { FluorineWebSafeCallContext.FreeNamedDataSlot(FluorineContext.FluorineContextKey); } }
private void OnBeginInvokeClients(object asyncResult) { AsyncResultNoResult ar = asyncResult as AsyncResultNoResult; try { // Perform the operation; if sucessful set the result InvokeData invokeData = ar.AsyncState as InvokeData; //Restore context FluorineWebSafeCallContext.SetData(FluorineContext.FluorineContextKey, invokeData.Context); InvokeClients(invokeData.Method, invokeData.Arguments, invokeData.Callback, invokeData.IgnoreSelf, invokeData.TargetScope); ar.SetAsCompleted(null, false); } catch (Exception ex) { // If operation fails, set the exception ar.SetAsCompleted(ex, false); } finally { FluorineWebSafeCallContext.FreeNamedDataSlot(FluorineContext.FluorineContextKey); } }