-
Notifications
You must be signed in to change notification settings - Fork 1
/
OSCcommunicator.h
executable file
·83 lines (59 loc) · 1.81 KB
/
OSCcommunicator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//
// OSCcommunicator.h
// oscSenderExample
//
// Created by Shunichi Kasahara on 12/03/19.
// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//
#include "ofMain.h"
#include "ofxOsc.h"
#ifndef oscSenderExample_OSCcommunicator_h
#define oscSenderExample_OSCcommunicator_h
/*
in Header, Define function for CallBack
static void myOscCallBack(ofxOscMessage recieveMessage, void *pUserdata);
//function exsample
void testApp::myOscCallBack(ofxOscMessage recieveMessage, void *pUserdata)
{
testApp *pThis = (testApp *)pUserdata;
if( recieveMessage.getAddress() == "/touch/position" ){
// both the arguments are int32's
pThis->mouseX = recieveMessage.getArgAsInt32( 0 );
pThis->mouseY = recieveMessage.getArgAsInt32( 1 );
}
}
*/
#define PORT 4053 //for kasahara debug port
#define NUM_MSG_STRINGS 5
class OSCcommunicator
{
public:
typedef void oscCallBack(ofxOscMessage recieveMessage, void *pUserdata);
//mean of code :
//we call function such that has input (ofxOscMessage recieveMessage)
//and return void, "oscCallBack"
OSCcommunicator();
void init(oscCallBack *pOSCCallBacK, void* pUserdata);
void finalize();
void update();
void render();
void setSendIPAddress(string ip);
void send(ofxOscMessage message);
string getSendIPAddress(){return SEND_HOST_IP;}
string getOnwIPAddress(){return OWN_IP;}
void setDebugVisible(bool is){ isDebugVisible = is;}
private:
void* mpUserdata;
oscCallBack *pOSCcallbackFunc;
ofxOscReceiver receiver;
ofxOscSender sender;
//for debug
int current_msg_string;
string msg_strings[NUM_MSG_STRINGS];
float timers[NUM_MSG_STRINGS];
bool isDebugVisible;
string OWN_IP;
string SEND_HOST_IP;
string m_SEND_TEXT;
};
#endif