smalltalk
/
osmo-st-mgcp
Archived
1
0
Fork 0

callagent: Make it possible to stop/start the MGCPCallAgent

Remember the IP/Port, on start allocate the socket.
This commit is contained in:
Holger Hans Peter Freyther 2011-06-29 10:08:14 +02:00
parent 5eeef62086
commit a0dbcd42e2
1 changed files with 7 additions and 3 deletions

View File

@ -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].
] ]