Can someone help me with #DataSnap REST Application and callbacks?
Can someone help me with #DataSnap REST Application and callbacks?
I'm new to DataSnap.
I'm going to create simple DS Server and web client with few buttons.
I created new datasnap server (Datasnap REST Application) using wizard, modified web-pages, css, wrote my server methods. it works fine.
Now I need to implement callback method on server, it should send some data to client. I can't understand how I can do that.
I watched "Heavyweight Callbacks with DataSnap
" by Methew DeLong (Heavyweight Callbacks with DataSnap - Part 2: Thin Client) Seems it is very easy, but it uses "DS Server" wizard and executes callback method using ServerContainer1 variable (ServerContainer1.DSServer1.BroadcastMessage()). But in DS REST Application I have webModule instead of ServerContainer, and do not have references to TWebModule instances.
So, the question is, how do I implement callbacks in DataSnap REST Application at server side (in #Delphi-XE4), or I should use DS Server instead of REST App?
http://www.youtube.com/watch?v=xVUAisxqW0U
I'm new to DataSnap.
I'm going to create simple DS Server and web client with few buttons.
I created new datasnap server (Datasnap REST Application) using wizard, modified web-pages, css, wrote my server methods. it works fine.
Now I need to implement callback method on server, it should send some data to client. I can't understand how I can do that.
I watched "Heavyweight Callbacks with DataSnap
" by Methew DeLong (Heavyweight Callbacks with DataSnap - Part 2: Thin Client) Seems it is very easy, but it uses "DS Server" wizard and executes callback method using ServerContainer1 variable (ServerContainer1.DSServer1.BroadcastMessage()). But in DS REST Application I have webModule instead of ServerContainer, and do not have references to TWebModule instances.
So, the question is, how do I implement callbacks in DataSnap REST Application at server side (in #Delphi-XE4), or I should use DS Server instead of REST App?
http://www.youtube.com/watch?v=xVUAisxqW0U
oook, seems I figured it out, I had to check "Server module" option in Server features wizard dialog box
ReplyDeleteНапиши потом о результатах
ReplyDeleteAndrey Alisov да там вроде просто все. когда ставишь галку Server Module в проект добавляется DataModule, на котором расположены TDSServer & TDSServerClass (то есть из TWebModule они вырезаются). Вот этот дата модуль с сервером создается единожды при старте. А при вот при каждом создании вэб-модуля, все ссылки на сервер проставляются в OnCreate или конструкторе.
ReplyDeleteСоответственно все обратные вызовы реализуются по той же схеме, что и в приведенном выше видео, поскольку экземпляр TDSServer доступен всегда. Правда у меня пока что ничего не работает :)
Andrew Terekhov когда заработает - запости у себя на сайте, плиз. почитаем.
ReplyDeleteOr here, even. Google translate is a good thing :)
ReplyDeleteLars Fosdal :) did you mean "translate" button under comment?:)
ReplyDeleteanyway, I still have no luck with callbacks in REST App :) i've created project as in video above, it works fine. but REST app uses different components (TIdHTTPWebBrokerBridge instead of TDSHttpService ? ); copied javascipt code to my project, but it doesn't work so far. may be I should recreate my project (:
Yes, I did! Decoding the Cyrillic alphabet is not my strongest side. :)
ReplyDeletesoo. i've created new Rest app project with test page (with memo as in video). it worked fine, so I copied this page to my existing project and failed.
ReplyDeleteIn the end I moved old pas files to new project and recreated html pages form scratch.