summaryrefslogtreecommitdiffstats
path: root/frtstream/src/example/test.cpp
blob: 5af115f9978d1553eff0e953ba526c517034ae51 (plain) (blame)
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
68
69
70
71
72
73
74
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/fastos/fastos.h>
#include <iostream>
#include <csignal>
#include <vector>
#include <string>
#include <set>

#include <vespa/frtstream/frtclientstream.h>


using namespace std;
using frtstream::FrtClientStream;
using frtstream::Method;
using frtstream::InvokationException;

const string connectionSpec = "tcp/test-tonyv:9997";

class TestApp : public FastOS_Application {
public:
    int Main() {
      FrtClientStream s(connectionSpec);

      std::vector<std::string> vec;
      vec.push_back("Hello"); vec.push_back("world");

      std::set<std::string> codeSet;
      codeSet.insert("abc"); codeSet.insert("def");

      std::vector<double> doubleVec;
      doubleVec.push_back(99.98); doubleVec.push_back(98.97);

      std::vector<float> floatVec;
      floatVec.push_back(99.98); floatVec.push_back(98.97);

      uint8_t i1 = 1;
      int8_t i2 = 2;

      uint16_t i3 = 1;
      int16_t i4 = 2;

      uint32_t i5 = 1;
      int32_t i6 = 2;

      uint64_t i7 = 1;
      int64_t i8 = 2;

      float f1 = 3.14;
      double d1 = 123.456;

      try {
          s <<Method("add") <<1 <<2 <<i1 <<f1 <<d1 <<vec <<codeSet <<doubleVec <<floatVec
            <<i1 <<i2 <<i3 <<i4 <<i5 <<i6 <<i7 <<i8;

          int res;
          s >> res >>vec >>codeSet >>doubleVec >>floatVec >>i1 >>f1 >>d1
            >>i1 >>i2 >>i3 >>i4 >>i5 >>i6 >>i7 >>i8;

          cout <<"Result = " <<res <<endl;
      } catch(const InvokationException& e) {
          cerr <<e <<endl;
      }
      return 0;

    }
};


int main(int argc, char** argv) {
    TestApp app;
    return app.Entry(argc, argv);


}