l@270: /***** OSCClient.h *****/ l@270: #ifndef __OSCClient_H_INCLUDED__ l@270: #define __OSCClient_H_INCLUDED__ l@270: l@270: #include l@270: #include l@270: #include l@270: #include l@270: l@270: class OSCMessageFactory{ l@270: public: l@270: OSCMessageFactory& to(std::string); l@270: OSCMessageFactory& add(std::string); l@270: OSCMessageFactory& add(int); l@270: OSCMessageFactory& add(float); l@270: OSCMessageFactory& add(bool); l@270: OSCMessageFactory& add(void *ptr, int size); l@270: oscpkt::Message end(); l@270: private: l@270: oscpkt::Message msg; l@270: }; l@270: l@270: class OSCClient{ l@270: public: l@270: OSCClient(); l@270: l@270: // must be called once during setup l@270: void setup(int port, const char* address="127.0.0.1", bool scheduleTask = true); l@270: l@270: // queue a message to be sent during the next aux task OSCSendTask l@270: // audio-thread safe l@270: void queueMessage(oscpkt::Message); l@270: l@270: // send a mesage immediately l@270: // *** do not use on audio thread! *** l@270: // to be used during setup l@270: void sendMessageNow(oscpkt::Message); l@270: l@270: // allows new OSC messages to be created l@270: // audio-thread safe l@270: // usage: oscClient.queueMessage(oscClient.newMessage.to("/address").add(param).end()); l@270: OSCMessageFactory newMessage; l@270: l@270: private: l@270: const char* address; l@270: int port; l@270: l@270: UdpClient socket; l@270: AuxiliaryTask OSCSendTask; l@270: std::queue outQueue; l@270: oscpkt::PacketWriter pw; l@270: char* outBuffer; l@270: l@270: static void sendQueue(void*); l@270: l@270: void createAuxTasks(); l@270: void queueSend(); l@270: l@270: }; l@270: l@270: #endif