WebSocket
code:js
const socket = new WebSocket('ws://localhost:8888');
socket.addEventListener('open', (event) => console.log('open', event));
socket.addEventListener('error', (event) => console.log('error', event));
socket.addEventListener('close', (event) => console.log('close', event));
// receive
socket.addEventListener('message', (event) => {
console.log('message', event);
});
// send
socket.send('Hello');
// close
socket.close();