OpenDaVINCI  4.16.0
Connection.h
Go to the documentation of this file.
1 
20 #ifndef OPENDAVINCI_CORE_IO_CONNECTION_H_
21 #define OPENDAVINCI_CORE_IO_CONNECTION_H_
22 
23 #include <string>
24 
26 #include <memory>
32 
33 namespace odcore { namespace data { class Container; } }
34 
35 namespace odcore {
36  namespace io {
37 
38 class ConnectionErrorListener;
39 namespace conference { class ContainerListener; }
40 
41  using namespace std;
42 
44  protected StringListener,
45  protected ConnectionListener
46  {
47  private:
51  Connection(Connection& obj);
52 
56  Connection& operator=(Connection& obj);
57 
58  public:
59  Connection(const std::string &ip, const uint32_t &port);
60  virtual ~Connection();
61 
62  void send(odcore::data::Container &container);
63  virtual void setContainerListener(odcore::io::conference::ContainerListener *cl);
64  void setErrorListener(ConnectionErrorListener* el);
65 
66  void start();
67  void stop();
68 
69  bool isConnected();
70 
71  protected:
72  friend class ConnectionAcceptor;
73  Connection(std::shared_ptr<odcore::io::tcp::TCPConnection> connection);
74 
75  virtual void nextString(const std::string &s);
76  virtual void handleConnectionError();
77 
78  private:
79  odcore::base::Mutex m_listenerMutex;
81 
82  odcore::base::Mutex m_errorHandlerMutex;
83  ConnectionErrorListener* m_errorHandler;
84 
85  std::shared_ptr<odcore::io::tcp::TCPConnection> m_connection;
86 
87  odcore::base::Mutex m_connectedMutex;
88  bool m_connected;
89  };
90  }
91 }
92 
93 #endif /* OPENDAVINCI_CORE_IO_CONNECTION_H_ */
Definition: ContainerListener.h:35
Definition: ContainerObserver.h:35
Definition: base/Mutex.h:49
Definition: Container.h:40
Definition: ConnectionListener.h:31
Definition: ConnectionErrorListener.h:30
Definition: ConnectionAcceptor.h:44
#define OPENDAVINCI_API
Definition: opendavinci.h:67
Definition: Connection.h:43
Definition: StringListener.h:36