Skip to content

Commit 4114196

Browse files
committed
Update examples
1 parent 2af7c38 commit 4114196

File tree

20 files changed

+164
-244
lines changed

20 files changed

+164
-244
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
examples

examples/.eslintrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"rules": {
3+
"no-console": 0
4+
}
5+
}

examples/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock.json

examples/echo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!doctype html>
22
<html><head>
33
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
4-
<script src="http://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js"></script>
4+
<script src="http://cdn.jsdelivr.net/sockjs/1/sockjs.min.js"></script>
55
<style>
66
.box {
77
width: 300px;

examples/echo/package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
{
2-
"name": "sockjs-echo",
3-
"version": "0.0.0-unreleasable",
4-
"dependencies": {
5-
"node-static": "0.5.9",
6-
"sockjs": "*"
7-
}
2+
"name": "sockjs-echo",
3+
"version": "0.0.1",
4+
"dependencies": {
5+
"node-static": "^0.7.11",
6+
"sockjs": "^0.4.0"
7+
},
8+
"private": true
89
}

examples/echo/server.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
1-
var http = require('http');
2-
var sockjs = require('sockjs');
3-
var node_static = require('node-static');
1+
'use strict';
2+
3+
const http = require('http');
4+
const sockjs = require('sockjs');
5+
const node_static = require('node-static');
46

57
// 1. Echo sockjs server
6-
var sockjs_opts = {sockjs_url: "http://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js"};
8+
const sockjs_opts = {
9+
prefix: '/echo',
10+
sockjs_url: 'http://cdn.jsdelivr.net/sockjs/1/sockjs.min.js'
11+
};
712

8-
var sockjs_echo = sockjs.createServer(sockjs_opts);
13+
const sockjs_echo = sockjs.createServer(sockjs_opts);
914
sockjs_echo.on('connection', function(conn) {
10-
conn.on('data', function(message) {
11-
conn.write(message);
12-
});
15+
conn.on('data', function(message) {
16+
conn.write(message);
17+
});
1318
});
1419

1520
// 2. Static files server
16-
var static_directory = new node_static.Server(__dirname);
21+
const static_directory = new node_static.Server(__dirname);
1722

1823
// 3. Usual http stuff
19-
var server = http.createServer();
24+
const server = http.createServer();
2025
server.addListener('request', function(req, res) {
21-
static_directory.serve(req, res);
26+
static_directory.serve(req, res);
2227
});
2328
server.addListener('upgrade', function(req,res){
24-
res.end();
29+
res.end();
2530
});
2631

27-
sockjs_echo.installHandlers(server, {prefix:'/echo'});
32+
sockjs_echo.attach(server);
2833

2934
console.log(' [*] Listening on 0.0.0.0:9999' );
3035
server.listen(9999, '0.0.0.0');

examples/express-3.x/index.html

Lines changed: 0 additions & 71 deletions
This file was deleted.

examples/express-3.x/package.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

examples/express-3.x/server.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

examples/express/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!doctype html>
22
<html><head>
33
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
4-
<script src="http://cdn.jsdelivr.net/sockjs/1.0.1/sockjs.min.js"></script>
4+
<script src="http://cdn.jsdelivr.net/sockjs/1/sockjs.min.js"></script>
55
<style>
66
.box {
77
width: 300px;

0 commit comments

Comments
 (0)