#pragma once
#include "OscTypes.h"
#include "OscOutboundPacketStream.h"
#include "UdpSocket.h"
#include "ofxOscBundle.h"
#include "ofParameter.h"
#include "ofParameterGroup.h"
struct ofxOscSenderSettings {
std::string host = "localhost";
int port = 0;
bool broadcast = true;
};
class ofxOscSender{
public:
ofxOscSender() {}
~ofxOscSender();
ofxOscSender(const ofxOscSender &mom);
ofxOscSender& operator=(const ofxOscSender &mom);
ofxOscSender& copy(const ofxOscSender &other);
bool setup(const std::string &host, int port);
bool setup(const ofxOscSenderSettings &settings);
void clear();
void sendMessage(const ofxOscMessage &message, bool wrapInBundle=true);
void sendBundle(const ofxOscBundle &bundle);
void sendParameter(const ofAbstractParameter ¶meter);
std::string getHost() const;
int getPort() const;
const ofxOscSenderSettings &getSettings() const;
friend std::ostream& operator<<(std::ostream &os, const ofxOscSender &sender);
private:
void appendBundle(const ofxOscBundle &bundle, osc::OutboundPacketStream &p);
void appendMessage(const ofxOscMessage &message, osc::OutboundPacketStream &p);
void appendParameter(ofxOscBundle &bundle, const ofAbstractParameter ¶meter, const std::string &address);
void appendParameter(ofxOscMessage &msg, const ofAbstractParameter ¶meter, const std::string &address);
ofxOscSenderSettings settings;
std::unique_ptr<osc::UdpTransmitSocket> sendSocket;
};
Comments