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'.
|
PackageLoader fileInPackage: 'Sockets'.
|
||||||
|
|
||||||
Object subclass: MGCPCallAgentBase [
|
Object subclass: MGCPCallAgentBase [
|
||||||
| socket queue rx tx trunks sem |
|
| socket queue rx tx trunks sem addr port |
|
||||||
<category: 'MGCP-Callagent'>
|
<category: 'MGCP-Callagent'>
|
||||||
<comment: 'I am responsible for the networking'>
|
<comment: 'I am responsible for the networking'>
|
||||||
|
|
||||||
|
@ -40,9 +40,10 @@ Object subclass: MGCPCallAgentBase [
|
||||||
initialize: anAddress port: aPort [
|
initialize: anAddress port: aPort [
|
||||||
<category: 'creation'>
|
<category: 'creation'>
|
||||||
sem := Semaphore forMutualExclusion.
|
sem := Semaphore forMutualExclusion.
|
||||||
socket := Sockets.DatagramSocket local: anAddress port: aPort.
|
|
||||||
queue := SharedQueue new.
|
queue := SharedQueue new.
|
||||||
trunks := OrderedCollection new.
|
trunks := OrderedCollection new.
|
||||||
|
addr := anAddress.
|
||||||
|
port := aPort.
|
||||||
]
|
]
|
||||||
|
|
||||||
addTrunk: aTrunk [
|
addTrunk: aTrunk [
|
||||||
|
@ -60,6 +61,9 @@ Object subclass: MGCPCallAgentBase [
|
||||||
start [
|
start [
|
||||||
<category: 'handling'>
|
<category: 'handling'>
|
||||||
|
|
||||||
|
self stop.
|
||||||
|
socket := Sockets.DatagramSocket local: addr port: port.
|
||||||
|
|
||||||
"Receive datagrams from the socket..."
|
"Receive datagrams from the socket..."
|
||||||
rx := [
|
rx := [
|
||||||
[ | data |
|
[ | data |
|
||||||
|
@ -80,7 +84,7 @@ Object subclass: MGCPCallAgentBase [
|
||||||
]
|
]
|
||||||
|
|
||||||
stop [
|
stop [
|
||||||
socket close.
|
socket ifNotNil: [socket close].
|
||||||
tx ifNotNil: [tx terminate].
|
tx ifNotNil: [tx terminate].
|
||||||
rx ifNotNil: [rx terminate].
|
rx ifNotNil: [rx terminate].
|
||||||
]
|
]
|
||||||
|
|
Reference in New Issue