mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:58:29 +00:00
763bcae067
This reverts commit37f4a44a27
. Reason for revert: Relanding after infra issues cleared Original change's description: > Revert "[ VM / Service ] Added `getClientName`, `setClientName` and `requireResumeApproval` RPCs" > > This reverts commit48808f7dce
. > > Reason for revert: Unable to approve failures. > > Original change's description: > > [ VM / Service ] Added `getClientName`, `setClientName` and `requireResumeApproval` RPCs > > > > Add support for naming VM service clients which allows for resume > > permissions to be set for all clients of the same name. If a client > > name requires resume approval, an isolate won't be resumed until all > > clients which require resume approval have called the `resume` RPC. > > > > Resume approvals can be set for the following pause events: > > - PauseOnStart > > - PausePostRequest (issued after `reloadSources(pause: true)`) > > - PauseOnExit > > > > Change-Id: I7dde3d8aaeccfcf47fa84f1f92159846f1560e16 > > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133621 > > Commit-Queue: Ben Konyi <bkonyi@google.com> > > Reviewed-by: Siva Annamalai <asiva@google.com> > > Reviewed-by: Gary Roumanis <grouma@google.com> > > TBR=jacobr@google.com,bkonyi@google.com,rmacnak@google.com,asiva@google.com,grouma@google.com > > Change-Id: I8e60416ad8cbec9ad93f4e34e9bf9af5a516c6dc > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134465 > Reviewed-by: Ben Konyi <bkonyi@google.com> > Commit-Queue: Ben Konyi <bkonyi@google.com> TBR=jacobr@google.com,bkonyi@google.com,rmacnak@google.com,asiva@google.com,grouma@google.com Change-Id: Ibd9d831774e5c4dd500da026f41b173589a9aefd No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/134415 Reviewed-by: Ben Konyi <bkonyi@google.com> Commit-Queue: Ben Konyi <bkonyi@google.com>
70 lines
2.2 KiB
Dart
70 lines
2.2 KiB
Dart
// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
part of dart._vmservice;
|
|
|
|
typedef void ClientServiceHandle(Message? response);
|
|
|
|
// A service client.
|
|
abstract class Client {
|
|
final VMService service;
|
|
final bool sendEvents;
|
|
|
|
static int _idCounter = 0;
|
|
final int _id = ++_idCounter;
|
|
|
|
String get defaultClientName => 'client$_id';
|
|
|
|
String get name => _name;
|
|
set name(String? n) => _name = (n ?? defaultClientName);
|
|
late String _name;
|
|
|
|
/// A set streamIds which describes the streams the client is connected to
|
|
final streams = <String>{};
|
|
|
|
/// Services registered and their aliases
|
|
/// key: service
|
|
/// value: alias
|
|
final services = <String, String>{};
|
|
|
|
/// Callbacks registered for service invocations set to the client
|
|
/// key: RPC id used for the request
|
|
/// value: callback that should be invoked
|
|
final serviceHandles = <String, ClientServiceHandle>{};
|
|
|
|
Client(this.service, {this.sendEvents = true}) {
|
|
_name = defaultClientName;
|
|
service._addClient(this);
|
|
}
|
|
|
|
// Disconnects the client.
|
|
disconnect();
|
|
|
|
/// When implementing, call [close] when the network connection closes.
|
|
void close() => service._removeClient(this);
|
|
|
|
/// Call to process a request. Response will be posted with 'seq'.
|
|
void onRequest(Message message) =>
|
|
// In JSON-RPC 2.0 messages with and id are Request and must be answered
|
|
// http://www.jsonrpc.org/specification#notification
|
|
service.routeRequest(service, message).then(post);
|
|
|
|
void onResponse(Message message) => service.routeResponse(message);
|
|
|
|
/// Call to process a notification. Response will not be posted.
|
|
void onNotification(Message message) =>
|
|
// In JSON-RPC 2.0 messages without an id are Notification
|
|
// and should not be answered
|
|
// http://www.jsonrpc.org/specification#notification
|
|
service.routeRequest(service, message);
|
|
|
|
// Sends a result to the client. Implemented in subclasses.
|
|
//
|
|
// Null can be passed as response to a JSON-RPC notification to close the
|
|
// connection.
|
|
void post(Response? result);
|
|
|
|
Map<String, dynamic> toJson() => {};
|
|
}
|