datasnap - How to work with TDSSessionManager.Instance.foreachsession (Delphi XE5) -


i have problem on understanding how work foreachsession method of tdssessionmanager.instance. (i need example if have). real example.

i want following: 1 client connect datasnap server. save 1 value in session. ... session.putdata('idretea', "1");

i want deny other clients connecting same value until first connection finish job.

how iterate thru session , compare idretea value finded in current session? (based on bussines logical).

i kinda want implement behavior on procedure tsrvcontainer.dssservermainconnect(dsconnecteventobject: tdsconnecteventobject);

here have values , can raise exception if find user , client know resume job (1,2,3 minute later), server being "busy" now.

you can provide anonymous method foreachsession, this:

procedure tservercontainer1.test; var   mycurrentsession: tdssession; begin   mycurrentsession := tdssessionmanager.instance.getthreadsession;    tdssessionmanager.instance.foreachsession(     procedure(const session: tdssession)     begin       // procedure called each session in tdssessionmanager       if (session.getdata('idretea') <> '') , (mycurrentsession.sessionname <> session.sessionname)         raise exception.create('server busy. try again later.');     end);    mycurrentsession.putdata('idretea', 'busy'); end; 

actually need provide method signature:

procedure(const session: tdssession) 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -