Last change
on this file since 13913 was 11071, checked in by tbretz, 13 years ago |
Replaced v19r21 by a version extracted with 'unzip -a' to get proper unix text format.
|
File size:
1.6 KB
|
Line | |
---|
1 | #include <dis.hxx>
|
---|
2 | #include <dic.hxx>
|
---|
3 | #include <iostream>
|
---|
4 | using namespace std;
|
---|
5 |
|
---|
6 | class RpcInt : public DimRpc
|
---|
7 | {
|
---|
8 | int val;
|
---|
9 |
|
---|
10 | void rpcHandler()
|
---|
11 | {
|
---|
12 | val = getInt();
|
---|
13 | dim_print_date_time();
|
---|
14 | printf("Got RPC %d\n", val);
|
---|
15 | val++;
|
---|
16 | // usleep(700000);
|
---|
17 | dim_print_date_time();
|
---|
18 | printf("Answering RPC %d\n", val);
|
---|
19 | setData(val);
|
---|
20 | }
|
---|
21 | public:
|
---|
22 | RpcInt(char *name): DimRpc(name,"I","I") {val = 0;};
|
---|
23 | };
|
---|
24 |
|
---|
25 | typedef struct tst{
|
---|
26 | char str1[16];
|
---|
27 | int ints[5];
|
---|
28 | char str2[18];
|
---|
29 | float floats[4];
|
---|
30 | int int1;
|
---|
31 | float floats1[16];
|
---|
32 | } MyStruct;
|
---|
33 |
|
---|
34 | typedef struct jeffIn{
|
---|
35 | char c1;
|
---|
36 | char c2;
|
---|
37 | char c3;
|
---|
38 | char str[3000];
|
---|
39 | }JeffIn;
|
---|
40 |
|
---|
41 | typedef struct jeffOut{
|
---|
42 | int i1;
|
---|
43 | char c1;
|
---|
44 | char str[3000];
|
---|
45 | }JeffOut;
|
---|
46 |
|
---|
47 | class RpcStruct : public DimRpc
|
---|
48 | {
|
---|
49 | MyStruct *val;
|
---|
50 |
|
---|
51 | void rpcHandler()
|
---|
52 | {
|
---|
53 | val = (MyStruct *)getData();
|
---|
54 | val->int1++;
|
---|
55 | setData(val, sizeof(MyStruct));
|
---|
56 | }
|
---|
57 | public:
|
---|
58 | RpcStruct(char *name): DimRpc(name,"C:16;I:5;C:18;F:4;I:1;F:16",
|
---|
59 | "C:16;I:5;C:18;F:4;I:1;F:16") {val = 0;};
|
---|
60 | };
|
---|
61 |
|
---|
62 | class JeffRpcStruct : public DimRpc
|
---|
63 | {
|
---|
64 | JeffIn *pin;
|
---|
65 | JeffOut pout;
|
---|
66 | int counter;
|
---|
67 |
|
---|
68 | void rpcHandler()
|
---|
69 | {
|
---|
70 | pin = (JeffIn *)getData();
|
---|
71 | pout.i1 = counter++;
|
---|
72 | pout.c1 = pin->c1;
|
---|
73 | strcpy(pout.str,pin->str);
|
---|
74 | setData(&pout, strlen(pout.str)+1+5);
|
---|
75 | }
|
---|
76 | public:
|
---|
77 | JeffRpcStruct(char *name): DimRpc(name,"C:1;C:1;C:1;C",
|
---|
78 | "I:1;C:1;C") {counter = 0;};
|
---|
79 | };
|
---|
80 |
|
---|
81 | int main()
|
---|
82 | {
|
---|
83 | RpcInt myRpcInt("TESTRPC/INT");
|
---|
84 | RpcInt *myRpcP;
|
---|
85 | RpcStruct myRpcStruct("TESTRPC/STRUCT");
|
---|
86 | JeffRpcStruct jeffRpcStruct("TESTJEFF");
|
---|
87 | int i;
|
---|
88 | char name[64];
|
---|
89 |
|
---|
90 | for(i = 0; i < 10; i++)
|
---|
91 | {
|
---|
92 | sprintf(name,"TESTRPC%d/INT",i);
|
---|
93 | myRpcP = new RpcInt(name);
|
---|
94 | }
|
---|
95 | DimServer::start("TESTRPC");
|
---|
96 | while(1)
|
---|
97 | pause();
|
---|
98 | return 0;
|
---|
99 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.