mirror of
https://git.roussel.pro/telecom-paris/pact.git
synced 2026-02-09 02:20:17 +01:00
14 lines
454 B
JavaScript
14 lines
454 B
JavaScript
class WebsocketClient {
|
|
constructor(onNewEffects) {
|
|
this.socket = new WebSocket("ws://localhost:5000");
|
|
this.socket.addEventListener("open", (event) => {
|
|
this.socket.send("connected");
|
|
});
|
|
this.socket.addEventListener("message", (event) => {
|
|
let msg = JSON.parse(event.data);
|
|
if (msg.type == "effects") {
|
|
onNewEffects(msg.effects);
|
|
}
|
|
});
|
|
}
|
|
} |