David Reiss | 9f3296b | 2010-08-31 16:58:41 +0000 | [diff] [blame] | 1 | #include "zmq.hpp" |
| 2 | #include "TZmqServer.h" |
| 3 | #include "Storage.h" |
| 4 | |
| 5 | using boost::shared_ptr; |
| 6 | using apache::thrift::TProcessor; |
| 7 | using apache::thrift::server::TZmqServer; |
| 8 | using apache::thrift::server::TZmqMultiServer; |
| 9 | |
| 10 | class StorageHandler : virtual public StorageIf { |
| 11 | public: |
| 12 | StorageHandler() |
| 13 | : value_(0) |
| 14 | {} |
| 15 | |
| 16 | void incr(const int32_t amount) { |
| 17 | value_ += amount; |
| 18 | printf("value_: %i\n", value_) ; |
| 19 | } |
| 20 | |
| 21 | int32_t get() { |
| 22 | return value_; |
| 23 | } |
| 24 | |
| 25 | private: |
| 26 | int32_t value_; |
| 27 | |
| 28 | }; |
| 29 | |
| 30 | |
| 31 | int main(int argc, char *argv[]) { |
| 32 | shared_ptr<StorageHandler> handler(new StorageHandler()); |
| 33 | shared_ptr<TProcessor> processor(new StorageProcessor(handler)); |
| 34 | |
| 35 | zmq::context_t ctx(1); |
| 36 | TZmqServer oneway_server(processor, ctx, "epgm://eth0;239.192.1.1:5555", ZMQ_SUB); |
| 37 | oneway_server.serve(); |
| 38 | |
| 39 | return 0; |
| 40 | } |