Skip to content

Commit 5991c35

Browse files
committed
[doc] Fix nits
1 parent 65717f6 commit 5991c35

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ ws.on('open', function open() {
148148
ws.send('something');
149149
});
150150

151-
ws.on('message', function incoming(message) {
152-
console.log('received: %s', message);
151+
ws.on('message', function message(data) {
152+
console.log('received: %s', data);
153153
});
154154
```
155155

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

181181
wss.on('connection', function connection(ws) {
182-
ws.on('message', function incoming(message) {
183-
console.log('received: %s', message);
182+
ws.on('message', function message(data) {
183+
console.log('received: %s', data);
184184
});
185185

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

203203
wss.on('connection', function connection(ws) {
204-
ws.on('message', function incoming(message) {
205-
console.log('received: %s', message);
204+
ws.on('message', function message(data) {
205+
console.log('received: %s', data);
206206
});
207207

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

261261
wss.on('connection', function connection(ws, request, client) {
262-
ws.on('message', function message(msg) {
263-
console.log(`Received message ${msg} from user ${client}`);
262+
ws.on('message', function message(data) {
263+
console.log(`Received message ${data} from user ${client}`);
264264
});
265265
});
266266

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

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

316316
wss.on('connection', function connection(ws) {
317-
ws.on('message', function incoming(data, isBinary) {
317+
ws.on('message', function message(data, isBinary) {
318318
wss.clients.forEach(function each(client) {
319319
if (client !== ws && client.readyState === WebSocket.OPEN) {
320320
client.send(data, { binary: isBinary });
@@ -342,7 +342,7 @@ ws.on('close', function close() {
342342
console.log('disconnected');
343343
});
344344

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

348348
setTimeout(function timeout() {

0 commit comments

Comments
 (0)