Open Lighting Architecture: ola::client::StreamingClient Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Classes | Public Member Functions | List of all members
ola::client::StreamingClient Class Reference

## Detailed Description

Send DMX512 data to olad.

StreamingClient sends DMX512 data to OLAD without waiting for an acknowledgement. It's best suited to simple clients which only ever send DMX512 data.

#include <stdlib.h>
#include <unistd.h>
#include <ola/DmxBuffer.h>
#include <ola/Logging.h>
#include <ola/client/StreamingClient.h>
#include <iostream>
using std::cout;
using std::endl;
int main(int, char *[]) {
unsigned int universe = 1; // universe to use for sending data
// turn on OLA logging
ola::InitLogging(ola::OLA_LOG_WARN, ola::OLA_LOG_STDERR);
ola::DmxBuffer buffer; // A DmxBuffer to hold the data.
buffer.Blackout(); // Set all channels to 0
// Create a new client.
ola::client::StreamingClient ola_client(
(ola::client::StreamingClient::Options()));
// Setup the client, this connects to the server
if (!ola_client.Setup()) {
std::cerr << "Setup failed" << endl;
exit(1);
}
// Send 100 frames to the server. Increment slot (channel) 0 each time a
// frame is sent.
for (unsigned int i = 0; i < 100; i++) {
buffer.SetChannel(0, i);
if (!ola_client.SendDmx(universe, buffer)) {
cout << "Send DMX failed" << endl;
exit(1);
}
usleep(25000); // sleep for 25ms between frames.
}
return 0;
}
Inheritance diagram for ola::client::StreamingClient:

## Classes
class | Options

## Public Member Functions
| StreamingClient (bool auto_start=true)
| StreamingClient (const Options &options)
| ~StreamingClient ()
bool | Setup ()
void | Stop ()
bool | SendDmx (unsigned int universe, const DmxBuffer &data)
bool | SendDMX (unsigned int universe, const DmxBuffer &data, const SendArgs &args)
| Send DMX data.
void | ChannelClosed (ola::rpc::RpcSession *session)

## Constructor & Destructor Documentation

## ◆ StreamingClient() [1/2]

ola::client::StreamingClient::StreamingClient | ( | bool | auto_start = true | ) |
| explicit

Create a new StreamingClient.

Parameters

  auto_start | if set to true, this will automatically start olad if it's not already running.

Deprecated
  Use the constructor that takes an Options struct instead.

## ◆ StreamingClient() [2/2]

ola::client::StreamingClient::StreamingClient | ( | const Options & | options | ) |
| explicit

Create a new StreamingClient.

Parameters

  options | an Options structure.

## ◆ ~StreamingClient()

ola::client::StreamingClient::~StreamingClient | ( |  | ) |

Destructor. This closes the connection to the olad server if it's still open.

## Member Function Documentation

## ◆ SendDMX()

bool ola::client::StreamingClient::SendDMX | ( | unsigned int | universe,
|  | const DmxBuffer & | data,
|  | const SendArgs & | args )
| virtual

Send DMX data.

Parameters

  universe | the universe to send to.
  data | the DmxBuffer with the data
  args | the SendDMXArgs to use for this call.

Implements ola::client::StreamingClientInterface.

## ◆ SendDmx()

bool ola::client::StreamingClient::SendDmx | ( | unsigned int | universe,
|  | const DmxBuffer & | data )
| virtual

Send a DmxBuffer to the olad server.

Parameters

  universe | the universe to send on.
  data | the DMX512 data.

Returns
  true if sent successfully, false if the connection to the server has been closed.

Implements ola::client::StreamingClientInterface.

## ◆ Setup()

bool ola::client::StreamingClient::Setup | ( |  | ) |
| virtual

Initialize the client and connect to olad.

Returns
  true if the initialization completed successfully, false if there was a failure.

Implements ola::client::StreamingClientInterface.

## ◆ Stop()

void ola::client::StreamingClient::Stop | ( |  | ) |
| virtual

Close the connection to the olad server. This does not need to be called since ~StreamingClient() will close the connection if it's still open when the object is destroyed.

Implements ola::client::StreamingClientInterface.

The documentation for this class was generated from the following files:

- include/ola/client/StreamingClient.h
- ola/StreamingClient.cpp