Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
OPCClient.h
1/*
2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU Library General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15 *
16 * OPCClient.h
17 * The Open Pixel Control Client.
18 * Copyright (C) 2014 Simon Newton
19 */
20
21#ifndef PLUGINS_OPENPIXELCONTROL_OPCCLIENT_H_
22#define PLUGINS_OPENPIXELCONTROL_OPCCLIENT_H_
23
24#include <memory>
25#include <string>
26
27#include "ola/DmxBuffer.h"
28#include "ola/io/MemoryBlockPool.h"
29#include "ola/io/SelectServerInterface.h"
30#include "ola/network/AdvancedTCPConnector.h"
32#include "ola/network/TCPSocket.h"
33#include "ola/util/Backoff.h"
34
35namespace ola {
36
37namespace io {
38class NonBlockingSender;
39} // namespace io
40
41namespace plugin {
42namespace openpixelcontrol {
43
49class OPCClient {
50 public:
55
63
67 ~OPCClient();
68
73 std::string GetRemoteAddress() const { return m_target.ToString(); }
74
80 bool SendDmx(uint8_t channel, const DmxBuffer &buffer);
81
88
89 private:
92
95 ola::network::TCPSocketFactory m_socket_factory;
97 std::auto_ptr<ola::network::TCPSocket> m_client_socket;
98 std::auto_ptr<ola::io::NonBlockingSender> m_sender;
99 std::auto_ptr<SocketEventCallback> m_socket_callback;
100
101 void SocketConnected(ola::network::TCPSocket *socket);
102 void NewData();
103 void SocketClosed();
104
105 OPCClient(const OPCClient &) = delete;
106 const OPCClient &operator=(const OPCClient &) = delete;
107};
108} // namespace openpixelcontrol
109} // namespace plugin
110} // namespace ola
111#endif // PLUGINS_OPENPIXELCONTROL_OPCCLIENT_H_
A class used to hold a single universe of DMX data.
Represents Socket Addresses.
A 1 argument callback which can be called multiple times.
Definition Callback.h:992
Used to hold a single universe of DMX data.
Definition DmxBuffer.h:49
Definition Backoff.h:98
MemoryBlockPool. This class is not thread safe.
Definition MemoryBlockPool.h:35
The interface for the SelectServer.
Definition SelectServerInterface.h:42
Attempts to open a TCP connection until a failure limit is reached.
Definition AdvancedTCPConnector.h:48
Definition TCPSocketFactory.h:46
An IPv4 SocketAddress.
Definition SocketAddress.h:78
Definition TCPSocket.h:43
An Open Pixel Control client.
Definition OPCClient.h:49
bool SendDmx(uint8_t channel, const DmxBuffer &buffer)
Send a DMX frame.
Definition OPCClient.cpp:58
std::string GetRemoteAddress() const
Return the remote address for this Client.
Definition OPCClient.h:73
~OPCClient()
Destructor.
Definition OPCClient.cpp:51
void SetSocketCallback(SocketEventCallback *callback)
Set the callback to be run when the socket state changes.
Definition OPCClient.cpp:72
ola::Callback1< void, bool > SocketEventCallback
Called when the socket changes state.
Definition OPCClient.h:54
OPCClient(ola::io::SelectServerInterface *ss, const ola::network::IPV4SocketAddress &target)
Create a new OPCClient.
Definition OPCClient.cpp:40
The namespace containing all OLA symbols.
Definition Credentials.cpp:44