From e45a9eb20c36b1787b209e9447ba3aaabf552520 Mon Sep 17 00:00:00 2001 From: William Bruno Date: Thu, 12 Mar 2026 21:36:41 -0400 Subject: [PATCH] debug --- quasar.config.ts | 25 +++++++--------------- src/boot/socket.ts | 39 ++++++++++++++++++++++++++++------ src/components/LeafletTest.vue | 3 ++- 3 files changed, 43 insertions(+), 24 deletions(-) diff --git a/quasar.config.ts b/quasar.config.ts index a0c2925..228e865 100644 --- a/quasar.config.ts +++ b/quasar.config.ts @@ -11,10 +11,7 @@ export default defineConfig((/* ctx */) => { // app boot file (/src/boot) // --> boot files are part of "main.js" // https://v2.quasar.dev/quasar-cli-vite/boot-files - boot: [ - 'axios', - 'socket', - ], + boot: ['axios', 'socket'], // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#css css: ['app.scss'], @@ -65,13 +62,10 @@ export default defineConfig((/* ctx */) => { // extendViteConf (viteConf) {}, // viteVuePluginOptions: {}, - extendViteConf () { + extendViteConf() { return { server: { - allowedHosts: [ - 'localhost', - 'strixx.famor.org', - ], + allowedHosts: ['localhost'], }, }; }, @@ -95,21 +89,21 @@ export default defineConfig((/* ctx */) => { devServer: { // https: true, open: false, // opens browser window automatically - public: 'http://strixx.famor.org:9000', + // public: 'http://strixx.famor.org:9000', proxy: { // proxy all requests starting with /api to jsonplaceholder '/api': { target: 'http://localhost:8000', changeOrigin: true, - }, + }, '/socket.io': { target: 'http://localhost:8000', // Your backend WebSocket server secure: false, // Set to true if using wss:// ws: true, // Enable WebSocket proxying rewriteWsOrigin: true, changeOrigin: true, -// rewrite: (path) => path.replace(/^\/socket.io/, ''), - } + // rewrite: (path) => path.replace(/^\/socket.io/, ''), + }, }, }, @@ -129,10 +123,7 @@ export default defineConfig((/* ctx */) => { // directives: [], // Quasar plugins - plugins: [ - 'Dialog', - 'Notify', - ], + plugins: ['Dialog', 'Notify'], }, // animations: 'all', // --- includes all animations // https://v2.quasar.dev/options/animations diff --git a/src/boot/socket.ts b/src/boot/socket.ts index 047099c..b460875 100644 --- a/src/boot/socket.ts +++ b/src/boot/socket.ts @@ -3,29 +3,56 @@ import type { Socket } from 'socket.io-client'; import { io } from 'socket.io-client'; import type { StatusUpdate } from 'src/types'; +interface SimulationStatus { + status: boolean; + data: { + latitude: number; + longitude: number; + start: string; + end?: string; + next_move?: number; + }; +} + +interface SimulationRequest { + latitude: number; + longitude: number; + delay?: number; + start?: string; + end?: string; +} + interface ServerToClientEvents { noArg: () => void; - basicEmit: (a: number, b: string, c: Buffer) => void; withAck: (d: string, callback: (e: number) => void) => void; status_update: (d: StatusUpdate) => void; + simulation: (d: SimulationStatus) => void; } interface ClientToServerEvents { message: (data: string) => void; connect: () => void; disconnect: () => void; - set_location: (latitude: number, longitude: number, callback: (response: { success: boolean; data: { latitude: number; longitude: number }; message?: string }) => void) => void; + set_location: (data: SimulationRequest, callback: (response: SimulationStatus) => void) => void; request_update: (callback: (response: { statusUpdate: StatusUpdate }) => void) => void; - command: (command: string, callback: (response: { success: boolean; message?: string }) => void ) => void; - shutdown: (delay: number, callback: (response: { success: boolean; message?: string }) => void) => void; + command: ( + command: string, + callback: (response: { success: boolean; message?: string }) => void, + ) => void; + shutdown: ( + delay: number, + callback: (response: { success: boolean; message?: string }) => void, + ) => void; // ... other events } -const socket: Socket = io(); +const socket: Socket = io('/', { + autoConnect: true, + transports: ['websocket'], +}); export default defineBoot(({ app }) => { app.config.globalProperties.$socket = socket; }); export { socket }; - \ No newline at end of file diff --git a/src/components/LeafletTest.vue b/src/components/LeafletTest.vue index e2e318f..bd6c201 100644 --- a/src/components/LeafletTest.vue +++ b/src/components/LeafletTest.vue @@ -42,7 +42,8 @@