aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/__layout.svelte
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-07-25 21:32:44 -0700
committerAdam Soltys <[email protected]>2022-07-25 21:32:44 -0700
commit482df6b7ac12636221a898513ef944205617167d (patch)
treeeb728a7326c998e9e8162f31906f72d326f30c49 /src/routes/__layout.svelte
parent11c7b181e2af1359d031f66736f0e90eeb1fab08 (diff)
downloadcoinos-ui-482df6b7ac12636221a898513ef944205617167d.tar.gz
coinos-ui-482df6b7ac12636221a898513ef944205617167d.zip
invoice endpoint
Diffstat (limited to 'src/routes/__layout.svelte')
-rw-r--r--src/routes/__layout.svelte19
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 />