Jump to content

Connections


Guest

Recommended Posts

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;

 

 

.

 

Link to comment
Share on other sites

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;

>

>

 

.

 

Link to comment
Share on other sites

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.

--

 

.

 

Link to comment
Share on other sites

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.

> --

>

 

 

.

 

Link to comment
Share on other sites

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.

 

 

 

--

 

 

 

Link to comment
Share on other sites

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

 

 

.

 

Link to comment
Share on other sites

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;

 

 

.

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...