"
(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 .
"
Object subclass: MGCPEndpoint [
| nr trunk state callid connid sdp|
MGCPEndpoint class >> stateUnused [ ^ #unused ]
MGCPEndpoint class >> stateReserved [ ^ #reserved ]
MGCPEndpoint class >> stateUsed [ ^ #used ]
MGCPEndpoint class >> stateBlocked [ ^ #blocked ]
MGCPEndpoint class >> initWith: aNr trunk: aTrunk [
^ self new
instVarNamed: #nr put: aNr;
instVarNamed: #trunk put: aTrunk;
instVarNamed: #state put: self stateUnused;
yourself
]
endpointName [
^ trunk endpointName: nr.
]
endpointNumber [
^ nr
]
multiplex [
^ trunk multiplexFor: nr.
]
timeslot [
^ trunk timeslotFor: nr.
]
trunk [
^ trunk
]
state [
^ state
]
isBlocked [
^ state = self class stateBlocked.
]
isReserved [
^ state = self class stateReserved.
]
isUnused [
^ state = self class stateUnused.
]
isUsed [
^ state = self class stateUsed.
]
requireState: aState [
state = aState ifFalse: [
^ self error: ('MGCPEndpoint(<1p>) not <2p>.'
expandMacrosWithArguments: {self endpointName. aState}).
].
]
reserve [
self requireState: self class stateUnused.
state := self class stateReserved.
]
used [
self requireState: self class stateReserved.
state := self class stateUsed.
]
free [
self requireState: self class stateUsed.
state := self class stateUnused.
sdp := nil.
callid := nil.
connid := nil.
]
tryBlock [
state = self class stateUnused ifTrue: [
state := self class stateBlocked.
^ true
].
^ false
]
unblock [
self requireState: self class stateBlocked.
state := self class stateUnused.
]
sdp [
^ sdp
]
sdp: aSdp [
self requireState: self class stateUsed.
sdp := aSdp.
]
callId [
^ callid
]
callId: aCallId [
self requireState: self class stateReserved.
callid := aCallId.
]
clearCallId [
self requireState: self class stateUsed.
callid := nil.
]
connId [
^ connid
]
connId: aConnId [
self requireState: self class stateUsed.
connid := aConnId.
]
]