This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
import goStore, { setReady, oauth2_register_discord, setup_websocket } from "@/netcode";
|
import goStore, { setReady, oauth2_register_discord, setup_websocket, heron_cookie_login } from "@/netcode";
|
||||||
|
|
||||||
await setup_websocket()
|
await setup_websocket()
|
||||||
|
|
||||||
|
const heron_session = useCookie('heron_session')
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
@@ -20,6 +21,10 @@ onMounted(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if (!heron_session.value) { return }
|
||||||
|
heron_cookie_login(heron_session.value)
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
+14
-1
@@ -105,6 +105,7 @@ export const setup_websocket = () =>
|
|||||||
return resolve();
|
return resolve();
|
||||||
}
|
}
|
||||||
const config = useRuntimeConfig();
|
const config = useRuntimeConfig();
|
||||||
|
const heron_session = useCookie('heron_session')
|
||||||
socket = new WebSocket(config.public.websocketEndpoint);
|
socket = new WebSocket(config.public.websocketEndpoint);
|
||||||
|
|
||||||
socket.onopen = function (e) {
|
socket.onopen = function (e) {
|
||||||
@@ -151,14 +152,26 @@ export const setup_websocket = () =>
|
|||||||
goStore.set_self(data.data);
|
goStore.set_self(data.data);
|
||||||
} else if (data.data_type == "current_game"){
|
} else if (data.data_type == "current_game"){
|
||||||
goStore.set_current_game(data.data)
|
goStore.set_current_game(data.data)
|
||||||
|
} else if (data.data_type == "session_cookie"){
|
||||||
|
heron_session.value = data.data
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// console.log(data.type, data.data_type, data.data);
|
// console.log(data.type, data.data_type, data.data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export async function heron_cookie_login(cookie:string){
|
||||||
|
await setup_websocket();
|
||||||
|
socket.send(
|
||||||
|
JSON.stringify({
|
||||||
|
type: "cookie_login",
|
||||||
|
data_type: "cookie",
|
||||||
|
data: cookie,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export async function oauth2_register_discord(code: string) {
|
export async function oauth2_register_discord(code: string) {
|
||||||
await setup_websocket();
|
await setup_websocket();
|
||||||
socket.send(
|
socket.send(
|
||||||
|
|||||||
Reference in New Issue
Block a user