Skip to content

Commit

Permalink
fix(#193): set up message event listener before open
Browse files Browse the repository at this point in the history
  • Loading branch information
jannis-baum committed Dec 16, 2024
1 parent 5d07d16 commit 7abb2a5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions static/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ function viv_scrollTo(value) {

const ws = new WebSocket(`ws://localhost:${window.VIV_PORT}`);

ws.addEventListener('open', () => {
ws.send(`PATH: ${window.VIV_PATH}`);
});

ws.addEventListener('message', (event) => {
const fields = event.data.toString().split(': ');
if (fields.length < 2) return;
Expand All @@ -40,3 +36,7 @@ ws.addEventListener('message', (event) => {
break;
}
});

ws.addEventListener('open', () => {
ws.send(`PATH: ${window.VIV_PATH}`);
});

0 comments on commit 7abb2a5

Please sign in to comment.