Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

get request id in method service

42 views
Skip to first unread message

s.am...@teravintech.com

unread,
Jul 18, 2013, 1:52:14 AM7/18/13
to jay...@googlegroups.com
public class HelloTest : JsonRpcHandler
{
        [JsonRpcMethod("echoTest")]
        public string echoTest(string test)
        {
              string response = "Response : " + test;
              return test;
        }
}

{"id":3,"method":"echoTest","params":{ "test" : "catty is here" }}


i want to get the id of the json and put it in the response
so the response will be like bellow:
string response = "Response " + requestId + " : " + test;

requetsId is 3 if like above json request.


Thanks,

Atif Aziz

unread,
Jul 18, 2013, 3:10:19 AM7/18/13
to jay...@googlegroups.com
You can do this by implementing your own JsonRpcDispatcher subclass that stashes away the request Id in the context and then retrieve it later from the invoked method. Here's a complete working example:

- 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