21#ifdef JUCE_GLOBAL_MODULE_SETTINGS_INCLUDED
22 #include <juce_core/juce_core.h>
24 #include <JuceHeader.h>
34class Ocp1ConnectionServer;
89 Ocp1Connection(
bool callbacksOnMessageThread =
true,
const juce::Thread::Priority threadPriority = juce::Thread::Priority::normal);
100 bool connectToSocket(
const juce::String& hostName,
int portNumber,
int timeOutMillisecs);
114 juce::StreamingSocket*
getSocket() const noexcept {
return socket.get(); }
140 juce::ReadWriteLock socketLock;
141 std::unique_ptr<juce::StreamingSocket> socket;
142 bool callbackConnectionState =
false;
143 const bool useMessageThread;
147 void initialiseWithSocket(std::unique_ptr<juce::StreamingSocket>);
149 void connectionMadeInt();
150 void connectionLostInt();
152 bool readNextMessage();
153 int readData(
void*,
int);
156 std::unique_ptr<ConnectionThread> thread;
157 std::atomic<bool> threadIsRunning{
false };
160 std::shared_ptr<SafeAction> safeAction;
163 int writeData(
void*,
int);
165 juce::Thread::Priority m_threadPriority;
TCP accept-loop server base class for OCP.1 connections.
Low-level TCP socket manager for a single OCP.1 connection.
virtual ~Ocp1Connection()
virtual void connectionLost()=0
Called when the TCP connection is dropped or closed. Override to react.
Notify
Controls whether connectionLost() is called when disconnect() is invoked. Use Notify::no when shuttin...
bool connectToSocket(const juce::String &hostName, int portNumber, int timeOutMillisecs)
Attempts a TCP connection to the given host and port. Spawns the read thread on success.
void disconnect(int timeoutMs=0, Notify notify=Notify::yes)
Closes the TCP socket and stops the read thread.
juce::StreamingSocket * getSocket() const noexcept
Returns the underlying JUCE socket (for diagnostics).
juce::String getConnectedHostName() const
Returns the hostname of the currently connected remote peer, or an empty string.
virtual void messageReceived(const ByteVector &message)=0
Called with each complete OCP.1 frame received from the remote device. Pass message to Ocp1Message::U...
bool isConnected() const
Returns true if the TCP socket is currently open.
virtual void connectionMade()=0
Called when the TCP connection is successfully established. Override to react.
bool sendMessage(const ByteVector &message)
Sends a complete OCP.1 frame over the TCP socket. Acquires the write lock, then writes all bytes in o...
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.