@@ -24,7 +24,7 @@ import { getBaseURL, TIMEZONE_CLIENT } from "../utils";
2424import { parseData } from "../utils/dataFormat" ;
2525import { MenuProps } from "../utils/lov" ;
2626import { changeFavicon , getLocalStorageValue , IdMessage , storeClientId } from "./utils" ;
27- import { lightenPayload , sendWsMessage , TAIPY_APP_ID , TAIPY_CLIENT_ID , WsMessage } from "./wsUtils" ;
27+ import { lightenPayload , sendWsMessage , TAIPY_GUI_ADDR , TAIPY_CLIENT_ID , WsMessage } from "./wsUtils" ;
2828
2929export enum Types {
3030 SocketConnected = "SOCKET_CONNECTED" ,
@@ -242,8 +242,8 @@ export const messageToAction = (message: WsMessage) => {
242242 changeFavicon ( ( message . payload as Record < string , string > ) ?. value ) ;
243243 } else if ( message . type == "BC" ) {
244244 stackBroadcast ( ( message as NamePayload ) . name , ( message as NamePayload ) . payload . value ) ;
245- } else if ( message . type == "AID " ) {
246- checkAppId ( ( message . payload as Record < string , string > ) . id ) ;
245+ } else if ( message . type == "GA " ) {
246+ checkGuiAddr ( ( message . payload as Record < string , string > ) . id ) ;
247247 }
248248 }
249249 return { } as TaipyBaseAction ;
@@ -288,16 +288,19 @@ const initializeBroadcastManagement = (dispatch: Dispatch<TaipyBaseAction>) => {
288288 } , broadcast_timeout ) ;
289289} ;
290290
291- // App id
292- const checkAppId = ( appId : string ) => {
293- if ( ! appId ) {
291+ // Gui Address
292+ const checkGuiAddr = ( guiAddr : string ) => {
293+ if ( ! guiAddr ) {
294294 return ;
295295 }
296- appId = `${ appId } ` ;
297- const localAppId = getLocalStorageValue ( TAIPY_APP_ID , "" ) ;
298- if ( ! localAppId || localAppId !== appId ) {
299- localStorage && localStorage . setItem ( TAIPY_APP_ID , appId ) ;
300- localAppId && window . location . assign ( getBaseURL ( ) ) ;
296+ guiAddr = `${ guiAddr } ` ;
297+ const localGuiAddr = getLocalStorageValue ( TAIPY_GUI_ADDR , "" ) ;
298+ if ( ! localGuiAddr || localGuiAddr !== guiAddr ) {
299+ localStorage && localStorage . setItem ( TAIPY_GUI_ADDR , guiAddr ) ;
300+ if ( localGuiAddr ) {
301+ console . info ( "Taipy GUI address changed, reloading the page" ) ;
302+ window . location . assign ( getBaseURL ( ) ) ;
303+ }
301304 }
302305} ;
303306
@@ -311,7 +314,7 @@ export const initializeWebSocket = (socket: Socket | undefined, dispatch: Dispat
311314 const id = getLocalStorageValue ( TAIPY_CLIENT_ID , "" ) ;
312315 const payload : Record < string , unknown > = { id } ;
313316 if ( lastReasonServer ) {
314- payload [ "app_id " ] = Number ( getLocalStorageValue ( TAIPY_APP_ID , "" ) ) ;
317+ payload [ "gui_addr " ] = Number ( getLocalStorageValue ( TAIPY_GUI_ADDR , "" ) ) ;
315318 }
316319 sendWsMessage ( socket , "ID" , TAIPY_CLIENT_ID , payload , id , undefined , false , ( ) => {
317320 dispatch ( { type : Types . SocketConnected } ) ;
0 commit comments