-
Notifications
You must be signed in to change notification settings - Fork 1
/
ofkOSCcommunicator.h
executable file
·95 lines (70 loc) · 2.43 KB
/
ofkOSCcommunicator.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
84
85
86
87
88
89
90
91
92
93
94
95
//
// ofkOSCcommunicator.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_ofkOSCcommunicator_h
#define oscSenderExample_ofkOSCcommunicator_h
/*
// ----- Static callback Usage ----- //
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 );
}
}
// ----- Event callback Usage ----- //
void onReceiveOSC(ofxOscMessage & prt);
ofAddListener(mOSCcommunicator.newReceivedOSCEvent,this,&CLASS::onReceiveOSC);
*/
#define NUM_MSG_STRINGS 50
class ofkOSCcommunicator
{
public:
typedef void oscCallBack(ofxOscMessage recieveMessage, void *pUserdata);
//mean of code :
//we call function such that has input (ofxOscMessage recieveMessage)
//and return void, "oscCallBack"
ofkOSCcommunicator();
void init(oscCallBack *pOSCCallBacK, void* pUserdata, int Revport = 4053, int Sendport = 4053);
// void init(oscCallBack *pOSCCallBacK, void* pUserdata, int port = 4053);
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;}
// PRE DEFINED OSC Messages gen and decoede
static ofxOscMessage genofkOSC(string name, int ID, ofMatrix4x4 mat);
static ofMatrix4x4 getFromofkOSC(ofxOscMessage message, string &name, int &ID);
ofEvent< ofxOscMessage > newReceivedOSCEvent;
//PRE DEFINED CONSTANT STRING
static string MESSAGE_MATRIX44;
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;
int mPort;
};
#endif