Skip to content

Commit

Permalink
Merge pull request openframeworks#2438 from pizthewiz/feature-optiona…
Browse files Browse the repository at this point in the history
…l-osc-bundles

Feature allow OSC message sends without bundle wrapper
  • Loading branch information
jvcleave committed Jul 8, 2014
2 parents 423fe7f + 0d24e71 commit 4d4c611
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions addons/ofxOsc/src/ofxOscSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void ofxOscSender::sendBundle( ofxOscBundle& bundle )
socket->Send( p.Data(), p.Size() );
}

void ofxOscSender::sendMessage( ofxOscMessage& message )
void ofxOscSender::sendMessage( ofxOscMessage& message, bool wrapInBundle )
{
//setting this much larger as it gets trimmed down to the size its using before being sent.
//TODO: much better if we could make this dynamic? Maybe have ofxOscMessage return its size?
Expand All @@ -85,10 +85,10 @@ void ofxOscSender::sendMessage( ofxOscMessage& message )
osc::OutboundPacketStream p( buffer, OUTPUT_BUFFER_SIZE );

// serialise the message
p << osc::BeginBundleImmediate;
if(wrapInBundle) p << osc::BeginBundleImmediate;
appendMessage( message, p );
p << osc::EndBundle;
if(wrapInBundle) p << osc::EndBundle;

socket->Send( p.Data(), p.Size() );
}

Expand All @@ -112,7 +112,7 @@ void ofxOscSender::sendParameter( const ofAbstractParameter & parameter){
if(address.length()) address += "/";
ofxOscMessage msg;
appendParameter(msg,parameter,address);
sendMessage(msg);
sendMessage(msg, false);
}
}

Expand Down
2 changes: 1 addition & 1 deletion addons/ofxOsc/src/ofxOscSender.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ofxOscSender
void setup( std::string hostname, int port );

/// send the given message
void sendMessage( ofxOscMessage& message );
void sendMessage( ofxOscMessage& message, bool wrapInBundle = true );
/// send the given bundle
void sendBundle( ofxOscBundle& bundle );
/// creates a message using an ofParameter
Expand Down
4 changes: 2 additions & 2 deletions examples/addons/oscChatSystemExample/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void ofApp::keyPressed(int key){
ofxOscMessage m;
m.setAddress("/typing");
m.addStringArg(clientTyping);
clientSender.sendMessage(m);
clientSender.sendMessage(m, false);

// clear out "typing"
clientTyping = "";
Expand Down Expand Up @@ -250,7 +250,7 @@ void ofApp::broadcastReceivedMessage(string chatmessage){
for(unsigned int i = 0; i < knownClients.size(); i++){
serverSender.setup(knownClients[i], serverRecvPort + 1);
m.setRemoteEndpoint(knownClients[i], serverRecvPort + 1);
serverSender.sendMessage(m);
serverSender.sendMessage(m, false);
ofLogVerbose("Server broadcast message " + m.getArgAsString(0) + " to " + m.getRemoteIp()
+ ":" + ofToString(m.getRemotePort()));
}
Expand Down
8 changes: 4 additions & 4 deletions examples/addons/oscSenderExample/src/ofApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void ofApp::keyPressed(int key){
m.addFloatArg(3.5f);
m.addStringArg("hello");
m.addFloatArg(ofGetElapsedTimef());
sender.sendMessage(m);
sender.sendMessage(m, false);
}

//send an image. (Note: the size of the image depends greatly on your network buffer sizes - if an image is too big the message won't come through )
Expand All @@ -72,7 +72,7 @@ void ofApp::mouseMoved(int x, int y){
m.setAddress("/mouse/position");
m.addIntArg(x);
m.addIntArg(y);
sender.sendMessage(m);
sender.sendMessage(m, false);
}

//--------------------------------------------------------------
Expand All @@ -85,15 +85,15 @@ void ofApp::mousePressed(int x, int y, int button){
ofxOscMessage m;
m.setAddress("/mouse/button");
m.addStringArg("down");
sender.sendMessage(m);
sender.sendMessage(m, false);
}

//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
ofxOscMessage m;
m.setAddress("/mouse/button");
m.addStringArg("up");
sender.sendMessage(m);
sender.sendMessage(m, false);

}

Expand Down

0 comments on commit 4d4c611

Please sign in to comment.