8000 Simplify examples · sockjs/sockjs-node@e2369c3 · GitHub
[go: up one dir, main page]

Skip to content

Commit e2369c3

Browse files
committed
Simplify examples
1 parent dc5a3d9 commit e2369c3

File tree

6 files changed

+11
-22
lines changed

6 files changed

+11
-22
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ A simplified echo SockJS server could look more or less like:
5050
const http = require('http');
5151
const sockjs = require('sockjs');
5252

53-
const echo = sockjs.createServer({ prefix:'/echo', sockjs_url: 'https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js' });
53+
const echo = sockjs.createServer({ prefix:'/echo' });
5454
echo.on('connection', function(conn) {
5555
conn.on('data', function(message) {
5656
conn.write(message);

examples/echo/server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ const node_static = require('node-static');
66

77
// 1. Echo sockjs server
88
const sockjs_opts = {
9-
prefix: '/echo',
10-
sockjs_url: 'https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js'
9+
prefix: '/echo'
1110
};
1211

1312
const sockjs_echo = sockjs.createServer(sockjs_opts);

examples/express/server.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,20 @@
11
'use strict';
22

3-
const express = require('express');
43
const http = require('http');
4+
const express = require('express');
55
const sockjs = require('sockjs');
66

7-
// 1. Echo sockjs server
87
const sockjs_opts = {
9-
prefix: '/echo',
10-
sockjs_url: 'https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js'
8+
prefix: '/echo'
119
};
1210

13-
var sockjs_echo = sockjs.createServer(sockjs_opts);
14-
sockjs_echo.on('connection', function(conn) {
15-
conn.on('data', function(message) {
16-
conn.write(message);
17-
});
11+
const sockjs_echo = sockjs.createServer(sockjs_opts);
12+
sockjs_echo.on('connection', conn => {
13+
conn.on('data', msg => conn.write(msg));
1814
});
1915

20-
// 2. Express server
2116
const app = express();
22-
app.get('/', function(req, res) {
23-
res.sendFile(__dirname + '/index.html');
24-
});
17+
app.get('/', (req, res) => res.sendFile(__dirname + '/index.html'));
2518

2619
const server = http.createServer(app);
2720
sockjs_echo.attach(server);

examples/hapi/server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ const Inert = require('inert');
66

77
// 1. Echo sockjs server
88
const sockjs_opts = {
9-
prefix: '/echo',
10-
sockjs_url: 'https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js'
9+
prefix: '/echo'
1110
};
1211

1312
const sockjs_echo = sockjs.createServer(sockjs_opts);

examples/koa/server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ const path = require('path');
88

99
// 1. Echo sockjs server
1010
const sockjs_opts = {
11-
prefix: '/echo',
12-
sockjs_url: 'https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js'
11+
prefix: '/echo'
1312
};
1413
const sockjs_echo = sockjs.createServer(sockjs_opts);
1514
sockjs_echo.on('connection', function(conn) {

examples/multiplex/server.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ const websocket_multiplex = require('websocket-multiplex');
77

88
// 1. Setup SockJS server
99
const sockjs_opts = {
10-
prefix: '/multiplex',
11-
sockjs_url: 'https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js'
10+
prefix: '/multiplex'
1211
};
1312
const service = sockjs.createServer(sockjs_opts);
1413

0 commit comments

Comments
 (0)
0