21#ifdef JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED
22 #include <juce_core/juce_core.h>
23 #include <juce_events/juce_events.h>
25 #include <JuceHeader.h>
133 NanoOcp1Base(
const juce::String& address,
const int port);
206 juce::String m_address;
250 NanoOcp1Client(
const bool callbacksOnMessageThread,
const juce::Thread::Priority threadPriority=juce::Thread::Priority::normal);
259 NanoOcp1Client(
const juce::String& address,
const int port,
const bool callbacksOnMessageThread,
const juce::Thread::Priority threadPriority=juce::Thread::Priority::normal);
267 bool start()
override;
273 bool stop()
override;
301 bool m_running{
false };
329 NanoOcp1Server(
const bool callbacksOnMessageThread,
const juce::Thread::Priority threadPriority=juce::Thread::Priority::normal);
338 NanoOcp1Server(
const juce::String& address,
const int port,
const bool callbacksOnMessageThread,
const juce::Thread::Priority threadPriority=juce::Thread::Priority::normal);
346 bool start()
override;
352 bool stop()
override;
371 std::unique_ptr<NanoOcp1Client> m_activeConnection;
372 bool m_callbacksOnMessageThread{
true };
373 juce::Thread::Priority m_threadPriority;
Abstract base class shared by NanoOcp1Client and NanoOcp1Server.
const int getPort()
Returns the current target port number.
std::function< void()> onConnectionEstablished
Fired once after a successful TCP connection is established.
void setPort(const int port)
Sets the TCP port number of the remote OCA device. DS100 default: 50014.
virtual bool stop()=0
Stops the client/server and closes any open TCP connection.
std::function< void()> onConnectionLost
Fired when the TCP connection is dropped or a connect attempt fails.
virtual bool start()=0
Starts the client/server. For the client, begins periodic reconnect attempts.
bool processReceivedData(const ByteVector &data)
Called by derived classes when bytes arrive from the socket. Invokes onDataReceived if set; the frame...
void setAddress(const juce::String &address)
Sets the IP address or hostname of the remote OCA device.
virtual bool sendData(const ByteVector &data)=0
Sends raw bytes over the active TCP connection.
const juce::String & getAddress()
Returns the current target address.
std::function< bool(const ByteVector &)> onDataReceived
Fired when a complete OCP.1 frame is received.
OCP.1 TCP client with automatic reconnection.
bool isRunning()
Returns true if start() has been called and stop() has not.
void timerCallback() override
Timer callback — attempts connectToSocket() when not yet connected.
void messageReceived(const ByteVector &message) override
Called by Ocp1Connection for each received OCP.1 frame — invokes onDataReceived.
void connectionMade() override
Called by Ocp1Connection when TCP connect succeeds — invokes onConnectionEstablished.
bool stop() override
Stops the reconnect timer and closes the TCP socket.
bool start() override
Starts the reconnect timer and begins attempting to connect.
void connectionLost() override
Called by Ocp1Connection when TCP connection is lost — invokes onConnectionLost.
~NanoOcp1Client() override
bool sendData(const ByteVector &data) override
Sends serialized OCP.1 bytes over the active TCP connection. The bytes must be a complete,...
OCP.1 TCP server that accepts a single incoming connection at a time.
~NanoOcp1Server() override
bool start() override
Binds the socket and starts the accept loop thread.
Ocp1Connection * createConnectionObject() override
Factory method called by the accept loop — creates the NanoOcp1Client peer object for the newly accep...
bool stop() override
Stops the accept loop and closes any active connection.
bool sendData(const ByteVector &data) override
Sends serialized OCP.1 bytes to the currently connected peer. If no peer is connected,...
TCP accept-loop server base class for OCP.1 connections.
Low-level TCP socket manager for a single OCP.1 connection.
Minimal AES70 / OCP.1 TCP client/server library built on JUCE.
std::vector< std::uint8_t > ByteVector
Binary buffer type used throughout NanoOcp for all serialized OCP.1 data.