File: main.cpp

package info (click to toggle)
dc-qt 0.2.0.alpha-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,948 kB
  • ctags: 5,361
  • sloc: cpp: 28,936; makefile: 19
file content (62 lines) | stat: -rw-r--r-- 1,264 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream>

#include <boost/bind.hpp>
#include <boost/thread/thread.hpp>

#include <list>
#include <string>

#include "rpcdriver.h"

using namespace rpc;
using namespace std;

rpc::RpcDriver* rd;

class HelloHandler : public RpcCommandHandler
{
public:
	HelloHandler(const std::string& cmdName) : RpcCommandHandler(cmdName,
																 NULL,
																 1) {}
	virtual void handleCommand( int clientId, 
								const std::list<boost::any>& params )
{


std::cout << "Handle hello" << std::endl;
// Send a reply

	rpc::CmdPtr cmd(new list<boost::any>);
	cmd->push_back( string("hoho") );
	list<boost::any> list1;
	for(int i = 0; i < 10;i++) {
		list<boost::any> list2;
		for(int j=0;j<5;j++) list2.push_back( i*j );
		list1.push_back(list2);
	}
	cmd->push_back( 10 );
	cmd->push_back( list1 );
	rd->queueCommand( -1, cmd );
}
};

int main (int argc, char * const argv[]) {
	
	try {
		
		// Create instance of RpcDriver
		rpc::RpcServerDriver driver( 6161 );
		rd = &driver;
		std::cout << "Server started." << std::endl;
			
		RpcCommandHandlerPtr hptr(new HelloHandler("hello"));
		driver.registerCommand(hptr);
		
		driver.waitForCompletion();
	}
	catch(...) {
		std::cout << "Exception reached all the way to end of main";
	}
    return 0;
}