Пример #1
0
void RPCClient::request(JsonBox::Value& json, char* method, JsonBox::Object params)
{
	string result = "";
	stringstream sstream("");
	
	DeviceInfo *dev = ((AppDelegate*)cocos2d::CCApplication::sharedApplication())->getDeviceInfo();
	JsonBox::Object device;
	dev->getJSONString(device);
	
	params["authkey"] = JsonBox::Value(dev->getAuthKey());
	params["device"] = JsonBox::Value(device);
	
	JsonBox::Object data;
	data["jsonrpc"] = JsonBox::Value("2.0");
	data["id"] = JsonBox::Value("1");
	data["method"] = JsonBox::Value(method);
	data["params"] = JsonBox::Value(params);

	sstream << data;

	if(_send(sstream.str()))
		_recv(result);
	
	sstream.flush();

	json.loadFromString(result);
}