Core/Rpc: Finished

git-svn-id: svn://ultimatepp.org/upp/trunk@5168 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-07-10 13:47:33 +00:00
parent 3b3ba5db66
commit 1dbfde1189
3 changed files with 14 additions and 10 deletions

View file

@ -188,6 +188,13 @@ Value ParseXmlRpcValue(XmlParser& p);
Value ParseXmlRpcParam(XmlParser& p);
ValueArray ParseXmlRpcParams(XmlParser& p);
struct RpcGet {
Value v;
template <class T>
operator T() { T x; ValueGet(x, v); return x; }
};
struct RpcData {
String peeraddr;
ValueArray in;
@ -201,7 +208,7 @@ struct RpcData {
template <class T>
RpcData& operator>>(T& x) { ValueGet(x, Get()); return *this; }
Value operator[](const char *id) { return in_map[id]; }
RpcGet operator[](const char *id) { RpcGet h; h.v = in_map[id]; return h; }
template <class T>
RpcData& operator<<(const T& x) { ASSERT(out_map.GetCount() == 0); Value v; ValuePut(v, x); out.Add(v); return *this; }

View file

@ -1,6 +1,6 @@
#include "Rpc.h"
#define LLOG(x) DLOG(x)
#define LLOG(x) // DLOG(x)
NAMESPACE_UPP
@ -148,12 +148,10 @@ Value ProcessJsonRpc(const Value& v, const char *group, const char *peeraddr)
data.in_map = param;
else
data.in = param;
DDUMP(data.in);
try {
if(CallRpcMethod(data, group, methodname)) {
if(IsValueArray(data.out)) {
ValueArray va = data.out;
DDUMP(data.out);
Value result = Null;
if(va.GetCount()) {
if(IsError(va[0])) {

View file

@ -41,7 +41,7 @@ void ValueGet(int& n, const Value& v)
void ValueGet(String& s, const Value& v)
{
ValueCheck(IsNull(v) || IsString(s));
ValueCheck(IsNull(v) || IsString(v));
s = v;
}
@ -53,7 +53,7 @@ void ValueGet(double& x, const Value& v)
void ValueGet(bool& x, const Value& v)
{
ValueCheck(IsNull(v) || IsNumber(x));
ValueCheck(IsNull(v) || IsNumber(v));
x = v;
}
@ -67,7 +67,6 @@ Time IsoTime(const Value& v)
void ValueGet(Date& x, const Value& v)
{
DDUMP(v);
if(IsString(v)) {
x = IsoTime(v);
return;