From 217c529b94651a20f3514d1a865bf7a111a56b27 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Sun, 12 Jun 2011 00:58:06 +0200 Subject: [PATCH] callagent: Introduce the SIPRequests class Inspired by the MGCPCommands it can create simple requests and add parameters to the mix... --- callagent/SIPRequests.st | 98 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 callagent/SIPRequests.st diff --git a/callagent/SIPRequests.st b/callagent/SIPRequests.st new file mode 100644 index 0000000..28d975f --- /dev/null +++ b/callagent/SIPRequests.st @@ -0,0 +1,98 @@ +" + (C) 2010-2011 by Holger Hans Peter Freyther + All Rights Reserved + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as + published by the Free Software Foundation, either version 3 of the + License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +" + +"TODO: Compare with MGCPCommands and share code..." + +Object subclass: SIPRequest [ + | addr parameters sdp | + + + + sipAddr: anAddr [ + + addr := anAddr + ] + + sipAddr [ + + ^ addr + ] + + parameters [ + + ^ parameters ifNil: [parameters := OrderedCollection new] + ] + + sdp: aSDP [ + + sdp := aSDP + ] + + addParameter: name value: aValue [ + + self parameters add: '%1: %2' % {name. aValue} + ] + + asDatagram [ + | out | + + out := WriteStream on: (String new). + out + nextPutAll: '%1 %2 SIP/2.0' % {self class verb. self sipAddr}; + cr; nl. + + self parameters do: [:each | + out nextPutAll: each; cr; nl + ]. + + out cr; nl. + + sdp ifNotNil: [ + out nextPutAll: sdp + ]. + + ^ out contents + ] +] + +SIPRequest subclass: SIPInviteCommand [ + + + SIPInviteCommand class >> verb [ + + ^ 'INVITE' + ] +] + +SIPRequest subclass: SIPCancelCommand [ + + + SIPCancelCommand class >> verb [ + + ^ 'CANCEL' + ] +] + +SIPRequest subclass: SIPByeCommand [ + + + SIPByeCommand class >> verb [ + + ^ 'BYE' + ] +]