public void UnSubscribe() { lock (this.thisLock) { if (this.subscriber != null) { this.subscriber.Dispose(); this.subscriber = null; SmsProviderEventSource.Current.Info(SmsProviderEventSource.EmptyTrackingId, this, nameof(UnSubscribe), OperationStates.Succeeded, $"Report agent stopped. connectorName={this.credential.ConnectorName} connectorKey={this.credential.ConnectorId}"); } if (this.ts != null) { this.ts.Cancel(); this.ts.Dispose(); this.ts = null; } if (this.connector != null) { this.connector = null; } this.reportManager.OnAgentUnSubscribed(this); } }
public void OnStart(DateTime startTime, string requestId) { lock (this.thisLock) { this.lastMessageSentTime = startTime; if (this.ts == null) { this.ts = new CancellationTokenSource(); } if (this.connector == null) { var serviceUri = new Uri(this.credential.ConnectorUri); var actorId = new ActorId(string.Format(AgentIdFormat, this.credential.ConnectorName, this.credential.ConnectorId)); this.connector = ActorProxy.Create <ISmsConnector>(actorId, serviceUri); } if (this.subscriber == null) { this.subscriber = Observable .Timer(TimeSpan.Zero, PullingInterval) .Select(x => Observable.FromAsync(async() => await PullAsync())) .Concat() .Subscribe(reports => ProcessMessageReports(reports)); SmsProviderEventSource.Current.Info(requestId ?? SmsProviderEventSource.EmptyTrackingId, this, nameof(OnStart), OperationStates.Succeeded, $"Report agent started. connectorName={this.credential.ConnectorName} connectorKey={this.credential.ConnectorId}"); } } }
public InboundAgent(string connectorUri) { this.serviceUri = new Uri(connectorUri); this.actorId = new ActorId(string.Format(AgentIdFormat, Guid.NewGuid().ToString())); this.connector = ActorProxy.Create <ISmsConnector>(this.actorId, this.serviceUri); }