From 7e99d4291172f4dadb59b81cf525817dd8a210e5 Mon Sep 17 00:00:00 2001 From: Comment Date: Tue, 4 Dec 2012 14:53:44 +0000 Subject: dress rehearsal version --- ofAsterisk/src/Asterisk.cpp | 33 +++++++++++++-------------------- ofAsterisk/src/Asterisk.h | 10 ++++++---- ofAsterisk/src/testApp.cpp | 10 ++++++++-- ofAsterisk/src/testApp.h | 2 ++ 4 files changed, 29 insertions(+), 26 deletions(-) (limited to 'ofAsterisk') diff --git a/ofAsterisk/src/Asterisk.cpp b/ofAsterisk/src/Asterisk.cpp index f5e7705..7c4f050 100755 --- a/ofAsterisk/src/Asterisk.cpp +++ b/ofAsterisk/src/Asterisk.cpp @@ -13,30 +13,14 @@ std::vector &split(const std::string &s, char delim, std::vector split(const std::string &s, char delim) { - std::vector elems; - return split(s, delim, elems); -} -Asterisk::Asterisk() +Asterisk::Asterisk(string passcode) { udpConnection.Create(); udpConnection.Bind(5000); udpConnection.SetNonBlocking(true); - //cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME passcode 1234\"'"); + cmd("ssh 80.93.22.22 'sudo /usr/sbin/asterisk -rx \"database put GAME passcode "+passcode+"\"'"); state=WAITING; //for acknowledge - printf("Asterisk: created socket and connected to server\n"); - - string test=string("gameQ has 1 calls (max unlimited) in 'rrmemory' strategy (8s holdtime, 50s talktime), W:0, C:38, A:26, SL:36.8% within 0s\ - Members: \ - Game AGI (Local/9999@default) with penalty 1 (In use) has taken 31 calls (last was 5333 secs ago)\ - Callers: \ - 1. SIP/sip_proxy-00000045 (wait: 0:06, prio: 0)"); - vector lines=split(test,'\n'); - for (int i=0;i 0) { pclose(file); string msg=string(buf); - vector lines=split(msg,'\n'); //received data is always a command ACKNOWLEDGEMENT if (msg.compare("Changing GAME to NOT_INUSE")==0) { printf("player dequeued\n"); state=PLAYING; } else if (msg.compare(0,5,"gameQ")==0) { - //queue status message + vector lines; + split(msg,'\n',lines); + queued=0; + for (int i=4;i5000) { + game.requestStatus(); + queuecheck=ofGetElapsedTimeMillis(); + } } //-------------------------------------------------------------- void testApp::draw(){ - + ofClear(0,0,0); + ofSetColor(255,255,255); + ofDrawBitmapString(ofToString(game.queued), ofGetWidth()/2,ofGetHeight()/2); } //-------------------------------------------------------------- diff --git a/ofAsterisk/src/testApp.h b/ofAsterisk/src/testApp.h index 84c984c..61570bc 100755 --- a/ofAsterisk/src/testApp.h +++ b/ofAsterisk/src/testApp.h @@ -21,5 +21,7 @@ class testApp : public ofBaseApp{ void gotMessage(ofMessage msg); Asterisk game; + + int queuecheck; }; -- cgit v1.2.3