GrandTabernacleAutoVI/server/testsite/app.js
killianmarty 02cc1ed028 server
2023-11-14 17:35:47 +01:00

27 lines
544 B
JavaScript

const socket = new WebSocket('ws://localhost:3000');
socket.addEventListener('open', (event) => {
console.log('connecté');
});
socket.addEventListener('message', (event) => {
console.log(event.data);
});
socket.addEventListener('close', (event) => {
console.log('Connexion au serveur WebSocket fermée');
});
function main(){
socket.send(JSON.stringify({type: "connect"}));
socket.send(JSON.stringify({
type: "update",
data: {
id: 0,
x: 0,
y: 0
}
}))
}