Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dwds/lib/dwds.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart';

import 'src/connections/app_connection.dart';
import 'src/connections/debug_connection.dart';
import 'src/devtools.dart';
import 'src/handlers/asset_handler.dart';
import 'src/handlers/dev_handler.dart';
import 'src/handlers/injected_handler.dart';
import 'src/servers/devtools.dart';

export 'src/connections/app_connection.dart' show AppConnection;
export 'src/connections/debug_connection.dart' show DebugConnection;
Expand Down
2 changes: 1 addition & 1 deletion dwds/lib/src/handlers/dev_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import '../../data/devtools_request.dart';
import '../../data/isolate_events.dart';
import '../../data/serializers.dart';
import '../connections/app_connection.dart';
import '../devtools.dart';
import '../dwds_vm_client.dart';
import '../handlers/asset_handler.dart';
import '../servers/devtools.dart';
import '../services/app_debug_services.dart';
import '../services/debug_service.dart';

Expand Down
File renamed without changes.
45 changes: 45 additions & 0 deletions dwds/lib/src/servers/extension_backend.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2019, 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.

import 'dart:io';

import 'package:http_multi_server/http_multi_server.dart';
import 'package:shelf/shelf_io.dart';
import 'package:sse/server/sse_handler.dart';

SseHandler _sseHandler = SseHandler(Uri.parse('/test'));

/// A backend for the Dart Debug Extension which sets up an SSE handler.
///
/// The SSE handler simply sends a simple message and prints the response when
/// a client connects.
class ExtensionBackend {
final String hostname;
final int port;
final HttpServer _server;

ExtensionBackend._(this.hostname, this.port, this._server) {
_listen();
}

// Starts the backend on an open port.
static Future<ExtensionBackend> start() async {
var server = await HttpMultiServer.bind('localhost', 0);
serveRequests(server, _sseHandler.handler);
return ExtensionBackend._(server.address.host, server.port, server);
}

Future<void> close() async {
await _server.close();
}

void _listen() async {
var connections = _sseHandler.connections;
while (await connections.hasNext) {
var connection = await connections.next;
connection.sink.add('foo');
connection.stream.listen(print);
}
}
}