mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
Poprawiono error handling socketów
This commit is contained in:
@@ -204,10 +204,18 @@ export default defineComponent({
|
||||
deep: true,
|
||||
|
||||
handler(statuses: StoreState['dataStatuses']) {
|
||||
const connectionStatus = statuses.connection;
|
||||
const sceneryDataStatus = statuses.sceneries;
|
||||
const trainsDataStatus = statuses.trains;
|
||||
const dispatcherDataStatus = statuses.dispatchers;
|
||||
|
||||
if (connectionStatus == DataStatus.Error) {
|
||||
this.setSignalStatus(connectionStatus);
|
||||
this.indicator.status = connectionStatus;
|
||||
this.indicator.message = 'data-status.S1a-connection';
|
||||
return;
|
||||
}
|
||||
|
||||
if (sceneryDataStatus == DataStatus.Error) {
|
||||
this.setSignalStatus(sceneryDataStatus);
|
||||
this.indicator.status = sceneryDataStatus;
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
"migration-confirm": "Roger that!"
|
||||
},
|
||||
"data-status": {
|
||||
"S1a-connection": "<b>S1a signal</b> <br> Cannot connect with SWDR API service!",
|
||||
"S1a-connection": "<b>S1a signal</b> <br> Cannot connect with Stacjownik API service!",
|
||||
"S1a-sceneries": "<b>S1a signal</b> <br> Cannot load online stations data!",
|
||||
"S2": "<b>S2 signal</b> <br> All data loaded successfully!",
|
||||
"S3": "<b>S3 signal</b> <br> Loading data...",
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
},
|
||||
|
||||
"data-status": {
|
||||
"S1a-connection": "<b>Sygnał S1a</b> <br> Błąd podczas próby połączenia się z serwisem SWDR!",
|
||||
"S1a-connection": "<b>Sygnał S1a</b> <br> Błąd podczas próby połączenia się z API Stacjownika!",
|
||||
"S1a-sceneries": "<b>Sygnał S1a</b> <br> Błąd podczas pobierania danych o sceneriach online!",
|
||||
"S2": "<b>Sygnał S2</b> <br> Pomyślnie załadowano dane!",
|
||||
"S3": "<b>Sygnał S3</b> <br> Pobieranie danych...",
|
||||
|
||||
@@ -334,6 +334,12 @@ export const useStore = defineStore('store', {
|
||||
transports: ['websocket', 'polling'],
|
||||
rememberUpgrade: true,
|
||||
reconnection: true,
|
||||
timeout: 10000
|
||||
});
|
||||
|
||||
socket.on('connect_error', (err) => {
|
||||
this.dataStatuses.connection = DataStatus.Error;
|
||||
this.webSocket = undefined;
|
||||
});
|
||||
|
||||
socket.on('UPDATE', (data: APIData) => {
|
||||
@@ -347,6 +353,7 @@ export const useStore = defineStore('store', {
|
||||
});
|
||||
|
||||
this.webSocket = socket;
|
||||
this.dataStatuses.connection = DataStatus.Loaded;
|
||||
},
|
||||
|
||||
async connectToAPI() {
|
||||
|
||||
Reference in New Issue
Block a user