Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Unified Diff: samples/tests/samples/src/chat/ChatServerTest.dart

Issue 8776001: Fix HTTP sample implementation to actually wait for connections before attempting to write. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « samples/chat/http_impl.dart ('k') | samples/tests/samples/src/chat/HttpTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/tests/samples/src/chat/ChatServerTest.dart
diff --git a/samples/tests/samples/src/chat/ChatServerTest.dart b/samples/tests/samples/src/chat/ChatServerTest.dart
index d5e29a0a3ca9e4232d259c605ea2b852a868580b..1307cfc5ccd540fa4743b91970fe047b7a571ac4 100644
--- a/samples/tests/samples/src/chat/ChatServerTest.dart
+++ b/samples/tests/samples/src/chat/ChatServerTest.dart
@@ -65,14 +65,17 @@ class ChatTestClient extends Isolate {
Map messageRequest = new Map();
messageRequest["request"] = "leave";
messageRequest["sessionId"] = sessionId;
- request = httpClient.open("POST", "127.0.0.1", port, "/leave");
- request.writeString(JSON.stringify(messageRequest));
- request.responseReceived =
- void _(HTTPClientResponse r) {
- response = r;
- response.dataEnd = leaveResponseHandler;
- };
- request.writeDone();
+ httpClient.openHandler = (HTTPClientRequest request) {
+ print('leave');
+ request.writeString(JSON.stringify(messageRequest));
+ request.writeDone();
+ request.responseReceived = (HTTPClientResponse r) {
+ print('leave response');
+ response = r;
+ response.dataEnd = leaveResponseHandler;
+ };
+ };
+ httpClient.open("POST", "127.0.0.1", port, "/leave");
}
void receive() {
@@ -121,14 +124,17 @@ class ChatTestClient extends Isolate {
messageRequest["request"] = "receive";
messageRequest["sessionId"] = sessionId;
messageRequest["nextMessage"] = receiveMessageNumber;
- request = httpClient.open("POST", "127.0.0.1", port, "/receive");
- request.writeString(JSON.stringify(messageRequest));
- request.responseReceived =
- void _(HTTPClientResponse r) {
- response = r;
- response.dataEnd = receiveResponseHandler;
- };
- request.writeDone();
+ httpClient.openHandler = (HTTPClientRequest request) {
+ print('receive');
+ request.writeString(JSON.stringify(messageRequest));
+ request.writeDone();
+ request.responseReceived = (HTTPClientResponse r) {
+ print('receive response');
+ response = r;
+ response.dataEnd = receiveResponseHandler;
+ };
+ };
+ httpClient.open("POST", "127.0.0.1", port, "/receive");
}
void sendMessage() {
@@ -151,14 +157,17 @@ class ChatTestClient extends Isolate {
messageRequest["request"] = "message";
messageRequest["sessionId"] = sessionId;
messageRequest["message"] = "message " + sendMessageNumber;
- request = httpClient.open("POST", "127.0.0.1", port, "/message");
- request.writeString(JSON.stringify(messageRequest));
- request.responseReceived =
- void _(HTTPClientResponse r) {
- response = r;
- response.dataEnd = sendResponseHandler;
- };
- request.writeDone();
+ httpClient.openHandler = (HTTPClientRequest request) {
+ print('message');
+ request.writeString(JSON.stringify(messageRequest));
+ request.writeDone();
+ request.responseReceived = (HTTPClientResponse r) {
+ print('message response');
+ response = r;
+ response.dataEnd = sendResponseHandler;
+ };
+ };
+ httpClient.open("POST", "127.0.0.1", port, "/message");
}
void join() {
@@ -182,14 +191,18 @@ class ChatTestClient extends Isolate {
Map joinRequest = new Map();
joinRequest["request"] = "join";
joinRequest["handle"] = "test1";
- request = httpClient.open("POST", "127.0.0.1", port, "/join");
- request.writeString(JSON.stringify(joinRequest));
- request.responseReceived =
- void _(HTTPClientResponse r) {
- response = r;
- response.dataEnd = joinResponseHandler;
- };
- request.writeDone();
+ httpClient.openHandler = (HTTPClientRequest request) {
+ print("join");
+ request.writeString(JSON.stringify(joinRequest));
+ request.writeDone();
+ request.responseReceived = (HTTPClientResponse r) {
+ print("join response");
+ response = r;
+ response.dataEnd = joinResponseHandler;
+ };
+ };
+ print('opening for join');
+ httpClient.open("POST", "127.0.0.1", port, "/join");
}
this.port.receive(
« no previous file with comments | « samples/chat/http_impl.dart ('k') | samples/tests/samples/src/chat/HttpTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698