diff --git a/src/BSCIPAConnection.st b/src/BSCIPAConnection.st index 12a4fb1..1a94d28 100644 --- a/src/BSCIPAConnection.st +++ b/src/BSCIPAConnection.st @@ -17,9 +17,27 @@ " PackageLoader + fileInPackage: 'OsmoCore'; fileInPackage: 'OsmoMGCP'; fileInPackage: 'OsmoNetwork'. +Osmo.IPAProtoHandler subclass: BSCIPAProtoHandler [ + | bsc | + + + BSCIPAProtoHandler class >> initWith: aBSC [ + + ^ self new + instVarNamed: #bsc put: aBSC; + yourself + ] + + handlePong: aMsg [ + + bsc receivedPong. + ] +] + Object subclass: BSCConnection [ | config msc trunk | @@ -60,7 +78,8 @@ Object subclass: BSCConnection [ ] BSCConnection subclass: BSCIPAConnection [ - | socket demuxer writeQueue muxer dispatcher sccp tx terminated ipa | + | socket demuxer writeQueue muxer dispatcher sccp tx terminated + ipa ping_timeout pong_timeout | + "I send a ping and start a timer..." + self + send: (ByteArray with: Osmo.IPAConstants msgPing) + with: Osmo.IPAConstants protocolIPA. + self logDebug: 'BSC lac: %1 sent ping waiting now.' % {self lac} area: #bsc. + + pong_timeout := (Osmo.TimerScheduler instance) + scheduleInSeconds: 5 block: [ + self logNotice: 'BSC lac: %1 ping timeout.' % {self lac} area: #bsc. + socket close]. + ] + + receivedPong [ + + terminated = true ifTrue: [^false]. + + pong_timeout cancel. + self logDebug: 'BSC lac: %1 ponged.' % {self lac} area: #bsc. + ping_timeout := (Osmo.TimerScheduler instance) + scheduleInSeconds: 30 block: [ + self sendPing]. + ] ]