SMPP API
SMPP API
The SMPP Lua API exposes JSLEE SMPP-handling functionality for use within the Lua script engine.
Functions
SMPPMessage:wrap (javaObject)
Description
Wraps an SMPP message from Java in the Lua SMPP API.
Arguments
Argument | Comments |
---|---|
javaObject |
The handle to the Java object to wrap. |
Returns
Return | Type | Comments |
---|---|---|
wrappedObject |
Object | The wrapped object. |
Example
local s = SMPPMessage:wrap (obj)
SMPPMessage:unwrap ()
Description
Unwraps a Lua SMPP API SMPP message in order to pass to Java.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
unwrappedObject |
Object | The unwrapped Java object. |
Example
resp = SMPPMessage:create("SubmitSm")
resp:setMessage("Your balance is $123.45.")
resp:setSender("123")
resp:setDestination("456")
event = JSLEE.createEvent ("nz.co.nsquared.slee.smpp.event.SMPPMessageEvent", context, resp:unwrap())
SMPPMessage:create (smppMessageName, ...)
Description
Create a new instance of an SMPP messagew ith the supplied arguments. The object will be returned as a Lua-wrapped object, allowing API usage.
Arguments
Argument | Comments |
---|---|
smppMessageName |
The type of SMPP message to construct, e.g. SubmitSM or DeliverSm . |
... |
Additional arguments, passed to the Java constructor. |
Returns
Return | Type | Comments |
---|---|---|
smppMessage |
Object | The created SMPP message object. |
Example
resp = SMPPMessage:create("SubmitSm")
resp:setMessage("Your balance is $123.45.")
SMPPMessage:isRequest ()
Description
Indicates whether the SMPP message is a request or not. Returns true
if
the message is a request and false
otherwise.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
result |
Boolean | true if the object is a request type, false otherwise. |
Example
function smppHandler.handle (uuid, smppRequest)
local incomingMessage = smppRequest:getMessage()
if incomingMessage.isRequest():
-- do request processing
SMPPMessage:isResponse ()
Description
Indicates whether the SMPP message is a response or not. Returns true
if
the message is a response and false
otherwise.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
result |
Boolean | true if the object is a response type, false otherwise. |
Example
function smppHandler.handle (uuid, smppRequest)
local incomingMessage = smppRequest:getMessage()
if incomingMessage.isResponse():
-- do response processing
SMPPMessage:response ()
Description
Returns a built response object for an SMPP request object.
Will raise an error if the SMPP request object cannot be replied to.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
response |
Object | The built, wrapped SMPP object. |
SMPPMessage:commandCodeAsInt()
Description
Returns the command code of the SMPP message as an integer. One of:
SMPP Value | Integer Value |
---|---|
ESME_OK | 0 |
ESME_RINVMSGLEN | 1 |
ESME_RINVCMDLEN | 2 |
ESME_RINVCMDID | 3 |
ESME_RINVBNDSTS | 4 |
ESME_RALYBND | 5 |
ESME_RINVPRTFLG | 6 |
ESME_RINVREGDLVFLG | 7 |
ESME_RSYSERR | 8 |
ESME_RINVSRCADR | 10 |
ESME_RINVDSTADR | 11 |
ESME_RINVMSGID | 12 |
ESME_RBINDFAIL | 13 |
ESME_RINVPASWD | 14 |
ESME_RINVSYSID | 15 |
ESME_RCANCELFAIL | 17 |
ESME_RREPLACEFAIL | 19 |
ESME_RMSGQFUL | 20 |
ESME_RINVSERTYP | 21 |
ESME_RINVNUMDESTS | 51 |
ESME_RINVDLNAME | 52 |
ESME_RINVDESTFLAG | 64 |
ESME_RINVSUBREP | 66 |
ESME_RINVESMCLASS | 67 |
ESME_RCNTSUBDL | 68 |
ESME_RSUBMITFAIL | 69 |
ESME_RINVSRCTON | 72 |
ESME_RINVSRCNPI | 73 |
ESME_RINVDSTTON | 80 |
ESME_RINVDSTNPI | 81 |
ESME_RINVSYSTYP | 83 |
ESME_RINVREPFLAG | 84 |
ESME_RINVNUMMSGS | 85 |
ESME_RTHROTTLED | 88 |
ESME_RINVSCHED | 97 |
ESME_RINVEXPIRY | 98 |
ESME_RINVDFTMSGID | 99 |
ESME_RX_T_APPN | 100 |
ESME_RX_P_APPN | 101 |
ESME_RX_R_APPN | 102 |
ESME_RQUERYFAIL | 103 |
ESME_RINVTLVSTREAM | 192 |
ESME_RTLVNOTALLWD | 193 |
ESME_RINVTLVLEN | 194 |
ESME_RMISSINGTLV | 195 |
ESME_RINVTLVVAL | 196 |
ESME_RDELIVERYFAILURE | 245 |
ESME_RUNKNOWNERR | 255 |
ESME_RSERTYPUNAUTH | 256 |
ESME_RPROHIBITED | 257 |
ESME_RSERTYPUNAVAIL | 258 |
ESME_RSERTYPDENIED | 259 |
ESME_RINVDCS | 260 |
ESME_RINVSRCADDRSUBUNIT | 261 |
ESME_RINVDSTADDRSUBUNIT | 262 |
ESME_RINVBCASTFREQINT | 263 |
ESME_RINVBCASTALIAS_NAME | 264 |
ESME_RINVBCASTAREAFMT | 265 |
ESME_RINVNUMBCAST_AREAS | 266 |
ESME_RINVBCASTCNTTYPE | 267 |
ESME_RINVBCASTMSGCLASS | 268 |
ESME_RBCASTFAIL | 269 |
ESME_RBCASTQUERYFAIL | 270 |
ESME_RBCASTCANCELFAIL | 271 |
ESME_RINVBCAST_REP | 272 |
ESME_RINVBCASTSRVGRP | 273 |
ESME_RINVBCASTCHANIND | 274 |
ESME_RESERVED | 1024 |
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
code |
Integer | The integer representation of the message’s command code. |
Example
resp = SMPPMessage:create("SubmitSm")
local i = resp::commandCodeAsInt()
SMPPMessage:commandCode()
Returns the command code of the SMPP message as a hexadecimal value. One of:
SMPP Value | Hexadecimal Value |
---|---|
ESME_OK | 0 |
ESME_RINVMSGLEN | 1 |
ESME_RINVCMDLEN | 2 |
ESME_RINVCMDID | 3 |
ESME_RINVBNDSTS | 4 |
ESME_RALYBND | 5 |
ESME_RINVPRTFLG | 6 |
ESME_RINVREGDLVFLG | 7 |
ESME_RSYSERR | 8 |
ESME_RINVSRCADR | A |
ESME_RINVDSTADR | B |
ESME_RINVMSGID | C |
ESME_RBINDFAIL | D |
ESME_RINVPASWD | E |
ESME_RINVSYSID | F |
ESME_RCANCELFAIL | 11 |
ESME_RREPLACEFAIL | 13 |
ESME_RMSGQFUL | 14 |
ESME_RINVSERTYP | 15 |
ESME_RINVNUMDESTS | 33 |
ESME_RINVDLNAME | 34 |
ESME_RINVDESTFLAG | 40 |
ESME_RINVSUBREP | 42 |
ESME_RINVESMCLASS | 43 |
ESME_RCNTSUBDL | 44 |
ESME_RSUBMITFAIL | 45 |
ESME_RINVSRCTON | 48 |
ESME_RINVSRCNPI | 49 |
ESME_RINVDSTTON | 50 |
ESME_RINVDSTNPI | 51 |
ESME_RINVSYSTYP | 53 |
ESME_RINVREPFLAG | 54 |
ESME_RINVNUMMSGS | 55 |
ESME_RTHROTTLED | 58 |
ESME_RUNKNOWNERR | FF |
ESME_RINVSCHED | 61 |
ESME_RINVEXPIRY | 62 |
ESME_RINVDFTMSGID | 63 |
ESME_RX_T_APPN | 64 |
ESME_RX_P_APPN | 65 |
ESME_RX_R_APPN | 66 |
ESME_RQUERYFAIL | 67 |
ESME_RINVTLVSTREAM | C0 |
ESME_RTLVNOTALLWD | C1 |
ESME_RINVTLVLEN | C2 |
ESME_RMISSINGTLV | C3 |
ESME_RINVTLVVAL | C4 |
ESME_RDELIVERYFAILURE | FE |
ESME_RSERTYPUNAUTH | 100 |
ESME_RPROHIBITED | 101 |
ESME_RSERTYPUNAVAIL | 102 |
ESME_RSERTYPDENIED | 103 |
ESME_RINVDCS | 104 |
ESME_RINVSRCADDRSUBUNIT | 105 |
ESME_RINVDSTADDRSUBUNIT | 106 |
ESME_RINVBCASTFREQINT | 107 |
ESME_RINVBCASTALIAS_NAME | 108 |
ESME_RINVBCASTAREAFMT | 109 |
ESME_RINVNUMBCAST_AREAS | 10A |
ESME_RINVBCASTCNTTYPE | 10B |
ESME_RINVBCASTMSGCLASS | 10C |
ESME_RBCASTFAIL | 10D |
ESME_RBCASTQUERYFAIL | 10E |
ESME_RBCASTCANCELFAIL | 10F |
ESME_RINVBCAST_REP | 110 |
ESME_RINVBCASTSRVGRP | 111 |
ESME_RINVBCASTCHANIND | 112 |
ESME_RESERVED | 400 |
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
code |
Hexadecimal | The hexadecimal representation of the message’s command code. |
Example
resp = SMPPMessage:create("SubmitSm")
local h = resp::commandCode()
SMPPMessage:getMessageID ()
Description
Returns the message ID from an SMPP response object.
If no message ID exists, returns an empty string.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
number |
String | The message ID of the SMPP object. |
SMPPMessage:setMessageID (messageId)
Description
Sets the message ID of an SMPP object to the provided string.
Arguments
Argument | Comments |
---|---|
messageId |
The string to set as the message ID. |
Returns
Nothing.
Example
resp = SMPPMessage:create("SubmitSmResp")
resp:setMessageID("1")
Example
local id = response:getMessageID ()
SMPPMessage:getSequenceNumber ()
Description
Returns the sequence number from the header of an SMPP object.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
number |
Long | The sequence number of the SMPP object. |
Example
local seq = message:getSequenceNumber ()
SMPPMessage:setSequenceNumber (number)
Description
Sets the sequence number in the header of an SMPP object.
Arguments
Argument | Comments |
---|---|
number |
The sequence number to set. |
Returns
Nothing.
Example
message:setSequenceNumber (123)
SMPPMessage:getMessage (textEncoding)
Description
Returns the short message body of an SMPP object.
If no body exists, returns an empty string.
Arguments
Argument | Comments |
---|---|
textEncoding |
The name of the SMPP encoding scheme that matches the message’s encoding. If not specified, defaults to ascii . |
Returns
Return | Type | Comments |
---|---|---|
message |
String | The message’s decoded contents. |
Example
function smppHandler.handle (uuid, smppRequest)
local incomingMessage = smppRequest:getMessage()
if incomingMessage is not nil:
logger:debug("[[smpp-handler.lua] Incoming message is " .. incomingMessage)
SMPPMessage:setMessage (message, textEncoding)
Description
Sets the short message body of an SMPP object to the provided string.
Arguments
Argument | Comments |
---|---|
message |
The string to set as the message body. |
textEncoding |
The name of the SMPP encoding scheme to use for encoding. If not specified, defaults to ascii . |
Returns
Nothing.
Example
resp = SMPPMessage:create("SubmitSm")
resp:setMessage("Your balance is $123.45.")
SMPPMessage:getSender ()
Description
Returns the sender digits of an SMPP object.
If no sender digits exist, returns an empty string.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
digits |
String | The string of the message’s sender. |
Example
function smppHandler.handle (uuid, smppRequest)
local incomingSender = smppRequest:getSender()
logger:debug("[[smpp-handler.lua] Message sender is " .. incomingSender)
SMPPMessage:setSender (sender)
Description
Sets the sender digits of an SMPP object to the provided string.
Arguments
Argument | Comments |
---|---|
sender |
The string to set as the message sender. |
Returns
Nothing.
Example
resp = SMPPMessage:create("SubmitSm")
resp:setSender("12345")
SMPPMessage:getDestination ()
Description
Returns the destination digits of an SMPP object.
If no destination digits exist, returns an empty string.
Arguments
None.
Returns
Return | Type | Comments |
---|---|---|
digits |
String | The string of the message’s destination. |
Example
function smppHandler.handle (uuid, smppRequest)
local incomingDestination = smppRequest:getDestination()
logger:debug("[[smpp-handler.lua] Message destination is " .. incomingDestination)
SMPPMessage:setDestination (destination)
Description
Sets the destination of an SMPP object to the provided string.
Arguments
Argument | Comments |
---|---|
destination |
The string to set as the message destination. |
Returns
Nothing.
Example
resp = SMPPMessage:create("SubmitSm")
resp:setDestination("12345")