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