Refactored data buffering. Updated websocket example to have 2 message roundtrips.

This commit is contained in:
Sergey Lyubka committed 2012-09-20 13:45:35 +01:00
1 parent edffc46b98
commit 98fb44f836
4 files changed
+80 -64

No files matched your search

+6 -1
View File
@@ -2,6 +2,11 @@
<meta charset="utf-8" />
<title>WebSocket Test</title>
<script language="javascript" type="text/javascript">
// This javascript code creates a websocket to the URI "/foo",
// sends a message to it, waits for the reply, and sends an "exit" message.
// Server must terminate the conversation after receiving "exit" message.
var writeToScreen = function(message) {
var div = document.createElement('div');
div.innerHTML = message;
@@ -22,7 +27,7 @@
websocket.onmessage = function(ev) {
writeToScreen('<span style="color: blue;">RESPONSE: ' + ev.data +
' </span>');
websocket.close();
websocket.send('exit');
};
websocket.onerror = function(ev) {
writeToScreen('<span style="color: red; ">ERROR: </span> ' + ev.data);