Last active
March 25, 2019 12:41
-
-
Save ElectricImpSampleCode/6ab77a58dfc711216982 to your computer and use it in GitHub Desktop.
A code snippet showing when and how to trap unexpected disconnection events.
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
// EARLY CALL CODE | |
server.setsendtimeoutpolicy(RETURN_ON_ERROR, WAIT_TIL_SENT, 30.0); | |
// GLOBALS | |
local disconnectedFlag = false; | |
local disconnectedCount = 0; | |
// FUNCTIONS | |
function mainProgramLoop() { | |
// We'll fill this in below | |
} | |
function disconnectionHandler(reason) { | |
// Function called automatically if the agent link is lost | |
if (reason != SERVER_CONNECTED) disconnectedFlag = true; | |
} | |
// START OF RUNTIME | |
server.onunexpecteddisconnect(disconnectionHandler); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment