Chapter 4: initial recipe samples

This commit is contained in:
Beth Griggs
2020-04-29 22:00:34 +01:00
parent 503edc4ec2
commit bcf782f7dc
59 changed files with 471 additions and 655 deletions
+12
View File
@@ -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!')
})
})