1
0
Fork 0

osmo: Introduce a subclass for the CTRL handling

This commit is contained in:
Holger Hans Peter Freyther 2013-03-27 08:27:13 +01:00
parent 3ae32dfb73
commit a47c76fc1b
4 changed files with 49 additions and 17 deletions

View File

@ -40,7 +40,7 @@ UA = \
OSMO = \
osmo/OsmoUDPSocket.st osmo/OsmoCtrlLogging.st \
osmo/OsmoCtrlGrammar.st osmo/OsmoAppConnection.st \
osmo/OsmoCtrlGrammarTest.st
osmo/OsmoCtrlConnection.st osmo/OsmoCtrlGrammarTest.st

View File

@ -17,19 +17,13 @@
"
Object subclass: OsmoAppConnection [
| socket writeQueue demuxer muxer dispatcher ctrlBlock |
| socket writeQueue demuxer muxer dispatcher |
<category: 'OsmoNetwork-Socket'>
<comment: 'I connect to a OpenBSC App on the Control Port and wait for
TRAPS coming from the server and will act on these.'>
onCtrlData: aBlock [
<category: 'ctrl-dispatch'>
ctrlBlock := aBlock
]
handleCTRL: aCtrl [
<category: 'ctrl-dispatch'>
ctrlBlock value: aCtrl.
initializeDispatcher [
"Allow another class to register handlers"
]
createConnection: aHostname port: aPort [
@ -56,9 +50,7 @@ TRAPS coming from the server and will act on these.'>
dispatcher := IPADispatcher new.
dispatcher initialize.
dispatcher
addHandler: IPAConstants protocolOsmoCTRL
on: self with: #handleCTRL:.
self initializeDispatcher.
ipa := IPAProtoHandler new.
ipa registerOn: dispatcher.
@ -70,10 +62,6 @@ TRAPS coming from the server and will act on these.'>
^ self connect: 4250.
]
sendCtrlData: aData [
muxer nextPut: aData with: IPAConstants protocolOsmoCTRL.
]
sendOne [
| msg |
<category: 'dispatch'>

View File

@ -0,0 +1,43 @@
"
(C) 2011-2013 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 <http://www.gnu.org/licenses/>.
"
OsmoAppConnection subclass: OsmoCtrlConnection [
| ctrlBlock |
<category: 'OsmoNetwork-Socket'>
onCtrlData: aBlock [
<category: 'ctrl-dispatch'>
ctrlBlock := aBlock
]
handleCTRL: aCtrl [
<category: 'ctrl-dispatch'>
ctrlBlock value: aCtrl.
]
initializeDispatcher [
super dispatcher.
dispatcher
addHandler: IPAConstants protocolOsmoCTRL
on: self with: #handleCTRL:.
]
sendCtrlData: aData [
muxer nextPut: aData with: IPAConstants protocolOsmoCTRL.
]
]

View File

@ -27,6 +27,7 @@
<filein>osmo/OsmoCtrlLogging.st</filein>
<filein>osmo/OsmoCtrlGrammar.st</filein>
<filein>osmo/OsmoAppConnection.st</filein>
<filein>osmo/OsmoCtrlConnection.st</filein>
<test>