|
|
@@ -76,29 +76,35 @@ export default defineNuxtPlugin({
|
|
|
|
|
|
hooks: {
|
|
|
"app:mounted": () => {
|
|
|
- if (LOG_HOOKS) {
|
|
|
- console.log(
|
|
|
- "[app socketio] [app:mounted]",
|
|
|
- import.meta.server ? "server" : "client"
|
|
|
+ return useNuxtApp().runWithContext(() => {
|
|
|
+ const {
|
|
|
+ $socketio: { socket }
|
|
|
+ } = useNuxtApp()
|
|
|
+
|
|
|
+ if (LOG_HOOKS) {
|
|
|
+ console.log(
|
|
|
+ "[app socketio] [app:mounted]",
|
|
|
+ import.meta.server ? "server" : "client"
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ useEventHandlers()
|
|
|
+
|
|
|
+ if (LOG_LISTENERS) {
|
|
|
+ console.log("[listeners]")
|
|
|
+
|
|
|
+ // noinspection JSUnresolvedReference
|
|
|
+ _forIn(socket._callbacks, (callbacks, event) => {
|
|
|
+ console.log(`${event}`, callbacks)
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ // reconnect on signin/signout
|
|
|
+ watch(
|
|
|
+ useAuthClient().isSignedIn,
|
|
|
+ () => socket.disconnect().connect()
|
|
|
)
|
|
|
- }
|
|
|
-
|
|
|
- const {
|
|
|
- $socketio: { socket }
|
|
|
- } = useNuxtApp()
|
|
|
-
|
|
|
- // useEventHandlers()
|
|
|
-
|
|
|
- if (LOG_LISTENERS) {
|
|
|
- console.log("[listeners]")
|
|
|
-
|
|
|
- _forIn(socket._callbacks, (callbacks, event) => {
|
|
|
- console.log(`${event}`, callbacks)
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- // reconnect on signin/signout
|
|
|
- watch(useAuthClient().isSignedIn, () => socket.disconnect().connect())
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
"app:rendered": () => {
|