You are not logged in.
Pages: 1
If the request is terminated, then ServiceRunningContext^.Request = nil.
But since the same thread could almost instantly been used by another request, ServiceRunningContext could also be reused.
So I don't think it is usable outside the thread of this request.
Offline
I guess it would be a good idea, if there is a way to signal it to the running context in some way, for longer MVC ops to check on that. I tried studying the source for it, but could not make out a place where I could inject logic on that :-|
Regards,
Daniel
Offline
MVC is TRestServer-based so you have OnStartUri/OnBeforeUri/OnAfterUri events.
Which kind of callback do you need?
I have just introduced some dedicated TMvcApplication.OnBeforeRender/OnAfterRender callbacks.
Offline
I wouldn't think about callback, rather just a field/property like ClientListening (definitely not the best name), that would be false, once disconnected. This way the methods could stop gathering/sorting/whatever data and abort upon checking that flag.
I guess that could be achieved just before setting ServiceRunningContext^.Request := nil.
Where does that "ServiceRunningContext^.Request := nil" happen? I'd be happy to check out a way for achieving that.
Regards,
Daniel
Offline
I don't understand what you expect.
There is nothing like a "connection", just requests. This is what the TRestServer and the new TMvcApplication.On*Render callbacks offer.
You may want to track sessions, so track cookies lifetime.
I have just added TMvcApplication.OnSessionCreate/OnSessionFinalized callbacks for this.
But I guess that most of this logic could be done in your MVC business code directly.
Offline
Basically I am trying to find a way to check, whether the client has aborted the request in the meantime. In .NET running on http.sys you get something called a CancellationToken. That would allow canceling longer operations, when the client "lost interest".
Offline
Do you mean that the request could take a while, and that the socket has been closed on the client side before the answer is sent back?
For MVC views, which are made by the browser directly, there is no simple way of making the client close the connection.
For AJAX requests, you can call abort() before you get the answer, but I guess it is out of scope.
Our Web server is not meant for long requests. It consumes a thread of the thread pool during each request, so it would be easy to render the server unstable (typically make a DoS attack).
The MVC requests are meant to take a few milliseconds, tops.
So there is no "CancellationToken-like" feature in the mORMot server.
If you want to run some long-term process on the server side, you would rather use WebSockets or let the client poll the server for the task to be finished.
This is clearly out of scope of our MVC pattern.
Offline
Pages: 1