diff options
| author | Adam Soltys <[email protected]> | 2022-07-25 21:32:44 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-07-25 21:32:44 -0700 |
| commit | eb9a9c048ebcda09df0ba31745b9d9a5b543596f (patch) | |
| tree | 4f6e01f85f8b442b6688638a17194d3ff7118c1f /src/routes/__layout.svelte | |
| parent | 5640d62d160cb6e00289db28d7ff25b6881db71d (diff) | |
| download | coinos-ui-eb9a9c048ebcda09df0ba31745b9d9a5b543596f.tar.gz coinos-ui-eb9a9c048ebcda09df0ba31745b9d9a5b543596f.zip | |
invoice endpoint
Diffstat (limited to 'src/routes/__layout.svelte')
| -rw-r--r-- | src/routes/__layout.svelte | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/routes/__layout.svelte b/src/routes/__layout.svelte index 2e511e00..0168bb7c 100644 --- a/src/routes/__layout.svelte +++ b/src/routes/__layout.svelte @@ -1,5 +1,24 @@ <script> import '../app.css'; + import { onMount } from 'svelte'; + import { rate, ws } from "$lib/store"; + import { messages } from "$lib/socket"; + + let token = + 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6ImJvYiIsImlhdCI6MTY1ODc5NDkxMX0._zFTEADrbLffcXa5sIMrJtJ483VdIiYmsdt2ofibxu4'; + + onMount(async () => { + $ws = new WebSocket(`ws://localhost:3119/ws`); + + $ws.onmessage = (msg) => { + let { type, data } = JSON.parse(msg.data); + messages(data)[type] && messages(data)[type](); + }; + + $ws.onopen = () => { + ws.send(JSON.stringify({ type: 'login', data: token })); + }; + }); </script> <slot /> |
