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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // Server is up and running. | 173 // Server is up and running. |
174 _notifyServerState(ip, _server.port); | 174 _notifyServerState(ip, _server.port); |
175 return this; | 175 return this; |
176 }).catchError((e, st) { | 176 }).catchError((e, st) { |
177 print('Could not start Observatory HTTP server:\n$e\n$st\n'); | 177 print('Could not start Observatory HTTP server:\n$e\n$st\n'); |
178 _notifyServerState("", 0); | 178 _notifyServerState("", 0); |
179 return this; | 179 return this; |
180 }); | 180 }); |
181 } | 181 } |
182 | 182 |
| 183 close(bool force) { |
| 184 if (_server == null) { |
| 185 return new Future.value(null); |
| 186 } |
| 187 return _server.close(force: force); |
| 188 } |
| 189 |
183 Future shutdown(bool forced) { | 190 Future shutdown(bool forced) { |
184 if (_server == null) { | 191 if (_server == null) { |
185 // Not started. | 192 // Not started. |
186 return new Future.value(this); | 193 return new Future.value(this); |
187 } | 194 } |
188 | 195 |
189 // Force displaying of status messages if we are forcibly shutdown. | 196 // Force displaying of status messages if we are forcibly shutdown. |
190 _displayMessages = _displayMessages || forced; | 197 _displayMessages = _displayMessages || forced; |
191 | 198 |
192 // Shutdown HTTP server and subscription. | 199 // Shutdown HTTP server and subscription. |
193 var ip = _server.address.address.toString(); | 200 var ip = _server.address.address.toString(); |
194 var port = _server.port.toString(); | 201 var port = _server.port.toString(); |
195 return _server.close(force: forced).then((_) { | 202 return close(forced).then((_) { |
196 if (_displayMessages) { | 203 if (_displayMessages) { |
197 print('Observatory no longer listening on http://$ip:$port'); | 204 print('Observatory no longer listening on http://$ip:$port'); |
198 } | 205 } |
199 _server = null; | 206 _server = null; |
200 _notifyServerState("", 0); | 207 _notifyServerState("", 0); |
201 return this; | 208 return this; |
202 }).catchError((e, st) { | 209 }).catchError((e, st) { |
203 _server = null; | 210 _server = null; |
204 print('Could not shutdown Observatory HTTP server:\n$e\n$st\n'); | 211 print('Could not shutdown Observatory HTTP server:\n$e\n$st\n'); |
205 _notifyServerState("", 0); | 212 _notifyServerState("", 0); |
206 return this; | 213 return this; |
207 }); | 214 }); |
208 } | 215 } |
209 | 216 |
210 } | 217 } |
211 | 218 |
212 void _notifyServerState(String ip, int port) | 219 void _notifyServerState(String ip, int port) |
213 native "VMServiceIO_NotifyServerState"; | 220 native "VMServiceIO_NotifyServerState"; |
OLD | NEW |