annotate include/OSCClient.h @ 536:b97fe1dc4278 prerelease

merge
author Liam Donovan <l.b.donovan@qmul.ac.uk>
date Thu, 23 Jun 2016 21:24:45 +0100
parents e4392164b458
children
rev   line source
l@270 1 /***** OSCClient.h *****/
l@270 2 #ifndef __OSCClient_H_INCLUDED__
l@270 3 #define __OSCClient_H_INCLUDED__
l@270 4
l@270 5 #include <UdpClient.h>
giuliomoro@301 6 #include <Bela.h>
l@270 7 #include <oscpkt.hh>
l@270 8 #include <queue>
l@270 9
l@270 10 class OSCMessageFactory{
l@270 11 public:
l@270 12 OSCMessageFactory& to(std::string);
l@270 13 OSCMessageFactory& add(std::string);
l@270 14 OSCMessageFactory& add(int);
l@270 15 OSCMessageFactory& add(float);
l@270 16 OSCMessageFactory& add(bool);
l@270 17 OSCMessageFactory& add(void *ptr, int size);
l@270 18 oscpkt::Message end();
l@270 19 private:
l@270 20 oscpkt::Message msg;
l@270 21 };
l@270 22
l@270 23 class OSCClient{
l@270 24 public:
l@270 25 OSCClient();
l@270 26
l@270 27 // must be called once during setup
l@270 28 void setup(int port, const char* address="127.0.0.1", bool scheduleTask = true);
l@270 29
l@270 30 // queue a message to be sent during the next aux task OSCSendTask
l@270 31 // audio-thread safe
l@270 32 void queueMessage(oscpkt::Message);
l@270 33
l@270 34 // send a mesage immediately
l@270 35 // *** do not use on audio thread! ***
l@270 36 // to be used during setup
l@270 37 void sendMessageNow(oscpkt::Message);
l@270 38
l@270 39 // allows new OSC messages to be created
l@270 40 // audio-thread safe
l@270 41 // usage: oscClient.queueMessage(oscClient.newMessage.to("/address").add(param).end());
l@270 42 OSCMessageFactory newMessage;
l@270 43
l@270 44 private:
l@270 45 const char* address;
l@270 46 int port;
l@270 47
l@270 48 UdpClient socket;
l@270 49 AuxiliaryTask OSCSendTask;
l@270 50 std::queue<oscpkt::Message> outQueue;
l@270 51 oscpkt::PacketWriter pw;
l@270 52 char* outBuffer;
l@270 53
l@270 54 static void sendQueue(void*);
l@270 55
l@270 56 void createAuxTasks();
l@270 57 void queueSend();
l@270 58
l@270 59 };
l@270 60
giuliomoro@301 61 #endif