wew
This commit is contained in:
@ -3,11 +3,12 @@ import Map from '@/engine/Map/Map'
|
||||
|
||||
export const useMapStore = defineStore('map', {
|
||||
state: () => ({
|
||||
map: null as Map | null,
|
||||
map: null as any | null,
|
||||
}),
|
||||
|
||||
actions: {
|
||||
setMap(map: Map) {
|
||||
setMap(map: any) {
|
||||
console.log('Setting map:', map);
|
||||
this.map = map;
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,10 @@ import { defineStore } from 'pinia';
|
||||
import { io, Socket } from 'socket.io-client';
|
||||
import config from '@/config';
|
||||
import axios from 'axios';
|
||||
import { useMapStore } from '@/stores/map';
|
||||
|
||||
|
||||
|
||||
|
||||
export const useSocketStore = defineStore('socket', {
|
||||
state: () => ({
|
||||
@ -59,7 +63,6 @@ export const useSocketStore = defineStore('socket', {
|
||||
this.socket.on('message', (message) => {
|
||||
console.log('Received message:', message);
|
||||
});
|
||||
|
||||
// Handle more socket events as needed
|
||||
},
|
||||
|
||||
@ -68,6 +71,17 @@ export const useSocketStore = defineStore('socket', {
|
||||
this.socket.disconnect();
|
||||
this.socket = null;
|
||||
}
|
||||
},
|
||||
|
||||
getMap() {
|
||||
if (this.socket) {
|
||||
this.socket.emit('get_map');
|
||||
this.socket.on('map', (map) => {
|
||||
const mapStore = useMapStore();
|
||||
// Get map from server
|
||||
mapStore.setMap(map);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Reference in New Issue
Block a user