Skip to content

Commit

Permalink
Don't use the same id, stupid!
Browse files Browse the repository at this point in the history
Id is now stored in requestId and will be incremented on each
request.
  • Loading branch information
subutux committed Aug 14, 2013
1 parent 4b29546 commit d7f14cc
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion jsonrpc2.vala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace JsonRPC2 {
private bool debug;
private string[] auth;
private string RpcSessionId;
private int requestId;
public SessionAsync Session;

public JsonRPC2client (string url, string rClass) {
Expand All @@ -42,6 +43,7 @@ namespace JsonRPC2 {
remoteClass = rClass;
debug = false;
auth = {"",""};
requestId = 0;
}
public void authenticate(string username,string password){
auth = {username,password};
Expand All @@ -54,6 +56,8 @@ namespace JsonRPC2 {
size_t lenght;
string request;
string returned;

requestId = requestId + 1;
var jsonRequest = new Json.Object();
var jsonRoot = new Json.Node(NodeType.OBJECT);
var jsonGen = new Generator();
Expand All @@ -67,7 +71,7 @@ namespace JsonRPC2 {
jsonRequest.set_string_member("jsonrpc","2.0");
jsonRequest.set_string_member("method",remoteClass + "." + module);
jsonRequest.set_array_member("params",jsonParameters);
jsonRequest.set_int_member("id",1);
jsonRequest.set_int_member("id",requestId);
request = jsonGen.to_data(out lenght);
if (debug)
stdout.printf("<-- Sending: %s\n", request);
Expand Down

0 comments on commit d7f14cc

Please sign in to comment.