Is it possible to assign a context object to rpc-methods?

Skip to first unread message

Hüseyin Uslu

Mar 5, 2014, 10:58:09 AM3/5/14
For json-rpc 2.0, I'm using I'd like to ask if a specific functionality also exists for jayrock.

Basically, when calling jsonrpc-dispatcher, I can create my own context object;

                var rpcContext = new HttpRpcContext(this, rpcResponse);

And when calling the dispatcher, I set the context object to dispatcher;

               JsonRpcProcessor.Process(async, rpcContext);

Then within the json-rpc method handler, I can access the context object I assigned using;

        public Wallet.Responses.Getwork Getwork()
             var context = (HttpRpcContext)JsonRpcContext.Current().Value;

With this I can further manipulate my json-rpc responses based on the context of the client and so.

Is this possible with jayrock?

Hüseyin Uslu

Mar 5, 2014, 11:20:01 AM3/5/14
And I'm running jayrock over a standalone httplistener, so can't use ASP.Net's context object's and so.

Hüseyin Uslu

Mar 5, 2014, 11:29:24 AM3/5/14
Only sample I've found close to this is; 

Though it uses ASP.Net's context to store stuff. As I'm running standalone jayrock, it's not a possibility for me.

Atif Aziz

Mar 5, 2014, 1:44:23 PM3/5/14
In the sample I posted earlier, you'll see how this was done by installing a custom dispatcher that establishes the context for the service. How you define and associate the request context is up to you. The techniques can vary and Jayrock isn't very prescriptive in this area except providing the hooks for enabling custom scenarios.

- Atif

You received this message because you are subscribed to the Google Groups "Jayrock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
For more options, visit

Reply all
Reply to author
0 new messages