public static async Task <JsonRpcSession> CreateAsync( Optional <Func <CancellationToken, Task <PinnedRemotableDataScope> > > getSnapshotAsync, object callbackTarget, Stream serviceStream, Stream snapshotStreamOpt, CancellationToken cancellationToken) { var snapshot = getSnapshotAsync.Value == null ? null : await getSnapshotAsync.Value(cancellationToken).ConfigureAwait(false); JsonRpcSession session; try { session = new JsonRpcSession(snapshot, callbackTarget, serviceStream, snapshotStreamOpt, cancellationToken); } catch { snapshot?.Dispose(); throw; } try { await session.InitializeAsync().ConfigureAwait(false); } catch when(!cancellationToken.IsCancellationRequested) { // The session disposes of itself when cancellation is requested. session.Dispose(); throw; } return(session); }
public SnapshotJsonRpcClient(JsonRpcSession owner, Stream stream, CancellationToken cancellationToken) : base(stream, callbackTarget: null, useThisAsCallback: true, cancellationToken: cancellationToken) { _owner = owner; _source = new CancellationTokenSource(); StartListening(); }
public SnapshotJsonRpcClient(JsonRpcSession owner, Stream stream, CancellationToken cancellationToken) : base(stream, callbackTarget: null, useThisAsCallback: true, cancellationToken: cancellationToken) { Contract.ThrowIfNull(owner.PinnedScopeOpt); _owner = owner; _source = new CancellationTokenSource(); StartListening(); }
protected override async Task <Session> CreateServiceSessionAsync(string serviceName, PinnedRemotableDataScope snapshot, object callbackTarget, CancellationToken cancellationToken) { // get stream from service hub to communicate snapshot/asset related information // this is the back channel the system uses to move data between VS and remote host var snapshotStream = await RequestServiceAsync(_hubClient, WellKnownServiceHubServices.SnapshotService, _hostGroup, cancellationToken).ConfigureAwait(false); // get stream from service hub to communicate service specific information // this is what consumer actually use to communicate information var serviceStream = await RequestServiceAsync(_hubClient, serviceName, _hostGroup, cancellationToken).ConfigureAwait(false); return(await JsonRpcSession.CreateAsync(snapshot, snapshotStream, callbackTarget, serviceStream, cancellationToken).ConfigureAwait(false)); }
public static async Task <JsonRpcSession> CreateAsync( PinnedRemotableDataScope snapshot, Stream snapshotStream, object callbackTarget, Stream serviceStream, CancellationToken cancellationToken) { var session = new JsonRpcSession(snapshot, snapshotStream, callbackTarget, serviceStream, cancellationToken); await session.InitializeAsync().ConfigureAwait(false); return(session); }
public SnapshotJsonRpcClient(JsonRpcSession owner, Stream stream) : base(stream) { _owner = owner; _source = new CancellationTokenSource(); }