Created
June 29, 2013 23:58
-
-
Save fizzy33/5893196 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
// =++=++=++= isolate.groovy =++=++=++= | |
void sendSignal(String sessionId, String signalName) { | |
def url = new URL("https://api.tropo.com/1.0/sessions/${sessionId}/signals?action=signal&value=${signalName}") | |
log("--log-- http get -- " + url) | |
def connection = url.openConnection() | |
def response = slurpStream(connection.getInputStream()) | |
def statusCode = connection.getResponseCode() | |
log("--log-- http get response -- " + statusCode + " -- " + response) | |
response | |
} | |
String slurpStream(InputStream input) { | |
def bufferSize = 4906 | |
def buffer = new char[bufferSize] | |
def out = new StringBuilder() | |
def reader = new InputStreamReader(input, "UTF-8") | |
try { | |
while(true) { | |
def readCount = reader.read(buffer, 0, buffer.length); | |
if (readCount < 0) break | |
out.append(buffer, 0, readCount) | |
} | |
out.toString() | |
} finally { | |
reader.close() | |
} | |
} | |
log("mySessionId=" + currentCall.sessionId) | |
Thread.start("childthread") { | |
log("--log-- child thread started") | |
await(5000) // wait 5 seconds | |
log("--log-- sending signal") | |
sendSignal(currentCall.sessionId, "happy") | |
log("--log-- signal sent") | |
} | |
say("https://vmail.medxcom.com/assets/prompts/system/followme_hold.mp3", [ | |
onSignal: { event -> | |
say("stopped on hold with " + event.value) | |
} | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment