summaryrefslogtreecommitdiffstats
path: root/connection
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-06-17 21:54:18 +0200
committerHolger Hans Peter Freyther <holger@moiji-mobile.com>2014-06-17 21:55:54 +0200
commit244f9b682bdc7b4dfc985780e9c8c920045b9747 (patch)
treece1f5f9da06ccfe7d3597380485a6d4591ccedd9 /connection
parentc9cb3d5cab06255a64aba0d01e132c3007855e37 (diff)
connection: Dispatch on the message body we have received
Diffstat (limited to 'connection')
-rw-r--r--connection/Extensions.st29
-rw-r--r--connection/SMPPConnection.st38
2 files changed, 57 insertions, 10 deletions
diff --git a/connection/Extensions.st b/connection/Extensions.st
new file mode 100644
index 0000000..bdbe52c
--- /dev/null
+++ b/connection/Extensions.st
@@ -0,0 +1,29 @@
+"
+ (C) 2014 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/>.
+"
+
+SMPPEnquireLink extend [
+ connectionDispatchOn: aConnection with: aMessage [
+ aConnection respondToEnquire: aMessage
+ ]
+]
+
+SMPPBindTransceiverResponse extend [
+ connectionDispatchOn: aConnection with: aMessage [
+ aConnection receviedResponse: aMessage
+ ]
+]
diff --git a/connection/SMPPConnection.st b/connection/SMPPConnection.st
index ac7ed2b..05564c5 100644
--- a/connection/SMPPConnection.st
+++ b/connection/SMPPConnection.st
@@ -38,15 +38,11 @@ Osmo.OsmoStreamSocketBase subclass: SMPPConnection [
]
scheduleBindTrx [
- | header body seq data |
-
- seq := nextSeq.
- nextSeq := nextSeq + 1.
+ | header body |
header := SMPPPDUHeader new
commandId: SMPPBindTransceiver messageType;
commandStatus: 0;
- sequenceNumber: seq;
yourself.
body := SMPPBindTransceiver new
systemId: systemId;
@@ -58,11 +54,18 @@ Osmo.OsmoStreamSocketBase subclass: SMPPConnection [
addressRange: #[];
yourself.
- data := (SMPPMessage new
+ self send: (SMPPMessage new
header: header;
- body: body;
- toMessage) asByteArray.
- writeQueue nextPut: data.
+ body: body)
+ ]
+
+ send: aMessage [
+ | seq |
+ seq := nextSeq.
+ nextSeq := nextSeq + 1.
+
+ aMessage header sequenceNumber: seq.
+ writeQueue nextPut: aMessage toMessage asByteArray
]
connect [
@@ -84,11 +87,26 @@ Osmo.OsmoStreamSocketBase subclass: SMPPConnection [
[
msg := SMPPMessage readFrom: socket.
- msg inspect.
+ msg body connectionDispatchOn: self with: msg
] on: Error do: [:e |
e
inspect;
pass
]
]
+
+ respondToEnquire: aMessage [
+ | msg |
+ msg := SMPPMessage new
+ header: (SMPPPDUHeader new
+ commandId: SMPPBodyBase enquireLinkResp;
+ commandStatus: 0;
+ sequenceNumber: aMessage header sequenceNumber;
+ yourself);
+ body: #[].
+ self send: msg
+ ]
+
+ receviedResponse: aMessage [
+ ]
]