aboutsummaryrefslogtreecommitdiffstats
path: root/SCCPHandler.st
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-06-20 11:14:49 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-06-21 21:46:51 +0200
commiteda5c4bd0889a5258f0e6d32d3814deb4fe22a5f (patch)
tree6f92c07ac0dff4c307570dd1d51c1f5fbcb94250 /SCCPHandler.st
parentbd2acafc8e5e4d7cdd6e28b211e6a9ee7e083010 (diff)
sccp: Move the state transition into a central place
Diffstat (limited to 'SCCPHandler.st')
-rw-r--r--SCCPHandler.st45
1 files changed, 29 insertions, 16 deletions
diff --git a/SCCPHandler.st b/SCCPHandler.st
index 957e163..df6b7b7 100644
--- a/SCCPHandler.st
+++ b/SCCPHandler.st
@@ -88,37 +88,49 @@ Object subclass: SCCPConnectionBase [
^ dst
]
+ changeState: newState do: aBlock [
+ state := newState.
+ aBlock value.
+ ]
+
connectionRequest: aData [
| res |
<category: 'handling'>
"Send the confirmation now"
- state := self class stateRequested.
- res := Osmo.SCCPConnectionRequest
+
+ self changeState: self class stateRequested do: [
+ res := Osmo.SCCPConnectionRequest
initWith: (self srcRef) dest: (Osmo.SCCPAddress createWith: 254) data: aData.
- self nextPut: res toMessage.
+ self nextPut: res toMessage.
+ ].
]
confirm: aCC [
<category: 'handling'>
- self dstRef: aCC src.
- state := self class stateConnected.
- confirmSem signal.
+
+ self changeState: self class stateConnected do: [
+ self dstRef: aCC src.
+ confirmSem signal.
+ ]
]
release [
| rlsd |
<category: 'handling'>
- state := self class stateReleased.
- rlsd := Osmo.SCCPConnectionReleased initWithDst: self dstRef src: self srcRef cause: 0.
- self nextPut: rlsd toMessage.
+ self changeState: self class stateReleased do: [
+ rlsd := Osmo.SCCPConnectionReleased initWithDst: self dstRef src: self srcRef cause: 0.
+ self nextPut: rlsd toMessage.
+ ]
]
releaseComplete: aMSG [
<category: 'handling'>
"TODO: verify that we are in the right state"
- state := self class stateReleaseComplete.
- self terminate.
+
+ self changeState: self class stateReleaseComplete do: [
+ self terminate.
+ ]
]
released: aRLSD [
@@ -126,11 +138,12 @@ Object subclass: SCCPConnectionBase [
<category: 'handling'>
"Give up local resources here. We are done."
- state := self class stateReleaseComplete.
- rlc := Osmo.SCCPConnectionReleaseComplete
- initWithDst: aRLSD src src: aRLSD dst.
- self nextPut: rlc toMessage.
- self terminate.
+ self changeState: self class stateReleaseComplete do: [
+ rlc := Osmo.SCCPConnectionReleaseComplete
+ initWithDst: aRLSD src src: aRLSD dst.
+ self nextPut: rlc toMessage.
+ self terminate.
+ ]
]
nextPutData: aMsg [