Chapter 4: initial recipe samples
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
const WebSocket = require('ws')
|
||||
|
||||
const WebSocketServer = new WebSocket.Server({
|
||||
port: 3000
|
||||
})
|
||||
|
||||
WebSocketServer.on('connection', (socket) => {
|
||||
socket.on('message', (msg) => {
|
||||
console.log('Received:', msg)
|
||||
if (msg === 'Hello') socket.send('World!')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user