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 | 5 |
6 final Map _servicePathMap = { | 6 final Map _servicePathMap = { |
7 'http' : { | 7 'http' : { |
8 'servers' : _httpServersServiceObject | 8 'servers' : _httpServersServiceObject, |
9 }, | 9 }, |
| 10 'socket' : _socketServiceObject, |
10 'file' : { | 11 'file' : { |
11 'randomaccessfiles' : _randomAccessFilesServiceObject | 12 'randomaccessfiles' : _randomAccessFilesServiceObject |
12 } | 13 } |
13 }; | 14 }; |
14 | 15 |
15 String _serviceObjectHandler(List<String> paths, | 16 String _serviceObjectHandler(List<String> paths, |
16 List<String> keys, | 17 List<String> keys, |
17 List<String> values) { | 18 List<String> values) { |
18 assert(keys.length == values.length); | 19 assert(keys.length == values.length); |
19 badPath() { | 20 badPath() { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 return server._toJSON(false); | 57 return server._toJSON(false); |
57 } | 58 } |
58 return { | 59 return { |
59 'id': 'io/http/servers', | 60 'id': 'io/http/servers', |
60 'type': 'HttpServerList', | 61 'type': 'HttpServerList', |
61 'members': _HttpServer._servers.values | 62 'members': _HttpServer._servers.values |
62 .map((server) => server._toJSON(true)).toList(), | 63 .map((server) => server._toJSON(true)).toList(), |
63 }; | 64 }; |
64 } | 65 } |
65 | 66 |
| 67 Map _socketServiceObject(args) { |
| 68 if (args.length == 1) { |
| 69 var socket = _NativeSocket._sockets[int.parse(args.first)]; |
| 70 if (socket == null) { |
| 71 return {}; |
| 72 } |
| 73 return socket._toJSON(false); |
| 74 } |
| 75 return { |
| 76 'id': 'io/socket', |
| 77 'type': 'SocketList', |
| 78 'members': _NativeSocket._sockets.values |
| 79 .map((socket) => socket._toJSON(true)).toList(), |
| 80 }; |
| 81 } |
| 82 |
66 Map _randomAccessFilesServiceObject(args) { | 83 Map _randomAccessFilesServiceObject(args) { |
67 if (args.length == 1) { | 84 if (args.length == 1) { |
68 var raf = _RandomAccessFile._files[int.parse(args.first)]; | 85 var raf = _RandomAccessFile._files[int.parse(args.first)]; |
69 if (raf == null) { | 86 if (raf == null) { |
70 return {}; | 87 return {}; |
71 } | 88 } |
72 return raf._toJSON(false); | 89 return raf._toJSON(false); |
73 } | 90 } |
74 return { | 91 return { |
75 'id': 'io/file/randomaccessfiles', | 92 'id': 'io/file/randomaccessfiles', |
76 'type': 'RandomAccessFileList', | 93 'type': 'RandomAccessFileList', |
77 'members': _RandomAccessFile._files.values | 94 'members': _RandomAccessFile._files.values |
78 .map((raf) => raf._toJSON(true)).toList(), | 95 .map((raf) => raf._toJSON(true)).toList(), |
79 }; | 96 }; |
80 } | 97 } |
81 | 98 |
OLD | NEW |