Skip to content

Commit

Permalink
Simplify examples
Browse files Browse the repository at this point in the history
  • Loading branch information
brycekahle committed Oct 3, 2018
1 parent dc5a3d9 commit e2369c3
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 22 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ A simplified echo SockJS server could look more or less like:
const http = require('http');
const sockjs = require('sockjs');

const echo = sockjs.createServer({ prefix:'/echo', sockjs_url: 'https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js' });
const echo = sockjs.createServer({ prefix:'/echo' });
echo.on('connection', function(conn) {
conn.on('data', function(message) {
conn.write(message);
Expand Down
3 changes: 1 addition & 2 deletions examples/echo/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const node_static = require('node-static');

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

const sockjs_echo = sockjs.createServer(sockjs_opts);
Expand Down
19 changes: 6 additions & 13 deletions examples/express/server.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
'use strict';

const express = require('express');
const http = require('http');
const express = require('express');
const sockjs = require('sockjs');

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

var sockjs_echo = sockjs.createServer(sockjs_opts);
sockjs_echo.on('connection', function(conn) {
conn.on('data', function(message) {
conn.write(message);
});
const sockjs_echo = sockjs.createServer(sockjs_opts);
sockjs_echo.on('connection', conn => {
conn.on('data', msg => conn.write(msg));
});

// 2. Express server
const app = express();
app.get('/', function(req, res) {
res.sendFile(__dirname + '/index.html');
});
app.get('/', (req, res) => res.sendFile(__dirname + '/index.html'));

const server = http.createServer(app);
sockjs_echo.attach(server);
Expand Down
3 changes: 1 addition & 2 deletions examples/hapi/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ const Inert = require('inert');

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

const sockjs_echo = sockjs.createServer(sockjs_opts);
Expand Down
3 changes: 1 addition & 2 deletions examples/koa/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ const path = require('path');

// 1. Echo sockjs server
const sockjs_opts = {
prefix: '/echo',
sockjs_url: 'https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js'
prefix: '/echo'
};
const sockjs_echo = sockjs.createServer(sockjs_opts);
sockjs_echo.on('connection', function(conn) {
Expand Down
3 changes: 1 addition & 2 deletions examples/multiplex/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ const websocket_multiplex = require('websocket-multiplex');

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

Expand Down

0 comments on commit e2369c3

Please sign in to comment.