aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-06-24 10:09:12 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-06-24 20:08:22 +0200
commitab1e1890870692fa173f135ad5b96911e9c4b3b1 (patch)
treed6695404ca3e59a010dd074a2ed8e9d4074d672f
parenta87b29e0943d72ed91d6c303319b738dd1517ec0 (diff)
callagent: Add state transitions to the MGCPEndpoint
-rw-r--r--callagent/MGCPEndpoint.st60
1 files changed, 60 insertions, 0 deletions
diff --git a/callagent/MGCPEndpoint.st b/callagent/MGCPEndpoint.st
index a5ac215..a3b909d 100644
--- a/callagent/MGCPEndpoint.st
+++ b/callagent/MGCPEndpoint.st
@@ -67,4 +67,64 @@ Object subclass: MGCPEndpoint [
<category: 'state'>
^ state = self class stateUsed.
]
+
+ reserve [
+ <category: 'allocation'>
+ state = self class stateUnused ifFalse: [
+ ^ self error: 'MGCPEndpoint(%1) not unused.'
+ % {self endpointName} area: #mgcp.
+ ].
+
+ state := self class stateReserved.
+ ]
+
+ used [
+ <category: 'allocation'>
+ state = self class stateReserved ifFalse: [
+ ^ self error: 'MGCPEndpoint(%1) not reserved.'
+ % {self endpointName} area: #mgcp.
+ ].
+
+ state := self class stateUsed.
+ ]
+
+ free [
+ <category: 'allocation'>
+ state = self class stateUsed ifFalse: [
+ ^ self error: 'MGCPEndpoint(%1) not used.'
+ % {self endpointName} area: #mgcp.
+ ].
+
+ state := self class stateUnused.
+ ]
+
+ tryBlock [
+ <category: 'allocation'>
+ state = self class stateUnused ifTrue: [
+ state := self class stateBlocked.
+ ^ true
+ ].
+
+ ^ false
+ ]
+
+ unblock [
+ <category: 'allocation'>
+ state = self class stateBlocked ifFalse: [
+ ^ self error: 'MGCPEndpoint(%1) not blocked.'
+ % {self endpointName} area: #mgcp.
+ ].
+
+ state := self class stateUnused.
+ ]
+
+ sdp [
+ <category: 'sdp'>
+ ^ sdp
+ ]
+
+ sdp: aSdp [
+ <category: 'sdp'>
+ sdp := aSdp.
+ ]
]