JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::OSCReceiver Class Reference

A class for receiving OSC data. More...

#include <juce_OSCReceiver.h>

Collaboration diagram for juce::OSCReceiver:

Classes

class  Listener
 A class for receiving OSC data from an OSCReceiver. More...
 
class  ListenerWithOSCAddress
 A class for receiving only those OSC messages from an OSCReceiver that match a given OSC address. More...
 
struct  MessageLoopCallback
 Use this struct as the template parameter for Listener and ListenerWithOSCAddress to receive incoming OSC data on the message thread. More...
 
struct  RealtimeCallback
 Use this struct as the template parameter for Listener and ListenerWithOSCAddress to receive incoming OSC data immediately after it arrives, called directly on the network thread that listens to incoming OSC traffic. More...
 

Public Types

using FormatErrorHandler = std::function< void(const char *data, int dataSize)>
 An error handler function for OSC format errors that can be called by the OSCReceiver. More...
 

Public Member Functions

 OSCReceiver ()
 Creates an OSCReceiver. More...
 
 OSCReceiver (const String &threadName)
 Creates an OSCReceiver with a specific name for its thread. More...
 
 ~OSCReceiver ()
 Destructor. More...
 
void addListener (Listener< MessageLoopCallback > *listenerToAdd)
 Adds a listener that listens to OSC messages and bundles. More...
 
void addListener (Listener< RealtimeCallback > *listenerToAdd)
 Adds a listener that listens to OSC messages and bundles. More...
 
void addListener (ListenerWithOSCAddress< MessageLoopCallback > *listenerToAdd, OSCAddress addressToMatch)
 Adds a filtered listener that listens to OSC messages matching the address used to register the listener here. More...
 
void addListener (ListenerWithOSCAddress< RealtimeCallback > *listenerToAdd, OSCAddress addressToMatch)
 Adds a filtered listener that listens to OSC messages matching the address used to register the listener here. More...
 
bool connect (int portNumber)
 Connects to the specified UDP port using a datagram socket, and starts listening to OSC packets arriving on this port. More...
 
bool connectToSocket (DatagramSocket &socketToUse)
 Connects to a UDP datagram socket that is already set up, and starts listening to OSC packets arriving on this port. More...
 
bool disconnect ()
 Disconnects from the currently used UDP port. More...
 
void registerFormatErrorHandler (FormatErrorHandler handler)
 Installs a custom error handler which is called in case the receiver encounters a stream it cannot parse as an OSC bundle or OSC message. More...
 
void removeListener (Listener< MessageLoopCallback > *listenerToRemove)
 Removes a previously-registered listener. More...
 
void removeListener (Listener< RealtimeCallback > *listenerToRemove)
 Removes a previously-registered listener. More...
 
void removeListener (ListenerWithOSCAddress< MessageLoopCallback > *listenerToRemove)
 Removes a previously-registered listener. More...
 
void removeListener (ListenerWithOSCAddress< RealtimeCallback > *listenerToRemove)
 Removes a previously-registered listener. More...
 

Private Attributes

std::unique_ptr< Pimpl > pimpl
 

Friends

struct OSCReceiverCallbackMessage
 

Detailed Description

A class for receiving OSC data.

An OSCReceiver object allows you to receive OSC bundles and messages. It can connect to a network port, receive incoming OSC packets from the network via UDP, parse them, and forward the included OSCMessage and OSCBundle objects to its listeners.

{OSC}

Member Typedef Documentation

◆ FormatErrorHandler

using juce::OSCReceiver::FormatErrorHandler = std::function<void (const char* data, int dataSize)>

An error handler function for OSC format errors that can be called by the OSCReceiver.

The arguments passed are the pointer to and the data of the buffer that the OSCReceiver has failed to parse.

Constructor & Destructor Documentation

◆ OSCReceiver() [1/2]

juce::OSCReceiver::OSCReceiver ( )

Creates an OSCReceiver.

◆ OSCReceiver() [2/2]

juce::OSCReceiver::OSCReceiver ( const String threadName)

Creates an OSCReceiver with a specific name for its thread.

◆ ~OSCReceiver()

juce::OSCReceiver::~OSCReceiver ( )

Destructor.

Member Function Documentation

◆ addListener() [1/4]

void juce::OSCReceiver::addListener ( Listener< MessageLoopCallback > *  listenerToAdd)

Adds a listener that listens to OSC messages and bundles.

This listener will be called on the application's message loop.

◆ addListener() [2/4]

void juce::OSCReceiver::addListener ( Listener< RealtimeCallback > *  listenerToAdd)

Adds a listener that listens to OSC messages and bundles.

This listener will be called in real-time directly on the network thread that receives OSC data.

◆ addListener() [3/4]

void juce::OSCReceiver::addListener ( ListenerWithOSCAddress< MessageLoopCallback > *  listenerToAdd,
OSCAddress  addressToMatch 
)

Adds a filtered listener that listens to OSC messages matching the address used to register the listener here.

The listener will be called on the application's message loop.

◆ addListener() [4/4]

void juce::OSCReceiver::addListener ( ListenerWithOSCAddress< RealtimeCallback > *  listenerToAdd,
OSCAddress  addressToMatch 
)

Adds a filtered listener that listens to OSC messages matching the address used to register the listener here.

The listener will be called on the application's message loop.

◆ connect()

bool juce::OSCReceiver::connect ( int  portNumber)

Connects to the specified UDP port using a datagram socket, and starts listening to OSC packets arriving on this port.

Returns
true if the connection was successful; false otherwise.

◆ connectToSocket()

bool juce::OSCReceiver::connectToSocket ( DatagramSocket socketToUse)

Connects to a UDP datagram socket that is already set up, and starts listening to OSC packets arriving on this port.

Make sure that the object you give it doesn't get deleted while this object is still using it!

Returns
true if the connection was successful; false otherwise.

◆ disconnect()

bool juce::OSCReceiver::disconnect ( )

Disconnects from the currently used UDP port.

Returns
true if the disconnection was successful; false otherwise.

◆ registerFormatErrorHandler()

void juce::OSCReceiver::registerFormatErrorHandler ( FormatErrorHandler  handler)

Installs a custom error handler which is called in case the receiver encounters a stream it cannot parse as an OSC bundle or OSC message.

By default (i.e. if you never use this method), in case of a parsing error nothing happens and the invalid packet is simply discarded.

◆ removeListener() [1/4]

void juce::OSCReceiver::removeListener ( Listener< MessageLoopCallback > *  listenerToRemove)

Removes a previously-registered listener.

◆ removeListener() [2/4]

void juce::OSCReceiver::removeListener ( Listener< RealtimeCallback > *  listenerToRemove)

Removes a previously-registered listener.

◆ removeListener() [3/4]

void juce::OSCReceiver::removeListener ( ListenerWithOSCAddress< MessageLoopCallback > *  listenerToRemove)

Removes a previously-registered listener.

◆ removeListener() [4/4]

void juce::OSCReceiver::removeListener ( ListenerWithOSCAddress< RealtimeCallback > *  listenerToRemove)

Removes a previously-registered listener.

Friends And Related Function Documentation

◆ OSCReceiverCallbackMessage

friend struct OSCReceiverCallbackMessage
friend

Member Data Documentation

◆ pimpl

std::unique_ptr<Pimpl> juce::OSCReceiver::pimpl
private

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