summaryrefslogtreecommitdiff
path: root/vfg/src/Asterisk.h
blob: c9ce864ee54ce9cd24d4e8144ed51a36e4a74e26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef ASTERISK_H
#define ASTERISK_H

#include "ofMain.h"
#include "ofxNetwork.h"

#define IDLE 0
#define WAITING 1
#define STARTING 2
#define PLAYING 3

// http://stackoverflow.com/questions/1735781/non-blocking-pipe-using-popen

/*

Commands for game to control PBX

Game ready

ssh 10.10.10.1 'sudo /usr/sbin/asterisk -rx "devstate change Custom:GAME NOT_INUSE"'

change daily access 4 digit code

ssh 10.10.10.1 'sudo /usr/sbin/asterisk -rx "database put GAME passcode 1234"'

 

Set status code for current game

ssh 10.10.10.1 'sudo /usr/sbin/asterisk -rx "database put GAME statuscode 1234"'

Gameover Hangup Call

ssh 10.10.10.1 'sudo /usr/sbin/asterisk -rx "hangup request  Local/9999@default-00000039;2"

Local/9999@default-00000039;2 is a channel identifier and will be send to game when AGI script connects to game controller. The channel ID is unique for each call


can we have a message that someone has joined the queue?
can we have a message if someone hangs up?
*/

class Asterisk
{
    public:
        Asterisk();
        virtual ~Asterisk();
	void startGame();
	void endGame(string score);
	int update();
	void cmd(string s);
    
	int state;
    
    protected:
    private:
	int startTime;
	FILE *file;
	int filenum;
	ofxUDPManager udpConnection;
	string playerCode;
};

#endif // ASTERISK_H