Skip to content

Commit

Permalink
Optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
andot committed Oct 4, 2019
1 parent 101eb55 commit 1b6c7e7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lib/src/rpc/core/method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| |
| Method for Dart. |
| |
| LastModified: Mar 29, 2019 |
| LastModified: Oct 4, 2019 |
| Author: Ma Bingyao <andot@hprose.com> |
| |
\*________________________________________________________*/
Expand Down Expand Up @@ -66,6 +66,7 @@ class Method {
options[name] = invocation.positionalArguments[0];
}
}

String _getFunctionName(Function func) {
var str = func.toString();
var n = str.indexOf(' from Function \'');
Expand Down
6 changes: 4 additions & 2 deletions lib/src/rpc/http_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| |
| HttpHandler for Dart. |
| |
| LastModified: May 25, 2019 |
| LastModified: Oct 4, 2019 |
| Author: Ma Bingyao <andot@hprose.com> |
| |
\*________________________________________________________*/
Expand Down Expand Up @@ -177,7 +177,9 @@ class HttpHandler implements Handler<HttpServer> {
}
ByteStream stream =
new ByteStream(request.contentLength >= 0 ? request.contentLength : 0);
await for (var data in request) stream.write(data);
await for (var data in request) {
stream.write(data);
}
final data = stream.takeBytes();
Uint8List result;
switch (request.method) {
Expand Down
6 changes: 4 additions & 2 deletions lib/src/rpc/http_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| |
| HttpTransport for Dart. |
| |
| LastModified: May 4, 2019 |
| LastModified: Oct 4, 2019 |
| Author: Ma Bingyao <andot@hprose.com> |
| |
\*________________________________________________________*/
Expand Down Expand Up @@ -72,7 +72,9 @@ class HttpTransport implements Transport {
context['httpResponseHeaders'] = httpResponse.headers;
ByteStream stream = new ByteStream(
httpResponse.contentLength >= 0 ? httpResponse.contentLength : 0);
await for (var data in httpResponse) stream.write(data);
await for (var data in httpResponse) {
stream.write(data);
}
return stream.takeBytes();
}
throw new Exception(
Expand Down
4 changes: 2 additions & 2 deletions lib/src/rpc/plugins/oneway.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| |
| Oneway plugin for Dart. |
| |
| LastModified: Mar 25, 2019 |
| LastModified: Oct 4, 2019 |
| Author: Ma Bingyao <andot@hprose.com> |
| |
\*________________________________________________________*/
Expand All @@ -18,7 +18,7 @@ part of hprose.rpc.plugins;
class Oneway {
const Oneway();
Future handler(
String name, List args, Context context, NextInvokeHandler next) async {
String name, List args, Context context, NextInvokeHandler next) {
final result = next(name, args, context);
if (context.containsKey('oneway') && context['oneway'] as bool) {
result.catchError((e) => {});
Expand Down
4 changes: 2 additions & 2 deletions lib/src/rpc/websocket_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| |
| WebSocketHandler for Dart. |
| |
| LastModified: May 25, 2019 |
| LastModified: Oct 4, 2019 |
| Author: Ma Bingyao <andot@hprose.com> |
| |
\*________________________________________________________*/
Expand All @@ -33,7 +33,7 @@ class WebSocketHandler extends HttpHandler {
if (onAccept != null) onAccept(socket);
} catch (e) {
if (onError != null) onWebSocketError(socket, e);
socket.close();
await socket.close();
if (onClose != null) onClose(socket);
return;
}
Expand Down

0 comments on commit 1b6c7e7

Please sign in to comment.