summaryrefslogtreecommitdiffstats
path: root/connection/SMPPConnection.st
diff options
context:
space:
mode:
Diffstat (limited to 'connection/SMPPConnection.st')
-rw-r--r--connection/SMPPConnection.st42
1 files changed, 25 insertions, 17 deletions
diff --git a/connection/SMPPConnection.st b/connection/SMPPConnection.st
index c244f0f..a2b521e 100644
--- a/connection/SMPPConnection.st
+++ b/connection/SMPPConnection.st
@@ -38,12 +38,8 @@ Osmo.OsmoStreamSocketBase subclass: SMPPConnection [
]
scheduleBindTrx [
- | header body |
+ | command body |
- header := SMPPPDUHeader new
- commandId: SMPPBindTransceiver messageType;
- commandStatus: 0;
- yourself.
body := SMPPBindTransceiver new
systemId: systemId;
password: password;
@@ -53,23 +49,35 @@ Osmo.OsmoStreamSocketBase subclass: SMPPConnection [
typeOfNumber: 0;
addressRange: #[];
yourself.
+ command := SMPPCommand initWith: body.
+ self scheduleCommand: command.
+ ]
- self send: (SMPPMessage new
- header: header;
- body: body) onResponse: [:resp | ].
+ scheduleCommand: aCommand [
+ aCommand scheduledOn: self.
+ self send: aCommand.
]
- send: aMessage onResponse: aBlock [
- | seq key |
+ send: aCommand [
+ | seq key header message |
+
seq := nextSeq.
nextSeq := nextSeq + 1.
- aMessage header sequenceNumber: seq.
+ header := SMPPPDUHeader new
+ sequenceNumber: seq;
+ commandId: aCommand messageType;
+ commandStatus: 0;
+ yourself.
- "Remember that we want a response. TODO add timeout handling"
- pendingCommands at: seq put: aBlock.
+ message := SMPPMessage new
+ header: header;
+ body: aCommand body;
+ yourself.
- writeQueue nextPut: aMessage toMessage asByteArray
+ "Remember that we want a response. TODO add timeout handling"
+ pendingCommands at: seq put: aCommand.
+ writeQueue nextPut: message toMessage asByteArray
]
connect [
@@ -113,13 +121,13 @@ Osmo.OsmoStreamSocketBase subclass: SMPPConnection [
]
receviedResponse: aMessage [
- | seq block |
+ | seq command |
"Search for a response"
seq := aMessage header sequenceNumber.
- block := pendingCommands removeKey: seq ifAbsent: [
+ command := pendingCommands removeKey: seq ifAbsent: [
"TODO: log it"
^false].
- block value: aMessage
+ command result: aMessage.
]
]