@ -17,7 +17,7 @@
"
Osmo . OsmoStreamSocketBase subclass: SMPPConnection [
| writeQueue nextSeq systemId password systemType |
| writeQueue nextSeq systemId password systemType pendingCommands |
<category: 'SMPP-Connection'>
createConnection: aHostname port: aPort [
@ -56,15 +56,19 @@ Osmo.OsmoStreamSocketBase subclass: SMPPConnection [
self send: (SMPPMessage new
header: header ;
body: body )
body: body ) onResponse: [: resp | ].
]
send: aMessage [
| seq |
send: aMessage onResponse: aBlock [
| seq key |
seq := nextSeq .
nextSeq := nextSeq + 1 .
aMessage header sequenceNumber: seq .
"Remember that we want a response. TODO add timeout handling"
pendingCommands at: seq put: aBlock .
writeQueue nextPut: aMessage toMessage asByteArray
]
@ -72,6 +76,7 @@ Osmo.OsmoStreamSocketBase subclass: SMPPConnection [
super connect .
nextSeq := 1 .
writeQueue := SharedQueue new .
pendingCommands := Dictionary new .
self scheduleBindTrx .
]
@ -108,5 +113,13 @@ Osmo.OsmoStreamSocketBase subclass: SMPPConnection [
]
receviedResponse: aMessage [
| seq block |
"Search for a response"
seq := aMessage header sequenceNumber .
block := pendingCommands removeKey: seq ifAbsent: [
"TODO: log it"
^ false ].
block value: aMessage
]
]