Guest Posted March 22, 2011 Share Posted March 22, 2011 Message from: "news.fmsoft.net" Would like to know the ip of who is logged in the system? . Quote Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2011 Author Share Posted March 23, 2011 Message from: "Farshad Mohajeri" "news.fmsoft.net" wrote in message news:FOF0QjL6LHA.3560@anaxagvs227... > Would like to know the ip of who is logged in the system? add to uses: ServerModule, UniGUIApplication; Routine: procedure TMainForm.UniButton1Click(Sender: TObject); var I : Integer; ASessionList: TList; begin ASessionList:=UniServerModule.SessionManager.Sessions.SessionList.LockList; try for I := 0 to ASessionList.Count-1 do begin UniMemo1.Lines.Add( TUniGUISession(ASessionList).UniApplication.RemoteAddress ); end; finally UniServerModule.SessionManager.Sessions.SessionList.UnlockList; end; end; . Quote Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2011 Author Share Posted March 23, 2011 Message from: "news.fmsoft.net" Tanks. Em 23/03/2011 08:12, Farshad Mohajeri escreveu: > "news.fmsoft.net" wrote in message > news:FOF0QjL6LHA.3560@anaxagvs227... >> Would like to know the ip of who is logged in the system? > > add to uses: > ServerModule, UniGUIApplication; > > Routine: > > procedure TMainForm.UniButton1Click(Sender: TObject); > var > I : Integer; > ASessionList: TList; > begin > ASessionList:=UniServerModule.SessionManager.Sessions.SessionList.LockList; > try > for I := 0 to ASessionList.Count-1 do > begin > UniMemo1.Lines.Add( > TUniGUISession(ASessionList).UniApplication.RemoteAddress ); > end; > finally > UniServerModule.SessionManager.Sessions.SessionList.UnlockList; > end; > end; > > . Quote Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2011 Author Share Posted March 23, 2011 Message from: "Harry Rogers" Hi Farshad I added to your example to grab a bit more info about users. When they log in a number of fields in the Mainmodule are updated (sorry my news reader insists on wrapping this text) procedure TfrmWhois.UniButton1Click(Sender: TObject); var I : Integer; ASessionList: TList; Amod : TuniMainmodule; begin ASess..ist:UniServerModule.SessionManager.Sessions.SessionList.LockList; try unilistbox1.Items.Clear; for I := 0 to ASessionList.Count-1 do begin Amod:=TuniMainModule(TUniGUISession(ASessionList).DataModules[0]) ; Unilistbox1.Items.add( amod.fCurrentUserName + '@' + amod.fCurrentBranchName + '. ' + amod.fLoggedInTime + '. IP=' + TUniGUISession(ASessionList).UniApplication.RemoteAddress); end; finally UniServerModule.SessionManager.Sessions.SessionList.UnlockList; end; end; This works fine once but subsequent sessions complain about list index being out of bounds [0]. I have a single datamodule so I assumed it was safe to use TuniMainModule(TUniGUISession(ASessionList).DataModules[0]) What would be the correct way to do this ? - thanks. -- . Quote Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2011 Author Share Posted March 23, 2011 Message from: "Farshad Mohajeri" "Harry Rogers" wrote in message news:sIYEPkX6LHA.2164@anaxagvs227... > Hi Farshad > > I added to your example to grab a bit more info about users. When they > log in a number of fields in the Mainmodule are updated > > (sorry my news reader insists on wrapping this text) > > procedure TfrmWhois.UniButton1Click(Sender: TObject); > var > I : Integer; > ASessionList: TList; > Amod : TuniMainmodule; > begin > > ASess..ist:UniServerModule.SessionManager.Sessions.SessionList.LockList; > try > unilistbox1.Items.Clear; > for I := 0 to ASessionList.Count-1 do > begin > Amod:=TuniMainModule(TUniGUISession(ASessionList).DataModules[0]) ; > Unilistbox1.Items.add( amod.fCurrentUserName + '@' + > amod.fCurrentBranchName + '. ' + amod.fLoggedInTime + '. IP=' + > TUniGUISession(ASessionList).UniApplication.RemoteAddress); > end; > finally > UniServerModule.SessionManager.Sessions.SessionList.UnlockList; > end; > end; > > This works fine once but subsequent sessions complain about list index > being out of bounds [0]. I have a single datamodule so I assumed it was > safe to use > TuniMainModule(TUniGUISession(ASessionList).DataModules[0]) TUniGUISession can not be directlly casted to TuniMainModule. Correct syntax is: AMod:=TUniMainModule( TUniGUISession( ASessionList ).UniApplication.UniMainModule ); > > What would be the correct way to do this ? - thanks. > -- > . Quote Link to comment Share on other sites More sharing options...
Guest Posted March 23, 2011 Author Share Posted March 23, 2011 Message from: "Harry Rogers" Many thanks All the best . Quote Link to comment Share on other sites More sharing options...
Guest Posted March 24, 2011 Author Share Posted March 24, 2011 Message from: "Harry Rogers" Farshad Mohajeri wrote: > > "Harry Rogers" wrote in message > news:sIYEPkX6LHA.2164@anaxagvs227... > > Hi Farshad > > > > I added to your example to grab a bit more info about users. When > > they log in a number of fields in the Mainmodule are updated > > > > (sorry my news reader insists on wrapping this text) > > > > procedure TfrmWhois.UniButton1Click(Sender: TObject); > > var > > I : Integer; > > ASessionList: TList; > > Amod : TuniMainmodule; > > begin > > > > ASess..ist:UniServerModule.SessionManager.Sessions.SessionList.LockL > > ist; try > > unilistbox1.Items.Clear; > > for I := 0 to ASessionList.Count-1 do > > begin > > Amod:=TuniMainModule(TUniGUISession(ASessionList).DataModules[0]) > > ; Unilistbox1.Items.add( amod.fCurrentUserName + '@' + > > amod.fCurrentBranchName + '. ' + amod.fLoggedInTime + '. IP=' + > > TUniGUISession(ASessionList).UniApplication.RemoteAddress); > > end; > > finally > > UniServerModule.SessionManager.Sessions.SessionList.UnlockList; > > end; > > end; > > > > > This works fine once but subsequent sessions complain about list > > index being out of bounds [0]. I have a single datamodule so I > > assumed it was safe to use > > TuniMainModule(TUniGUISession(ASessionList).DataModules[0]) > > TUniGUISession can not be directlly casted to TuniMainModule. > > Correct syntax is: > > AMod:=TUniMainModule( TUniGUISession( ASessionList > ).UniApplication.UniMainModule ); > > > > > > What would be the correct way to do this ? - thanks. > > -- Hi Farshad That works... until a session logs off. We get an Av when we try to traverse the session list - even if I take out the bits accessing the UniMainModule. -- Quote Link to comment Share on other sites More sharing options...
Guest Posted March 24, 2011 Author Share Posted March 24, 2011 Message from: "Farshad Mohajeri" "Harry Rogers" > Hi Farshad > > That works... until a session logs off. > We get an Av when we try to traverse the session list - even if I take > out the bits accessing the UniMainModule. Logged as #938 . Quote Link to comment Share on other sites More sharing options...
Guest Posted March 24, 2011 Author Share Posted March 24, 2011 Message from: "Farshad Mohajeri" "Farshad Mohajeri" wrote in message news:kkUcqJk6LHA.3152@anaxagvs227... > > "Harry Rogers" >> Hi Farshad >> >> That works... until a session logs off. >> We get an Av when we try to traverse the session list - even if I take >> out the bits accessing the UniMainModule. > > Logged as #938 > Workaround: if TUniGUISession(ASessionList ).UniApplication<>nil then begin // your task end; . 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.