Skip to content

Commit 3e031ee

Browse files
authored
refactor: rename wsServer to webSocketServer (#3291)
1 parent ebb9254 commit 3e031ee

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lib/servers/WebsocketServer.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,29 @@ module.exports = class WebsocketServer extends BaseServer {
1010
constructor(server) {
1111
super(server);
1212

13-
this.wsServer = new ws.Server({
13+
this.webSocketServer = new ws.Server({
1414
noServer: true,
1515
path: this.server.options.client.path,
1616
});
1717

1818
this.server.server.on('upgrade', (req, sock, head) => {
19-
if (!this.wsServer.shouldHandle(req)) {
19+
if (!this.webSocketServer.shouldHandle(req)) {
2020
return;
2121
}
2222

23-
this.wsServer.handleUpgrade(req, sock, head, (connection) => {
24-
this.wsServer.emit('connection', connection, req);
23+
this.webSocketServer.handleUpgrade(req, sock, head, (connection) => {
24+
this.webSocketServer.emit('connection', connection, req);
2525
});
2626
});
2727

28-
this.wsServer.on('error', (err) => {
28+
this.webSocketServer.on('error', (err) => {
2929
this.server.logger.error(err.message);
3030
});
3131

3232
const noop = () => {};
3333

3434
setInterval(() => {
35-
this.wsServer.clients.forEach((socket) => {
35+
this.webSocketServer.clients.forEach((socket) => {
3636
if (socket.isAlive === false) {
3737
return socket.terminate();
3838
}
@@ -58,7 +58,7 @@ module.exports = class WebsocketServer extends BaseServer {
5858

5959
// f should be passed the resulting connection and the connection headers
6060
onConnection(f) {
61-
this.wsServer.on('connection', (connection, req) => {
61+
this.webSocketServer.on('connection', (connection, req) => {
6262
connection.isAlive = true;
6363
connection.on('pong', () => {
6464
connection.isAlive = true;

test/server/proxy-option.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ describe('proxy option', () => {
301301

302302
describe('should handles external websocket upgrade', () => {
303303
let ws;
304-
let wsServer;
304+
let webSocketServer;
305305
let responseMessage;
306306

307307
const transportModes = ['sockjs', 'ws'];
@@ -329,8 +329,8 @@ describe('proxy option', () => {
329329
done
330330
);
331331

332-
wsServer = new WebSocketServer({ port: port4 });
333-
wsServer.on('connection', (server) => {
332+
webSocketServer = new WebSocketServer({ port: port4 });
333+
webSocketServer.on('connection', (server) => {
334334
server.on('message', (message) => {
335335
server.send(message);
336336
});
@@ -353,7 +353,7 @@ describe('proxy option', () => {
353353
});
354354

355355
afterAll((done) => {
356-
wsServer.close();
356+
webSocketServer.close();
357357
testServer.close(done);
358358
});
359359
});

0 commit comments

Comments
 (0)