| 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 library protocol; | 5 library protocol; |
| 6 | 6 |
| 7 import 'dart:convert' show JsonDecoder; | 7 import 'dart:convert' show JsonDecoder; |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Instances of the class [Request] represent a request that was received. | 10 * Instances of the class [Request] represent a request that was received. |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 factory Request.fromString(String data) { | 70 factory Request.fromString(String data) { |
| 71 try { | 71 try { |
| 72 var result = DECODER.convert(data); | 72 var result = DECODER.convert(data); |
| 73 if (result is! Map) { | 73 if (result is! Map) { |
| 74 return null; | 74 return null; |
| 75 } | 75 } |
| 76 String id = result[Request.ID]; | 76 String id = result[Request.ID]; |
| 77 String method = result[Request.METHOD]; | 77 String method = result[Request.METHOD]; |
| 78 Map<String, Object> params = result[Request.PARAMS]; | 78 Map<String, Object> params = result[Request.PARAMS]; |
| 79 Request request = new Request(id, method); | 79 Request request = new Request(id, method); |
| 80 params.forEach((String key, Object value) { | 80 if (params != null) { |
| 81 request.setParameter(key, value); | 81 params.forEach((String key, Object value) { |
| 82 }); | 82 request.setParameter(key, value); |
| 83 }); |
| 84 } |
| 83 return request; | 85 return request; |
| 84 } catch (exception) { | 86 } catch (exception) { |
| 85 return null; | 87 return null; |
| 86 } | 88 } |
| 87 } | 89 } |
| 88 | 90 |
| 89 /** | 91 /** |
| 90 * Return the value of the parameter with the given [name], or `null` if there | 92 * Return the value of the parameter with the given [name], or `null` if there |
| 91 * is no such parameter associated with this request. | 93 * is no such parameter associated with this request. |
| 92 */ | 94 */ |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 /** | 493 /** |
| 492 * The response to be returned as a result of the failure. | 494 * The response to be returned as a result of the failure. |
| 493 */ | 495 */ |
| 494 final Response response; | 496 final Response response; |
| 495 | 497 |
| 496 /** | 498 /** |
| 497 * Initialize a newly created exception to return the given reponse. | 499 * Initialize a newly created exception to return the given reponse. |
| 498 */ | 500 */ |
| 499 RequestFailure(this.response); | 501 RequestFailure(this.response); |
| 500 } | 502 } |
| OLD | NEW |