Here is a list of code from that response with consistent formatting.
```
const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });
wss.on('connection', (ws) => {
    console.log('Client connected');
    ws.on('message', (message) => {
        console.log(Received message: ${message});
        // Broadcast message to all clients
        wss.clients.forEach((client) => {
            if (client.readyState === WebSocket.OPEN) {
                client.send(message);
            }
    });
});
```
```
ws.on('close', () => {
    console.log('Client disconnected');
});
```
```
const socket = new WebSocket('ws://localhost:8080');
socket.addEventListener('open', (event) => {
    console.log('Connected to server');
});
socket.addEventListener('message', (event) => {
    console.log(Received message: ${event.data});
});
socket.addEventListener('close', (event) => {
    console.log('Disconnected from server');
});
```
```
wss.clients.forEach((client) => {
    if (client.readyState === WebSocket.OPEN) {
        client.send('Hello, clients!');
    }
});
```
```socket.send('Hello, server!');```
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence