09-14-2019, 06:57 AM
Pages: 1 2
09-15-2019, 03:53 PM
Another option for anonymous function callbacks:
//Sample callback structure to pass/fill variables
//---------------------------------------------------------------------------
struct LookUpStruct
{
String *rip,*sts,*lac,*tid,*bnm;
LookUpStruct(String *_rip, String *_sts, String *_lac, String *_tid, String *_bnm) : rip(_rip),sts(_sts),lac(_lac),tid(_tid),bnm(_bnm) { };
void operator()(System::TObject* obj)
{
TIWApplication *ASession = (TIWApplication *)obj;
*rip = ((TIWUserSession*)ASession->Data)->realIP;
*sts = ASession->SessionTimeStamp.FormatString("yyyy-mm-dd hh:nn
s");
*lac = ASession->LastAccess.FormatString("yyyy-mm-dd hh:nn
s");
*tid = IntToStr(ASession->TrackID);
*bnm = ASession->Browser->BrowserName;
}
};
//---------------------------------------------------------------------------
typedef TMethodRef<Iwlfsessionlist::TSessionProc,LookUpStruct,void,System::TObject* > _LookUpStruct;
//---------------------------------------------------------------------------
//Sample callback struct usage
//---------------------------------------------------------------------------
void __fastcall TMJForm::btnRefreshAsyncClick(TObject *Sender, TStringList *EventParams)
{
auto_ptr<TStringList> sl(new TStringList);
gSessions->GetList(sl.get());
String ip,sts,lac,tid,bnm;
for(int i=0;i<sl->Count;i++) {
gSessions->LookUp(sl->Strings[i],new _LookUpStruct(LookUpStruct(&ip,&sts,&lac,&tid,&bnm)));
...
}
}
//Sample callback structure to pass/fill variables
//---------------------------------------------------------------------------
struct LookUpStruct
{
String *rip,*sts,*lac,*tid,*bnm;
LookUpStruct(String *_rip, String *_sts, String *_lac, String *_tid, String *_bnm) : rip(_rip),sts(_sts),lac(_lac),tid(_tid),bnm(_bnm) { };
void operator()(System::TObject* obj)
{
TIWApplication *ASession = (TIWApplication *)obj;
*rip = ((TIWUserSession*)ASession->Data)->realIP;
*sts = ASession->SessionTimeStamp.FormatString("yyyy-mm-dd hh:nn

*lac = ASession->LastAccess.FormatString("yyyy-mm-dd hh:nn

*tid = IntToStr(ASession->TrackID);
*bnm = ASession->Browser->BrowserName;
}
};
//---------------------------------------------------------------------------
typedef TMethodRef<Iwlfsessionlist::TSessionProc,LookUpStruct,void,System::TObject* > _LookUpStruct;
//---------------------------------------------------------------------------
//Sample callback struct usage
//---------------------------------------------------------------------------
void __fastcall TMJForm::btnRefreshAsyncClick(TObject *Sender, TStringList *EventParams)
{
auto_ptr<TStringList> sl(new TStringList);
gSessions->GetList(sl.get());
String ip,sts,lac,tid,bnm;
for(int i=0;i<sl->Count;i++) {
gSessions->LookUp(sl->Strings[i],new _LookUpStruct(LookUpStruct(&ip,&sts,&lac,&tid,&bnm)));
...
}
}
09-16-2019, 06:46 AM
I've tried the other example by now and it works fine, but this example is actually closest to what I need.
Thank you for your help
Juergen
Thank you for your help
Juergen
09-17-2019, 09:20 AM
I changed everything according to the last example and it works fine.
Thanks again for your help.
Juergen
Thanks again for your help.
Juergen
09-17-2019, 01:37 PM
Thanks for the follow up.
Pages: 1 2