From f7bee21ada14851da8626a3784821ded25333fe6 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Mon, 3 Dec 2012 17:04:02 +0000 Subject: working on train --- ofAsterisk/src/Asterisk.cpp | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'ofAsterisk/src/Asterisk.cpp') diff --git a/ofAsterisk/src/Asterisk.cpp b/ofAsterisk/src/Asterisk.cpp index 46957cd..f5e7705 100755 --- a/ofAsterisk/src/Asterisk.cpp +++ b/ofAsterisk/src/Asterisk.cpp @@ -4,14 +4,39 @@ //there is no notification that there is someone in the queue //but there is a status message you can check periodically... +std::vector &split(const std::string &s, char delim, std::vector &elems) { + std::stringstream ss(s); + std::string item; + while(std::getline(ss, item, delim)) { + elems.push_back(item); + } + return elems; +} + +std::vector split(const std::string &s, char delim) { + std::vector elems; + return split(s, delim, elems); +} + Asterisk::Asterisk() { 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 1234\"'"); 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"); -- cgit v1.2.3