ultimatepp/reference/XmlRpcServer/XmlRpcSrvTst.cpp
cxl 52f85319ad reference: XmlRpcCall, XmlRpcSever, XmlRpcClient
git-svn-id: svn://ultimatepp.org/upp/trunk@1822 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2009-12-20 20:27:56 +00:00

43 lines
675 B
C++

#include <XmlRpc/XmlRpc.h>
using namespace Upp;
XMLRPC_METHOD(compute)
{
double a, b;
String op;
rpc >> a >> op >> b;
Cout() << "Request: " << a << op << b << '\n';
if(op.GetCount() == 1)
switch(*op) {
case '+':
rpc << a + b;
return;
case '-':
rpc << a - b;
return;
case '/':
if(b == 0)
rpc << ErrorValue("division by zero");
else
rpc << a / b;
return;
case '*':
rpc << a * b;
return;
}
rpc << ErrorValue("unknown operator");
}
XMLRPC_METHOD(ping)
{
rpc << GetSysTime();
}
namespace Upp { extern bool HttpClient_Trace__; }
CONSOLE_APP_MAIN
{
Cout() << "Server..\n";
XmlRpcServer(1234);
}