xml - How do I receive push notifications with Indy? -


i have device uses restful web services , have used request/response functionality whereby send command via http , responds appropriate xml.

i need use device's pus notifications. have tried same approach above whereby supply tidhttp.get procedure relevant http url , stream in place response, doesn't seem work. call get doesn't come back. makes sense me in push notifications opening http stream of communication between device , program , connection remain open streaming until closed.

my problem though don't know how xml stream if get method doesn't return. if program has hung. have tried put communication via device , reading of stream thread can continue on own , main application can check resultant xml not work.

i wondering if on complicating , if there simple solution. when send request , response, works fine; it's push streaming can't work.

if use url in internet explorer can see xml returned "busy" logo running indicating stream open.

i have run command through browser firefox mozilla 20.0.1 , seen wireshark captures push request , response. http part shown below:

get /elite/notifications/stream?resume=2013-05-06t00:00:00z http/1.1  host: 192.168.10.10  user-agent: mozilla/5.0 (windows nt 6.1; wow64; rv:20.0) gecko/20100101 firefox/20.0  accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8  accept-language: en-us,en;q=0.5  accept-encoding: gzip, deflate  connection: keep-alive 

the request trying in delphi follows:

if feventstream = nil   feventstream := tstringstream.create(''); try   tapitem.fhttp.get(tapitem.i2ireaderip+'/elite/notifications/stream?resume=2013-05-01t00:00:00z',feventstream);   tapitem.feventxml := feventstream.readstring(feventstream.size); except   on e:exception begin     showmessage(e.message)   end; end; 

i have tried tidtcpconnection

  ftcpconn.iohandler.writeln(tapitem.i2ireaderip+i2i_push_event+'2013-05-01t00:00:00z');   while not terminated begin     xmlstring := xmlstring + ftcpconn.iohandler.readln;   end; 

any assistance in matter appreciated.

solution


in case adding keyword beginning of call worked. assumed tcp connection component requires knowledge of action (ie put etc) wish do, cant read mind, makes sense

ftcpconn.iohandler.writeln('get ' + tapitem.i2ireaderip+i2i_push_event+'2013-05-01t00:00:00z'); while not terminated begin   xmlstring := xmlstring + ftcpconn.iohandler.readln; end; 

tidhttp not support server-side pushes @ time (and then, there multiple ways server-side pushes can implemented - 1 rest service using?). have switch tidtcpclient, format , send http request manually, , use timer or thread read , parse pushed responses needed arrive.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -