blob: 36c7abdf35b535ba76da5801185a33d37d953161 [file] [log] [blame]
// -*- cqa -*-
/* System Description
* Defines input/output ports,
* and valid messages per port.
*/
system
{
Inbound userIn : UserInput;
Inbound netIn : SIPResp, SIPReq;
Outbound netOut : SIPResp, SIPReq;
Outbound userOut : TimeOutIndication;
}
/* ====================================================
* Message Definitions
*/
record TimeOutIndication { }
record UserInput
{
public String input1;
public String input2;
}
record SIPResp
{
public int status;
public String cseq;
}
record SIPReq
{
public String op;
public String param;
}
/* ====================================================
* SIPClient
*/
class SIPClient extends StateMachine {
const float T1 = 0.5; // For UDP transport
public float timeoutA = T1; // 17.1.1.2
public float timeoutB = 16 * T1; // 17.1.1.2
public float timeoutE = T1; // 17.1.2.2
public float timeoutF = 16 * T1; // 17.1.2.2
/* -----------------------------------------
* SIP addresses
* src = caller, dst = callee
*/
public String src = "sip:127.0.0.1";
public String dst = "sip:127.0.0.1:5061";
/* -----------------------------------------
* Methods to send SIP messages to network.
*/
public void Invite() {
SIPReq r;
r.op = "INVITE";
r.param = dst;
netOut.send(r, 1.0);
}
protected void Cancel() {
SIPReq r;
r.op = "CANCEL";
r.param = dst;
netOut.send(r, 1.0);
}
protected void Ack() {
SIPReq r;
r.op = "ACK";
r.param = dst;
netOut.send(r, 1.0);
}
protected void Bye() {
SIPReq r;
r.op = "BYE";
r.param = dst;
netOut.send(r, 1.0);
}
protected void SendOK(String cseq) {
SIPResp r;
r.status = 200;
r.cseq = cseq;
netOut.send(r, 1.0);
}
/* -----------------------------------------
* Methods to provide indications to the
* user interface.
*/
private void TimeOut()
{
// Indicate timeout
TimeOutIndication timeout;
userOut.send(timeout);
}
}
/* ====================================================
* main() - Starting Point
*/
void main()
{
var a = new SIPClient();
a.start();
}