mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-15 10:29:47 +00:00
Refactored data buffering. Updated websocket example to have 2 message roundtrips.
This commit is contained in:
1 parent
edffc46b98
commit
98fb44f836
4 files changed
+80
-64
No files matched your search
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user