DonaldShimoda Posted February 23, 2021 Share Posted February 23, 2021 Imagine i have 5 sessions open. Each session have one id stored in a cookie. I need to change a label dinamically, from the server, in the correct session id. Example, update temperature value in session with id 1 Is possible? Any hint how to search the session id? How will refresh at client side(browser) Best regards Quote Link to comment Share on other sites More sharing options...
irigsoft Posted February 24, 2021 Share Posted February 24, 2021 I use this to close all active sessions from one user (by name) without my own. unisession var sUserName : String; procedure CloseOtherSesionsFromUser (sesionUser : AnsiString); var I : Integer; U : TUniGUISession; begin Try UniServerModule.SessionManager.Sessions.Lock; for I :=UniServerModule.SessionManager.Sessions.SessionList.Count - 1 downto 0 do begin U := UniServerModule.SessionManager.Sessions.SessionList[I]; //U.LockSession; // Check mainModule availability. Some sessions may not have a MainModule instance if U.UniMainModule <> nil then begin // Do not close my OWN Session if (UniApplication.UniSession.SessionID <> U.SessionId) AND ((U.UniMainModule as TUniMainModule).sUserName = sesionUser) then begin U.ReleaseSession; U.Terminate ('Already connected: ' + sesionUser + '.' + '</br>' + 'Session is closed'); end; // UniMainModule(U.UniMainModule as TUniMainModule).logout ((U.UniMainModule as TUniMainModule).sUsername); // Access custom MainModule props end; end; UniServerModule.SessionManager.Sessions.Unlock; Finally End; end; You can use sessions list, to search active session. I use other function to search components by extended FindComponent in screen.activeform and change the values 1 Quote Link to comment Share on other sites More sharing options...
mhmda Posted February 24, 2021 Share Posted February 24, 2021 Web Sockets will be perfect solution for you. We already use this tech. in our web app for chat. I'll see if there is spare time for creating a video tutorial for Unigui + WebScokets (real time app) 🙂 3 Quote Link to comment Share on other sites More sharing options...
epos4u Posted February 24, 2021 Share Posted February 24, 2021 13 minutes ago, mhmda said: Web Sockets will be perfect solution for you. We already use this tech. in our web app for chat. I'll see if there is spare time for creating a video tutorial for Unigui + WebScokets (real time app) 🙂 That would be great... can't wait Quote Link to comment Share on other sites More sharing options...
mhmda Posted March 1, 2021 Share Posted March 1, 2021 Here you go: http://forums.unigui.com/index.php?/topic/16276-make-your-app-a-real-time-web-app-using-websockets/ Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.