Skip to content

Commit

Permalink
[doc] Fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Nov 1, 2021
1 parent 65717f6 commit 5991c35
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ ws.on('open', function open() {
ws.send('something');
});

ws.on('message', function incoming(message) {
console.log('received: %s', message);
ws.on('message', function message(data) {
console.log('received: %s', data);
});
```

Expand Down Expand Up @@ -179,8 +179,8 @@ import { WebSocketServer } from 'ws';
const wss = new WebSocketServer({ port: 8080 });

wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
ws.on('message', function message(data) {
console.log('received: %s', data);
});

ws.send('something');
Expand All @@ -201,8 +201,8 @@ const server = createServer({
const wss = new WebSocketServer({ server });

wss.on('connection', function connection(ws) {
ws.on('message', function incoming(message) {
console.log('received: %s', message);
ws.on('message', function message(data) {
console.log('received: %s', data);
});

ws.send('something');
Expand Down Expand Up @@ -259,14 +259,14 @@ const server = createServer();
const wss = new WebSocketServer({ noServer: true });

wss.on('connection', function connection(ws, request, client) {
ws.on('message', function message(msg) {
console.log(`Received message ${msg} from user ${client}`);
ws.on('message', function message(data) {
console.log(`Received message ${data} from user ${client}`);
});
});

server.on('upgrade', function upgrade(request, socket, head) {
// This function is not defined on purpose. Implement it with your own logic.
authenticate(request, (err, client) => {
authenticate(request, function next(err, client) {
if (err || !client) {
socket.write('HTTP/1.1 401 Unauthorized\r\n\r\n');
socket.destroy();
Expand Down Expand Up @@ -295,7 +295,7 @@ import WebSocket, { WebSocketServer } from 'ws';
const wss = new WebSocketServer({ port: 8080 });

wss.on('connection', function connection(ws) {
ws.on('message', function incoming(data, isBinary) {
ws.on('message', function message(data, isBinary) {
wss.clients.forEach(function each(client) {
if (client.readyState === WebSocket.OPEN) {
client.send(data, { binary: isBinary });
Expand All @@ -314,7 +314,7 @@ import WebSocket, { WebSocketServer } from 'ws';
const wss = new WebSocketServer({ port: 8080 });

wss.on('connection', function connection(ws) {
ws.on('message', function incoming(data, isBinary) {
ws.on('message', function message(data, isBinary) {
wss.clients.forEach(function each(client) {
if (client !== ws && client.readyState === WebSocket.OPEN) {
client.send(data, { binary: isBinary });
Expand Down Expand Up @@ -342,7 +342,7 @@ ws.on('close', function close() {
console.log('disconnected');
});

ws.on('message', function incoming(data) {
ws.on('message', function message(data) {
console.log(`Roundtrip time: ${Date.now() - data} ms`);

setTimeout(function timeout() {
Expand Down

0 comments on commit 5991c35

Please sign in to comment.