@@ -148,8 +148,8 @@ ws.on('open', function open() {
148
148
ws .send (' something' );
149
149
});
150
150
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 );
153
153
});
154
154
```
155
155
@@ -179,8 +179,8 @@ import { WebSocketServer } from 'ws';
179
179
const wss = new WebSocketServer ({ port: 8080 });
180
180
181
181
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 );
184
184
});
185
185
186
186
ws .send (' something' );
@@ -201,8 +201,8 @@ const server = createServer({
201
201
const wss = new WebSocketServer ({ server });
202
202
203
203
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 );
206
206
});
207
207
208
208
ws .send (' something' );
@@ -259,14 +259,14 @@ const server = createServer();
259
259
const wss = new WebSocketServer ({ noServer: true });
260
260
261
261
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} ` );
264
264
});
265
265
});
266
266
267
267
server .on (' upgrade' , function upgrade (request , socket , head ) {
268
268
// 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 ) {
270
270
if (err || ! client) {
271
271
socket .write (' HTTP/1.1 401 Unauthorized\r\n\r\n ' );
272
272
socket .destroy ();
@@ -295,7 +295,7 @@ import WebSocket, { WebSocketServer } from 'ws';
295
295
const wss = new WebSocketServer ({ port: 8080 });
296
296
297
297
wss .on (' connection' , function connection (ws ) {
298
- ws .on (' message' , function incoming (data , isBinary ) {
298
+ ws .on (' message' , function message (data , isBinary ) {
299
299
wss .clients .forEach (function each (client ) {
300
300
if (client .readyState === WebSocket .OPEN ) {
301
301
client .send (data, { binary: isBinary });
@@ -314,7 +314,7 @@ import WebSocket, { WebSocketServer } from 'ws';
314
314
const wss = new WebSocketServer ({ port: 8080 });
315
315
316
316
wss .on (' connection' , function connection (ws ) {
317
- ws .on (' message' , function incoming (data , isBinary ) {
317
+ ws .on (' message' , function message (data , isBinary ) {
318
318
wss .clients .forEach (function each (client ) {
319
319
if (client !== ws && client .readyState === WebSocket .OPEN ) {
320
320
client .send (data, { binary: isBinary });
@@ -342,7 +342,7 @@ ws.on('close', function close() {
342
342
console .log (' disconnected' );
343
343
});
344
344
345
- ws .on (' message' , function incoming (data ) {
345
+ ws .on (' message' , function message (data ) {
346
346
console .log (` Roundtrip time: ${ Date .now () - data} ms` );
347
347
348
348
setTimeout (function timeout () {
0 commit comments