eduardosuruagy Posted August 15, 2018 Share Posted August 15, 2018 How do I get all the active sections in Hyper Server? Quote Link to comment Share on other sites More sharing options...
Marlon Nardi Posted August 15, 2018 Share Posted August 15, 2018 for now we have this. http://www.unigui.com/resources/online-documentation/developer-manual" Sessions Another important difference from classical model is that in classical model your application is able to access all available session objects while in HyperServer each Node can only access sessions which are created by that specific Node. Needless to say that each Node holds a set of sessions which are isolated from other Nodes. If you need to query all of the sessions then you need to use different methods such as saving session information in a database table. You can simply create a row in the table when session is created and remove it when session is freed. " 2 Quote Link to comment Share on other sites More sharing options...
allenchow Posted August 17, 2018 Share Posted August 17, 2018 ANyone can show us an example or demo code for implementing this case ? When I can get session id and his IP when someone is login and quit ? Quote Link to comment Share on other sites More sharing options...
Marlon Nardi Posted August 17, 2018 Share Posted August 17, 2018 Simple sample: procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); begin CDS.FileName := UniServerModule.StartPath + '\dados.dat'; CDS.CreateDataSet; CDS.LoadFromFile(CDS.FileName); CDS.Open; CDS.Insert; CDS.FieldByName('SessionID').AsString := UniSession.SessionId; CDS.FieldByName('IP').AsString := UniSession.RemoteIP;; CDS.Post; end; procedure TUniMainModule.UniGUIMainModuleDestroy(Sender: TObject); begin CDS.Locate('SessionID',UniSession.SessionId,[loCaseInsensitive]); CDS.First; while not CDS.Eof do CDS.Delete; end; 2 Quote Link to comment Share on other sites More sharing options...
Administrators Farshad Mohajeri Posted August 17, 2018 Administrators Share Posted August 17, 2018 Simple sample: procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); begin CDS.FileName := UniServerModule.StartPath + '\dados.dat'; CDS.CreateDataSet; CDS.LoadFromFile(CDS.FileName); CDS.Open; CDS.Insert; CDS.FieldByName('SessionID').AsString := UniSession.SessionId; CDS.FieldByName('IP').AsString := UniSession.RemoteIP;; CDS.Post; end; procedure TUniMainModule.UniGUIMainModuleDestroy(Sender: TObject); begin CDS.Locate('SessionID',UniSession.SessionId,[loCaseInsensitive]); CDS.First; while not CDS.Eof do CDS.Delete; end; Your logic is correct but CDS is a memory dataset. For real usage a file based dB is needed Sent from my SM-N950F using Tapatalk Quote Link to comment Share on other sites More sharing options...
Marlon Nardi Posted August 17, 2018 Share Posted August 17, 2018 Exactly, I did just to get an idea of what it would be like, the CDS would be the DB (example) 2 Quote Link to comment Share on other sites More sharing options...
eduardosuruagy Posted August 18, 2018 Author Share Posted August 18, 2018 Can I tear down a section? Even using HS? Quote Link to comment Share on other sites More sharing options...
donlego Posted August 19, 2018 Share Posted August 19, 2018 hi.. if the user refresh the browser session id is change and UniGUIMainModuleDestroy never fired i need get all active session like tradisional unigui act,coz my app limiting connected user count with check count of active session with username login Quote Link to comment Share on other sites More sharing options...
allenchow Posted August 20, 2018 Share Posted August 20, 2018 hi.. if the user refresh the browser session id is change and UniGUIMainModuleDestroy never fired i need get all active session like tradisional unigui act,coz my app limiting connected user count with check count of active session with username login It should work even the user refresh the browser. I implement it into a table : qysession : procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject); var formattedDateTime : String; begin qysession.Open; qysession.append; qysession.FieldByName('ID').AsString := UniSession.SessionId; qysession.FieldByName('IP').AsString := UniSession.RemoteIP; DateTimeToString(formattedDateTime, 'dd/mm/yy hh:nn:ss', UniSession.LastTimeStamp); qysession.FieldByName('logdate').AsString := formattedDateTime; qysession.Post; qysession.Close; end; procedure TUniMainModule.UniGUIMainModuleDestroy(Sender: TObject); begin qysession.Open; if qysession.Locate('ID',UniSession.SessionId,[loCaseInsensitive]) then qysession.delete; qysession.Close; end; Quote Link to comment Share on other sites More sharing options...
donlego Posted August 20, 2018 Share Posted August 20, 2018 hi i try on 1472 not on voyager version i need record session on database when the user has pass the login form so i put the record on mainform oncreate event procedure TFrmMain.UniFormCreate(Sender: TObject); begin //INSERT SESSION PlayWithSession.INSERT_SESSION_DATABASE(UniSession.SessionId, UniMainModule.FMyStringVar_user, UniSession.UserAgent, UniPanel5.Caption, dm.KONEKSI.Server + ':' + dm.KONEKSI.Database, UniSession.RemoteIP, UniSession.RemoteIP); end; i want to delete record on database with session id but when user refresh the browser the sessionid always change , so if i put delete session on UniGUIMainModuleDestroy begin //DELETE SESSION PlayWithSession.DELETE_SESSION_DATABASE(UniSession.SessionId); end; it never find the before sessionid Quote Link to comment Share on other sites More sharing options...
Marlon Nardi Posted August 20, 2018 Share Posted August 20, 2018 Farshad, If it were possible , my dream code would be this one. A mega challenge, however, would benefit many projects . var HS: THyperServer; S : TUniGUISessions; U : TUniGUISession; vI, vII: Integer; MyClassOrVar: TMyClassOrVar; begin if NodeZero then begin HS := THyperServer.Create; HS.Lock; try for vI := 0 to HS.Nodes.Count -1 do begin S := HS.Nodes[vI].SessionManager.Sessions; for vII := 0 to S.SessionList.Count - 1 do begin U := S.SessionList[vII]; MyClassOrVar.Add(TUniMainModule(U.UniMainModule).MyClassOrVar.Name); end; end; finally HS.UnLock; HS.Free; end; end; end; Quote Link to comment Share on other sites More sharing options...
donlego Posted August 20, 2018 Share Posted August 20, 2018 +1 for marlon say, no db log for session,no db clear session service. like tradisional unigui.. Quote Link to comment Share on other sites More sharing options...
Ron Posted August 21, 2018 Share Posted August 21, 2018 I would rather have API REST access to the hyperserver, so I can monitor many servers from one user interface, and purge nodes and upload to a single server etc. A restriction of the number of sessions should be set in the config file, ideally, and also changeable through the API. When I have 20 Hyperservers, it would be nice to be able to change port settings through an API, instead of editing 20 text files. 1 Quote Link to comment Share on other sites More sharing options...
donlego Posted August 26, 2018 Share Posted August 26, 2018 With db to record session list , i can make delete user session when user log out, but if the server restart with any user still connect before the user logout How to delete all session still exist on db session log? I try with uniserver event on before shutdown but no success Quote Link to comment Share on other sites More sharing options...
User9912 Posted October 18, 2018 Share Posted October 18, 2018 On 8/20/2018 at 2:27 PM, Marlon Nardi said: Farshad, If it were possible , my dream code would be this one. A mega challenge, however, would benefit many projects . var HS: THyperServer; S : TUniGUISessions; U : TUniGUISession; vI, vII: Integer; MyClassOrVar: TMyClassOrVar; begin if NodeZero then begin HS := THyperServer.Create; HS.Lock; try for vI := 0 to HS.Nodes.Count -1 do begin S := HS.Nodes[vI].SessionManager.Sessions; for vII := 0 to S.SessionList.Count - 1 do begin U := S.SessionList[vII]; MyClassOrVar.Add(TUniMainModule(U.UniMainModule).MyClassOrVar.Name); end; end; finally HS.UnLock; HS.Free; end; end; end; Do I understand correctly that there is no way to go through all the sessions and find out their statuses? active/discarded 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.