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

37 views
Skip to first unread message

Hüseyin Uslu

unread,
Mar 5, 2014, 10:58:09 AM3/5/14
to jay...@googlegroups.com
For json-rpc 2.0, I'm using http://jsonrpc2.codeplex.com/. 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;

        [JsonRpcMethod("getwork")]
        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

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

Hüseyin Uslu

unread,
Mar 5, 2014, 11:29:24 AM3/5/14
to jay...@googlegroups.com
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

unread,
Mar 5, 2014, 1:44:23 PM3/5/14
to jay...@googlegroups.com
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 jayrock+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages