2019-05-31 15:56:07 +00:00
|
|
|
/**
|
|
|
|
|
* @license
|
2020-05-19 19:08:49 +00:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2019-05-31 15:56:07 +00:00
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
|
*/
|
|
|
|
|
|
2023-12-10 15:42:09 +00:00
|
|
|
const {WebSocketServer} = require('ws');
|
2019-05-31 15:56:07 +00:00
|
|
|
|
|
|
|
|
// simple echo server
|
2023-12-10 15:42:09 +00:00
|
|
|
const wss = new WebSocketServer({port: 8001});
|
|
|
|
|
wss.on('connection', (ws) => {ws.on('message', (data) => {
|
|
|
|
|
if (data.toString() === 'close') {
|
|
|
|
|
wss.close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
ws.send(data);
|
|
|
|
|
})});
|