| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:io'; | 6 import 'dart:io'; |
| 7 | 7 |
| 8 import 'package:http_parser/http_parser.dart'; | 8 import 'package:http_parser/http_parser.dart'; |
| 9 import 'package:path/path.dart' as path; | 9 import 'package:path/path.dart' as path; |
| 10 import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc; | 10 import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc; |
| 11 | 11 |
| 12 import '../exit_codes.dart' as exit_codes; | 12 import '../exit_codes.dart' as exit_codes; |
| 13 import '../io.dart'; | 13 import '../io.dart'; |
| 14 import '../log.dart' as log; | 14 import '../log.dart' as log; |
| 15 import '../utils.dart'; | 15 import '../utils.dart'; |
| 16 import 'asset_environment.dart'; | 16 import 'asset_environment.dart'; |
| 17 | 17 |
| 18 /// Implements the [WebSocket] API for communicating with a running pub serve | 18 /// Implements the [WebSocket] API for communicating with a running pub serve |
| 19 /// process, mainly for use by the Editor. | 19 /// process, mainly for use by the Editor. |
| 20 /// | 20 /// |
| 21 /// This is a [JSON-RPC 2.0](http://www.jsonrpc.org/specification) server. Its | 21 /// This is a [JSON-RPC 2.0](http://www.jsonrpc.org/specification) server. Its |
| 22 /// methods are described in the method-level documentation below. | 22 /// methods are described in the method-level documentation below. |
| 23 class WebSocketApi { | 23 class WebSocketApi { |
| 24 final AssetEnvironment _environment; | 24 final AssetEnvironment _environment; |
| 25 final json_rpc.Server _server; | 25 final json_rpc.Server _server; |
| 26 | 26 |
| 27 /// Whether the application should exit when this connection closes. | 27 /// Whether the application should exit when this connection closes. |
| 28 bool _exitOnClose = false; | 28 bool _exitOnClose = false; |
| 29 | 29 |
| 30 WebSocketApi(CompatibleWebSocket socket, this._environment) | 30 WebSocketApi(WebSocketChannel socket, this._environment) |
| 31 : _server = new json_rpc.Server(socket) { | 31 : _server = new json_rpc.Server(socket) { |
| 32 _server.registerMethod("urlToAssetId", _urlToAssetId); | 32 _server.registerMethod("urlToAssetId", _urlToAssetId); |
| 33 _server.registerMethod("pathToUrls", _pathToUrls); | 33 _server.registerMethod("pathToUrls", _pathToUrls); |
| 34 _server.registerMethod("serveDirectory", _serveDirectory); | 34 _server.registerMethod("serveDirectory", _serveDirectory); |
| 35 _server.registerMethod("unserveDirectory", _unserveDirectory); | 35 _server.registerMethod("unserveDirectory", _unserveDirectory); |
| 36 | 36 |
| 37 /// Tells the server to exit as soon as this WebSocket connection is closed. | 37 /// Tells the server to exit as soon as this WebSocket connection is closed. |
| 38 /// | 38 /// |
| 39 /// This takes no arguments and returns no results. It can safely be called | 39 /// This takes no arguments and returns no results. It can safely be called |
| 40 /// as a JSON-RPC notification. | 40 /// as a JSON-RPC notification. |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 } | 298 } |
| 299 | 299 |
| 300 /// The pub-specific JSON RPC error codes. | 300 /// The pub-specific JSON RPC error codes. |
| 301 class _Error { | 301 class _Error { |
| 302 /// The specified directory is not being served. | 302 /// The specified directory is not being served. |
| 303 static const NOT_SERVED = 1; | 303 static const NOT_SERVED = 1; |
| 304 | 304 |
| 305 /// The specified directory overlaps one or more ones already being served. | 305 /// The specified directory overlaps one or more ones already being served. |
| 306 static const OVERLAPPING = 2; | 306 static const OVERLAPPING = 2; |
| 307 } | 307 } |
| OLD | NEW |