Skip to content

Commit 18be4a5

Browse files
author
Jonas Pfenniger
committed
[examples] Fixing things up, more debug
1 parent ac6acd4 commit 18be4a5

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

example/ping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function ping(msg, conn) {
1919
function handler(req, res) {
2020
sys.debug(req.method + ' ' + req.uri.path);
2121
if (ws.askUpgrade(req)) {
22-
sys.debug("Upgrading to WebSocket");
22+
sys.debug("Upgrading to WebSocket " + req.headers.cookie);
2323
var conn = new ws.Connection(req, res);
2424
conn.addListener("message", ping);
2525
conn.addListener("close", function() {

example/public/sample.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@
2626
ws = new WebSocket("ws://localhost:8000/echo");
2727

2828
// Set event handlers.
29-
ws.onopen = function() {
29+
ws.onopen = function(e) {
30+
if (console) console.log("open", e);
3031
output("onopen");
3132
};
3233
ws.onmessage = function(e) {
34+
if (console) console.log("message", e);
3335
// e.data contains received string.
3436
output("onmessage: " + e.data);
3537
};
36-
ws.onclose = function() {
38+
ws.onclose = function(e) {
39+
if (console) console.log("open", e);
3740
output("onclose");
3841
};
3942

example/shared.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const mimeMap = {
1313
function notFound(req, res) {
1414
var msg = "<h1>File not found : " + req.uri.path + "</h1>";
1515
res.sendHeader(404, {
16-
"Content-Type": "text/html",
17-
"Content-Length": msg.length
16+
"Content-Type": "text/html",
17+
"Content-Length": msg.length
1818
});
1919
res.sendBody(msg);
2020
res.finish();
@@ -24,8 +24,8 @@ function sendFile(req, res, path) {
2424
posix.cat(path, "binary").addCallback(function(data) {
2525
var cType = mimeMap[mimeReg.exec(path)[0]] || "application/octet-stream";
2626
res.sendHeader(200, {
27-
"Content-Length": data.length,
28-
"Content-Type": cType
27+
"Content-Type": cType,
28+
"Content-Length": data.length
2929
});
3030
res.sendBody(data, "binary");
3131
res.finish();

0 commit comments

Comments
 (0)