OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library input.transformer; | 5 library input.transformer; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:convert'; | 8 import 'dart:convert'; |
9 import 'dart:io'; | 9 import 'dart:io'; |
10 | 10 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 if (exception is UnimplementedError) { | 196 if (exception is UnimplementedError) { |
197 if (exception.message.startsWith(ERROR_PREFIX)) { | 197 if (exception.message.startsWith(ERROR_PREFIX)) { |
198 result = JSON.decode(exception.message.substring(ERROR_PREFIX.length)); | 198 result = JSON.decode(exception.message.substring(ERROR_PREFIX.length)); |
199 } | 199 } |
200 } | 200 } |
201 processResponseResult(id, result); | 201 processResponseResult(id, result); |
202 } | 202 } |
203 | 203 |
204 /** | 204 /** |
205 * Process the expected response by completing the given completer | 205 * Process the expected response by completing the given completer |
206 * with the result if it has alredy been received, | 206 * with the result if it has already been received, |
207 * or caching the completer to be completed when the server | 207 * or caching the completer to be completed when the server |
208 * returns the associated result. | 208 * returns the associated result. |
209 * Return a future that completes when the response is received | 209 * Return a future that completes when the response is received |
210 * or `null` if the response has already been received | 210 * or `null` if the response has already been received |
211 * and the completer completed. | 211 * and the completer completed. |
212 */ | 212 */ |
213 Future processExpectedResponse(String id, Completer completer) { | 213 Future processExpectedResponse(String id, Completer completer) { |
214 if (responseMap.containsKey(id)) { | 214 if (responseMap.containsKey(id)) { |
215 logger.log(Level.INFO, 'processing cached response $id'); | 215 logger.log(Level.INFO, 'processing cached response $id'); |
216 completer.complete(responseMap.remove(id)); | 216 completer.complete(responseMap.remove(id)); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 if (op != null) { | 390 if (op != null) { |
391 outSink.add(op); | 391 outSink.add(op); |
392 } | 392 } |
393 } | 393 } |
394 | 394 |
395 @override | 395 @override |
396 void close() { | 396 void close() { |
397 outSink.close(); | 397 outSink.close(); |
398 } | 398 } |
399 } | 399 } |
OLD | NEW |