commit
0d8b61d359
@ -0,0 +1 @@ |
||||
server/node_modules |
@ -0,0 +1,20 @@ |
||||
<html> |
||||
<head> |
||||
<title>Egg Count Editor</title> |
||||
</head> |
||||
<body> |
||||
<input type="text" id="amount" value="0" /> |
||||
<button id="send"> |
||||
Send |
||||
</button> |
||||
|
||||
<script type="text/javascript"> |
||||
const amount = document.querySelector('#amount') |
||||
const button = document.querySelector('#send') |
||||
const socket = new WebSocket('ws://10.0.1.11:8080') |
||||
button.addEventListener('click', () => { |
||||
socket.send(amount.value) |
||||
}) |
||||
</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,51 @@ |
||||
<html> |
||||
<head> |
||||
<title>Egg Count</title> |
||||
|
||||
<style> |
||||
body, html { |
||||
background-color: transparent; |
||||
margin: 0; |
||||
padding: 0; |
||||
} |
||||
|
||||
.container { |
||||
height: 185px; |
||||
position: relative; |
||||
width: 128px; |
||||
} |
||||
|
||||
.egg, .count { |
||||
height: 100%; |
||||
left: 0; |
||||
position: absolute; |
||||
text-align: center; |
||||
top: 0; |
||||
width: 100%; |
||||
} |
||||
|
||||
.count { |
||||
font-size: 64px; |
||||
padding: 16px 0 0; |
||||
} |
||||
</style> |
||||
</head> |
||||
<body> |
||||
<div class="container"> |
||||
<div class="egg"> |
||||
<img src="./1f95a.svg" height="128" /> |
||||
</div> |
||||
<div class="count" id="count"> |
||||
0 |
||||
</div> |
||||
</div> |
||||
|
||||
<script type="text/javascript"> |
||||
const count = document.querySelector('#count') |
||||
const socket = new WebSocket('ws://10.0.1.11:8080') |
||||
socket.onmessage = (event) => { |
||||
count.innerHTML = event.data |
||||
} |
||||
</script> |
||||
</body> |
||||
</html> |
@ -0,0 +1,10 @@ |
||||
const WebSocket = require('ws') |
||||
const server = new WebSocket.Server({ |
||||
port: 8080 |
||||
}) |
||||
|
||||
server.on('connection', (socket) => { |
||||
socket.on('message', function(message) { |
||||
server.clients.forEach((client) => client.send(message)) |
||||
}) |
||||
}) |
@ -0,0 +1,13 @@ |
||||
{ |
||||
"name": "server", |
||||
"version": "1.0.0", |
||||
"lockfileVersion": 1, |
||||
"requires": true, |
||||
"dependencies": { |
||||
"ws": { |
||||
"version": "7.4.0", |
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.4.0.tgz", |
||||
"integrity": "sha512-kyFwXuV/5ymf+IXhS6f0+eAFvydbaBW3zjpT6hUdAh/hbVjTIB5EHBGi0bPoCLSK2wcuz3BrEkB9LrYv1Nm4NQ==" |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,14 @@ |
||||
{ |
||||
"name": "server", |
||||
"version": "1.0.0", |
||||
"description": "", |
||||
"main": "app.js", |
||||
"scripts": { |
||||
"test": "echo \"Error: no test specified\" && exit 1" |
||||
}, |
||||
"author": "", |
||||
"license": "ISC", |
||||
"dependencies": { |
||||
"ws": "^7.4.0" |
||||
} |
||||
} |
Loading…
Reference in new issue