OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of vmservice_io; | 5 part of vmservice_io; |
6 | 6 |
7 class WebSocketClient extends Client { | 7 class WebSocketClient extends Client { |
8 static const int PARSE_ERROR_CODE = 4000; | 8 static const int PARSE_ERROR_CODE = 4000; |
9 static const int BINARY_MESSAGE_ERROR_CODE = 4001; | 9 static const int BINARY_MESSAGE_ERROR_CODE = 4001; |
10 static const int NOT_MAP_ERROR_CODE = 4002; | 10 static const int NOT_MAP_ERROR_CODE = 4002; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 static const ROOT_REDIRECT_PATH = '/index.html'; | 121 static const ROOT_REDIRECT_PATH = '/index.html'; |
122 | 122 |
123 final VMService _service; | 123 final VMService _service; |
124 final String _ip; | 124 final String _ip; |
125 final int _port; | 125 final int _port; |
126 final bool _originCheckDisabled; | 126 final bool _originCheckDisabled; |
127 HttpServer _server; | 127 HttpServer _server; |
128 bool get running => _server != null; | 128 bool get running => _server != null; |
129 bool _displayMessages = false; | 129 bool _displayMessages = false; |
130 | 130 |
| 131 Uri get serverAddress { |
| 132 if (!running) { |
| 133 return null; |
| 134 } |
| 135 var ip = _server.address.address; |
| 136 var port = _server.port; |
| 137 return Uri.parse('http://$ip:$port/'); |
| 138 } |
| 139 |
131 Server(this._service, this._ip, this._port, this._originCheckDisabled) { | 140 Server(this._service, this._ip, this._port, this._originCheckDisabled) { |
132 _displayMessages = (_ip != '127.0.0.1' || _port != 8181); | 141 _displayMessages = (_ip != '127.0.0.1' || _port != 8181); |
133 } | 142 } |
134 | 143 |
135 bool _isAllowedOrigin(String origin) { | 144 bool _isAllowedOrigin(String origin) { |
136 Uri uri; | 145 Uri uri; |
137 try { | 146 try { |
138 uri = Uri.parse(origin); | 147 uri = Uri.parse(origin); |
139 } catch (_) { | 148 } catch (_) { |
140 return false; | 149 return false; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 _notifyServerState("", 0); | 333 _notifyServerState("", 0); |
325 onServerAddressChange(null); | 334 onServerAddressChange(null); |
326 return this; | 335 return this; |
327 }); | 336 }); |
328 } | 337 } |
329 | 338 |
330 } | 339 } |
331 | 340 |
332 void _notifyServerState(String ip, int port) | 341 void _notifyServerState(String ip, int port) |
333 native "VMServiceIO_NotifyServerState"; | 342 native "VMServiceIO_NotifyServerState"; |
OLD | NEW |