source: sources/src/rpcJsonClient.cc @ 1439:b23bfdd8a935

Revision 1439:b23bfdd8a935, 2.7 KB checked in by niam, 2 years ago (diff)

change contact info

Line 
1/***************************************************************************
2 *            rpcJsonClient.cc
3 *
4 *  Mon Jul 07 2008
5 *  Copyright  2008  Dmytro Milinevskyy
6 *  milinevskyy@gmail.com
7 ****************************************************************************/
8
9/*
10 *  This program is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU Lesser General Public License version 2.1 as published by
12 *  the Free Software Foundation;
13 *
14 *  This program is distributed in the hope that it will be useful,
15 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 *  GNU Library General Public License for more details.
18 *
19 *  You should have received a copy of the GNU Lesser General Public License
20 *  along with this program; if not, write to the Free Software
21 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24/**
25 * vim indentation settings
26 * set tabstop=4
27 * set shiftwidth=4
28 */
29
30#include <libdodo/directives.h>
31
32#include <libdodo/rpcJsonClient.h>
33#include <libdodo/types.h>
34#include <libdodo/rpcClient.h>
35#include <libdodo/rpcResponse.h>
36#include <libdodo/rpcJsonMethod.h>
37#include <libdodo/dataFormatJsonNode.h>
38#include <libdodo/dataFormatJsonProcessor.h>
39#include <libdodo/rpcJsonResponse.h>
40#include <libdodo/ioMemory.h>
41
42using namespace dodo::rpc::json;
43
44client::client(const io::channel &io) : rpc::client(io),
45                                        rqVersion("1.1"),
46                                        rqId(0)
47{
48}
49
50//-------------------------------------------------------------------
51
52client::~client()
53{
54}
55
56//-------------------------------------------------------------------
57
58void
59client::processCallRequest(const rpc::method &meth)
60{
61    dodo::data::format::json::processor jsonValue;
62
63    jsonValue.make(method::methodToJson(meth, rqVersion, ++rqId), io);
64
65    io.flush();
66}
67
68//-------------------------------------------------------------------
69
70dodo::rpc::response
71client::processCallResult()
72{
73    dodo::data::format::json::processor jsonValue;
74
75    dodo::data::format::json::node node = jsonValue.process(io);
76
77    return response::jsonToResponse(node, rpVersion, rpId);
78}
79
80//-------------------------------------------------------------------
81
82void
83client::setRequestVersion(const dodo::string &version)
84{
85    rqVersion = version;
86}
87
88//-------------------------------------------------------------------
89
90dodo::string
91client::responseVersion()
92{
93    return rpVersion;
94}
95
96//-------------------------------------------------------------------
97
98long
99client::responseId()
100{
101    return rpId;
102}
103
104//-------------------------------------------------------------------
105
Note: See TracBrowser for help on using the repository browser.