-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Formatting and a dummy ws-client to test
- Loading branch information
1 parent
8a8cd32
commit e75dfa5
Showing
6 changed files
with
92 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {el, Renderer, formatRoots} from "./dist/index.js"; | ||
|
||
// Create WebSocket connection. | ||
const socket = new WebSocket("ws://localhost:8080"); | ||
|
||
// Connection opened | ||
socket.addEventListener("open", (event) => { | ||
// Once the connection is opened we generate a new graph every 500ms | ||
setInterval(() => { | ||
let i = 1 + Math.round((Math.random() * 8)); | ||
let f = 110 * i; | ||
|
||
socket.send(JSON.stringify({ | ||
graph: formatRoots([el.cycle(el.const({key: 'a', value: f})), el.cycle(el.const({key: 'b', value: f * 1.01}))]), | ||
})); | ||
}, 500); | ||
}); | ||
|
||
// Listen for messages | ||
socket.addEventListener("message", (event) => { | ||
console.log("Message from server ", event.data); | ||
}); |