30 #ifndef INCLUDE_OLA_CLIENT_CLIENTWRAPPER_H_
31 #define INCLUDE_OLA_CLIENT_CLIENTWRAPPER_H_
33 #include <ola/AutoStart.h>
35 #include <ola/client/OlaClient.h>
36 #include <ola/io/SelectServer.h>
38 #include <ola/network/TCPSocket.h>
92 std::auto_ptr<ola::network::TCPSocket> m_socket;
96 std::auto_ptr<CloseCallback> m_close_callback;
98 virtual void CreateClient() = 0;
99 virtual bool StartupClient() = 0;
100 virtual void InitSocket() = 0;
107 template <
typename ClientClass>
112 m_auto_start(auto_start) {
119 ClientClass *
GetClient()
const {
return m_client.get(); }
122 std::auto_ptr<ClientClass> m_client;
125 void CreateClient() {
126 if (!m_client.get()) {
127 m_client.reset(
new ClientClass(m_socket.get()));
131 bool StartupClient() {
132 bool ok = m_client->Setup();
133 m_client->SetCloseHandler(
143 m_socket.reset(ola::network::TCPSocket::Connect(
148 if (m_socket.get()) {
149 m_socket->SetNoDelay();
161 #endif // INCLUDE_OLA_CLIENT_CLIENTWRAPPER_H_
ola::io::SelectServer * GetSelectServer()
Get the SelectServer used by this client.
Definition: ClientWrapper.h:71
bool Cleanup()
Reset the connection to the server.
Definition: OlaClientWrapper.cpp:62
Represents Socket Addresses.
SingleUseCallback0< ReturnType > * NewSingleCallback(ReturnType(*callback)())
A helper function to create a new SingleUseCallback with 0 create-time arguments and 0 execution time...
Definition: Callback.h:194
GenericClientWrapper< OlaClient > OlaClientWrapper
A ClientWrapper that uses the OlaClient.
Definition: ClientWrapper.h:157
bool Setup()
Setup the client.
Definition: OlaClientWrapper.cpp:43
static const int OLA_DEFAULT_PORT
The default port which olad listens on for incoming RPC connections.
Definition: Constants.h:68
The base Client Wrapper class.
Definition: ClientWrapper.h:50
A single threaded I/O event management system.
Definition: SelectServer.h:63
void SetCloseCallback(CloseCallback *callback)
Set the callback to be run when the client socket is closed.
Definition: OlaClientWrapper.cpp:39
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
ClientClass * GetClient() const
Return the underlying client object.
Definition: ClientWrapper.h:119
void SocketClosed()
Called internally when the client socket is closed.
Definition: OlaClientWrapper.cpp:70
static IPV4Address Loopback()
Returns the loopback address (127.0.0.1).
Definition: IPV4Address.cpp:165
An IPv4 SocketAddress.
Definition: SocketAddress.h:77
A templatized ClientWrapper.
Definition: ClientWrapper.h:108