callagent: Make it possible to stop/start the MGCPCallAgent
Remember the IP/Port, on start allocate the socket.
This commit is contained in:
parent
5eeef62086
commit
a0dbcd42e2
|
@ -19,7 +19,7 @@
|
|||
PackageLoader fileInPackage: 'Sockets'.
|
||||
|
||||
Object subclass: MGCPCallAgentBase [
|
||||
| socket queue rx tx trunks sem |
|
||||
| socket queue rx tx trunks sem addr port |
|
||||
<category: 'MGCP-Callagent'>
|
||||
<comment: 'I am responsible for the networking'>
|
||||
|
||||
|
@ -40,9 +40,10 @@ Object subclass: MGCPCallAgentBase [
|
|||
initialize: anAddress port: aPort [
|
||||
<category: 'creation'>
|
||||
sem := Semaphore forMutualExclusion.
|
||||
socket := Sockets.DatagramSocket local: anAddress port: aPort.
|
||||
queue := SharedQueue new.
|
||||
trunks := OrderedCollection new.
|
||||
addr := anAddress.
|
||||
port := aPort.
|
||||
]
|
||||
|
||||
addTrunk: aTrunk [
|
||||
|
@ -60,6 +61,9 @@ Object subclass: MGCPCallAgentBase [
|
|||
start [
|
||||
<category: 'handling'>
|
||||
|
||||
self stop.
|
||||
socket := Sockets.DatagramSocket local: addr port: port.
|
||||
|
||||
"Receive datagrams from the socket..."
|
||||
rx := [
|
||||
[ | data |
|
||||
|
@ -80,7 +84,7 @@ Object subclass: MGCPCallAgentBase [
|
|||
]
|
||||
|
||||
stop [
|
||||
socket close.
|
||||
socket ifNotNil: [socket close].
|
||||
tx ifNotNil: [tx terminate].
|
||||
rx ifNotNil: [rx terminate].
|
||||
]
|
||||
|
|
Reference in New Issue