-
-
Save araid/f2240012b975478f5a6b855e36f53170 to your computer and use it in GitHub Desktop.
OSC iOS crash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "cinder/app/App.h" | |
#include "cinder/app/RendererGl.h" | |
#include "cinder/gl/gl.h" | |
#include "cinder/Log.h" | |
#include "cinder/osc/Osc.h" | |
using namespace ci; | |
using namespace ci::app; | |
using namespace std; | |
class OscTestApp : public App { | |
public: | |
void setup() override; | |
void update() override; | |
void draw() override; | |
bool bCloseReceiver = false; | |
shared_ptr<osc::ReceiverUdp> mReceiver; | |
}; | |
void OscTestApp::setup() | |
{ | |
mReceiver = std::make_shared<osc::ReceiverUdp>(10001); | |
// Lock the iOS device screen and come back to the app to freeze it | |
mReceiver->setSocketErrorFn([this](const asio::error_code &error, const asio::ip::udp::endpoint &originator) | |
{ | |
CI_LOG_E("Socket Transport Error: "); | |
CI_LOG_E("Code:" << error); | |
CI_LOG_E("Message:" << error.message()); | |
CI_LOG_E("Originator:" << originator.address().to_string()); | |
bCloseReceiver = true; | |
}); | |
mReceiver->bind(); | |
mReceiver->listen(); | |
} | |
void OscTestApp::update() | |
{ | |
if (bCloseReceiver) {; | |
mReceiver->close(); | |
app::App::get()->io_service().poll(); | |
mReceiver.reset(); | |
// setup(); | |
} | |
} | |
void OscTestApp::draw() | |
{ | |
gl::clear( Color( 0, 0, 0 ) ); | |
gl::color(1, 1, 0); | |
vec2 anim(sin(getElapsedSeconds()), cos(getElapsedSeconds())); | |
gl::drawSolidCircle(getWindowCenter() + anim * 100.0f, 50); | |
} | |
CINDER_APP( OscTestApp, RendererGl ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment