File: commandTestServer.cpp

package info (click to toggle)
libaria 2.8.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,628 kB
  • ctags: 16,574
  • sloc: cpp: 135,490; makefile: 925; python: 597; java: 570; ansic: 182
file content (67 lines) | stat: -rw-r--r-- 1,575 bytes parent folder | download | duplicates (2)
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
63
64
65
66
67
#include "Aria.h"
#include "ArNetworking.h"

void function1(void)
{
  printf("Function1 called\n");
}

void function2(void)
{
  printf("Function2 called\n");
}

void function3(void)
{
  printf("Function3 called\n");
}

void function4(ArArgumentBuilder *arg)
{
  printf("Function4 called with string '%s'\n", arg->getFullString());
}

void function5(ArArgumentBuilder *arg)
{
  printf("Function5 called with string '%s'\n", arg->getFullString());
}

void function6(ArArgumentBuilder *arg)
{
  printf("Function6 called with string '%s'\n", arg->getFullString());
}


int main(int argc, char **argv)
{
  Aria::init();
  ArServerBase server;

  if (!server.open(7272))
  {
    printf("Could not open server port\n");
    exit(1);
  }

  ArServerHandlerCommands commands(&server);
  commands.addCommand("Function1", "Call the function that is number 1!", 
			    new ArGlobalFunctor(&function1));
  commands.addCommand("Function2", "Second function to call", 
			    new ArGlobalFunctor(&function2));
  commands.addCommand("Function3", "Tree climb", 
			    new ArGlobalFunctor(&function3));
  commands.addStringCommand("StringFunction4", 
			"Print a string in function 4", 
			    new ArGlobalFunctor1<
			    ArArgumentBuilder *>(&function4));
  commands.addStringCommand("StringFunction5", 
			"Prints a string given (5)", 
			    new ArGlobalFunctor1<
			    ArArgumentBuilder *>(&function5));
  commands.addStringCommand("StringFunction6", 
				  "Print out a value for function 6", 
			    new ArGlobalFunctor1<
			    ArArgumentBuilder *>(&function6));

  server.run();
}