Last active
December 21, 2018 09:00
-
-
Save hiroMTB/91270e5f2e7847fb1e9b8421a3d011ac to your computer and use it in GitHub Desktop.
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
void update(ofEventArgs &e) { | |
weConnected = tcpClient.isConnected(); | |
if (weConnected) { | |
string str = tcpClient.receive(); | |
if (str.length() > 0) { | |
ofNotifyEvent(tcpMessageReceived, str, this); | |
} | |
} | |
else { | |
//if we are not connected lets try and reconnect every 5 seconds | |
deltaTime = ofGetElapsedTimeMillis() - connectTime; | |
if (deltaTime > 5000) { | |
ofLogVerbose("skodaTCPClient") << "retrying connect..."; | |
weConnected = tcpClient.setup(mIp, mPort); | |
tcpClient.setMessageDelimiter("\n"); | |
ofLogVerbose("skodaTCPClient") << (weConnected ? "SUCCESS" : "FAIL"); | |
connectTime = ofGetElapsedTimeMillis(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment