callagent: Create a shared routine to verify the state transition
This commit is contained in:
parent
ab1e189087
commit
03348c1e8d
|
@ -68,34 +68,30 @@ Object subclass: MGCPEndpoint [
|
|||
^ state = self class stateUsed.
|
||||
]
|
||||
|
||||
requireState: aState [
|
||||
<category: 'allocation'>
|
||||
state = aState ifFalse: [
|
||||
^ self error: 'MGCPEndpoint(%1) not %2.'
|
||||
% {self endpointName. aState} area: #mgcp.
|
||||
].
|
||||
]
|
||||
|
||||
reserve [
|
||||
<category: 'allocation'>
|
||||
state = self class stateUnused ifFalse: [
|
||||
^ self error: 'MGCPEndpoint(%1) not unused.'
|
||||
% {self endpointName} area: #mgcp.
|
||||
].
|
||||
|
||||
self requireState: self class stateUnused.
|
||||
state := self class stateReserved.
|
||||
]
|
||||
|
||||
used [
|
||||
<category: 'allocation'>
|
||||
state = self class stateReserved ifFalse: [
|
||||
^ self error: 'MGCPEndpoint(%1) not reserved.'
|
||||
% {self endpointName} area: #mgcp.
|
||||
].
|
||||
|
||||
self requireState: self class stateReserved.
|
||||
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.
|
||||
self requireState: self class stateUsed.
|
||||
state := self class stateUsed.
|
||||
]
|
||||
|
||||
tryBlock [
|
||||
|
@ -110,11 +106,7 @@ Object subclass: MGCPEndpoint [
|
|||
|
||||
unblock [
|
||||
<category: 'allocation'>
|
||||
state = self class stateBlocked ifFalse: [
|
||||
^ self error: 'MGCPEndpoint(%1) not blocked.'
|
||||
% {self endpointName} area: #mgcp.
|
||||
].
|
||||
|
||||
self requireState: self class stateBlocked.
|
||||
state := self class stateUnused.
|
||||
]
|
||||
|
||||
|
|
Reference in New Issue