mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 05:18:11 +00:00
Unikatowe połączenia z serwerem
This commit is contained in:
+6
-5
@@ -196,7 +196,7 @@ export const useStore = defineStore('store', {
|
||||
|
||||
setStationsOnlineInfo() {
|
||||
const onlineStationNames: string[] = [];
|
||||
const prevDispatcherStatuses: StoreState['lastDispatcherStatuses'] = [];
|
||||
const prevDispatcherStatuses: StoreState['lastDispatcherStatuses'] = [];
|
||||
|
||||
this.apiData.stations?.forEach((stationAPIData) => {
|
||||
if (stationAPIData.region !== this.region.id || !stationAPIData.isOnline) return;
|
||||
@@ -322,7 +322,9 @@ export const useStore = defineStore('store', {
|
||||
|
||||
connectToWebsocket() {
|
||||
const socket = io(
|
||||
process.env.NODE_ENV !== 'production' && process.env.DEV_API == 1 ? URLs.stacjownikAPIDev : URLs.stacjownikAPI,
|
||||
process.env.NODE_ENV !== 'production' && process.env.VUE_APP_WS_DEV == 1
|
||||
? URLs.stacjownikAPIDev
|
||||
: URLs.stacjownikAPI,
|
||||
{
|
||||
transports: ['websocket', 'polling'],
|
||||
rememberUpgrade: true,
|
||||
@@ -333,6 +335,8 @@ export const useStore = defineStore('store', {
|
||||
socket.on('UPDATE', (data: APIData) => {
|
||||
this.apiData = data;
|
||||
|
||||
console.dir(data);
|
||||
|
||||
this.setOnlineData();
|
||||
});
|
||||
|
||||
@@ -367,9 +371,6 @@ export const useStore = defineStore('store', {
|
||||
|
||||
this.setTrainsOnlineData();
|
||||
this.setStationsOnlineInfo();
|
||||
|
||||
console.log("Loading");
|
||||
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -37,10 +37,6 @@ export interface APIData {
|
||||
stations?: StationAPIData[];
|
||||
dispatchers?: string[][];
|
||||
trains?: TrainAPIData[];
|
||||
|
||||
stationsSWDRStatus: string;
|
||||
trainsSWDRStatus: string;
|
||||
dispatchersSWDRStatus: string;
|
||||
}
|
||||
|
||||
export interface StationJSONData {
|
||||
|
||||
Reference in New Issue
Block a user