Am 23.07.2015 um 20:33 schrieb Lemonfiend:
class SomeWebInterface { void get() { ... runTask(toDelegate(&someTask)); ... } private auto someTask() { ... mySessionVar = "hello"; ... } }
Is there any way to have someTask set a SessionVar?
Since the request that determines the active session is bound to the
task that runs the request handler, this won't work using SessionVar
-
it's basically implicitly a TaskLocal
. But you could pass the Session
to the task and set the session field manually.
For that, the get
method would have to have a HTTPServerRequest req
parameter and then pass req.session
as an argument to runTask
, which
forwards it to someTask
.