Skip to content

Commit 11a3a05

Browse files
refactor: code
1 parent 6bd5919 commit 11a3a05

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

lib/servers/SockJSServer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module.exports = class SockJSServer extends BaseServer {
3434
constructor(server) {
3535
super(server);
3636

37-
this.socket = sockjs.createServer({
37+
this.implementation = sockjs.createServer({
3838
// Use provided up-to-date sockjs-client
3939
sockjs_url: '/__webpack_dev_server__/sockjs.bundle.js',
4040
// Default logger is very annoy. Limit useless logs.
@@ -57,7 +57,7 @@ module.exports = class SockJSServer extends BaseServer {
5757
return options.path;
5858
};
5959

60-
this.socket.installHandlers(this.server.server, {
60+
this.implementation.installHandlers(this.server.server, {
6161
...this.server.options.webSocketServer.options,
6262
prefix: getPrefix(this.server.options.webSocketServer.options),
6363
});
@@ -78,7 +78,7 @@ module.exports = class SockJSServer extends BaseServer {
7878

7979
// f should be passed the resulting connection and the connection headers
8080
onConnection(f) {
81-
this.socket.on('connection', (connection) => {
81+
this.implementation.on('connection', (connection) => {
8282
f(connection, connection ? connection.headers : null);
8383
});
8484
}

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.webSocketServer = new ws.Server({
13+
this.implementation = new ws.Server({
1414
...this.server.options.webSocketServer.options,
1515
noServer: true,
1616
});
1717

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

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

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

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

3434
setInterval(() => {
35-
this.webSocketServer.clients.forEach((socket) => {
35+
this.implementation.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.webSocketServer.on('connection', (connection, req) => {
61+
this.implementation.on('connection', (connection, req) => {
6262
connection.isAlive = true;
6363
connection.on('pong', () => {
6464
connection.isAlive = true;

0 commit comments

Comments
 (0)