internal WoopsaClientSubscription(WoopsaClientSubscriptionChannel channel, string servicePath, string relativePath, TimeSpan monitorInterval, TimeSpan publishInterval, EventHandler<WoopsaNotificationEventArgs> handler) { Channel = channel; ServicePath = servicePath; RelativePath = relativePath; MonitorInterval = monitorInterval; PublishInterval = publishInterval; Handler = handler; }
public WoopsaClient(string url, WoopsaContainer container, int notificationQueueSize = DefaultNotificationQueueSize) { Uri uri = new Uri(url); AuthorityUrl = uri.GetLeftPart(UriPartial.Authority); ClientProtocol = new WoopsaClientProtocol(url); _container = container; WoopsaUnboundClientObject unboundRoot = CreateUnboundRoot(""); SubscriptionChannel = new WoopsaClientSubscriptionChannel(this, unboundRoot, notificationQueueSize); _remoteMethodMultiRequest = unboundRoot.GetMethod( WoopsaMultiRequestConst.WoopsaMultiRequestMethodName, WoopsaValueType.JsonData, new WoopsaMethodArgumentInfo[] { new WoopsaMethodArgumentInfo(WoopsaMultiRequestConst.WoopsaMultiRequestArgumentName, WoopsaValueType.JsonData) }); }
protected virtual void Dispose(bool disposing) { if (disposing) { SubscriptionChannel.Terminate(); ClientProtocol.Terminate(); if (SubscriptionChannel != null) { SubscriptionChannel.Dispose(); SubscriptionChannel = null; } if (ClientProtocol != null) { ClientProtocol.Dispose(); ClientProtocol = null; } } }
private void executeServiceSubscriptions() { _currentChannel = this; while (!_terminated) try { lock (_channelLock) if (_subscriptionOpenChannel != null) if (SubscriptionsChanged) ManageSubscriptions(); // do not manage too quickly the subscriptions update to improve // grouping of subscriptions into a single multirequest Thread.Sleep(WoopsaSubscriptionServiceConst.ClientSubscriptionUpdateInterval); } catch (Exception) { } }
private void executeServiceNotifications() { _currentChannel = this; while (!_terminated) try { if (_subscriptionOpenChannel == null) OpenChannel(); else { bool hasSubscriptions; lock (_subscriptions) hasSubscriptions = _subscriptions.Count > 0; if (hasSubscriptions) ProcessNotifications(); else Thread.Sleep(TimeSpan.FromMilliseconds(1)); } } catch (WoopsaInvalidSubscriptionChannelException) { CloseChannel(); } catch (WebException) { if (!_terminated) { // There was some sort of network error. We will // try again later Thread.Sleep(ReconnectionInterval); } else { // Cancelled WebRequest, ignore } } catch (ObjectDisposedException) { } catch (Exception) { } }