|
message master™ SMSC Connectivity SDK Sample
The message master™ SMSC Connectivity SDK accelerates the development of custom SMS
and
EMS messaging applications. It prevents you from the time-consuming
implementation of sophisticated low-level communication protocols
(UCP,
SMPP, Sema OIS, CIMD2).
We have included some source code examples to show you how the ActiveXMS Mobile
Messaging SDK is used to encode and decode EMS content received through themessage master™ SMSC Connectivity SDK.
Here is an example for creating (encoding) the PDU strings for
a message containing a Picture, Animation and some Formatted Text.
Please note that you may need to adjust the encoding settings
depending on the type of gateway you are connecting to.
Dim objEncoder As New EMSMessageManager
Dim objMessage As EMSMessage
Dim objPicture As EMSPictureComponent
Dim objAnimation As EMSAnimationComponent
Dim objText As EMSTextComponent
Dim objPDU As EMSPDU
Dim lResult As Long
'Create a new message
Set objMessage = objEncoder.CreateEMSMessage("")
'Add the picture
Set objPicture = objMessage.AddComponent(emsComponent_Picture)
objPicture.PictureType = emsPictureType_UserDefined
objPicture.BitmapFilename = "c:\image.bmp"
objPicture.CopyProtected = True
'Add the animation
Set objAnimation = objMessage.AddCompnent(emsComponent_Animation)
objAnimation.Animation = emsAnim_Laughing
'Add the text
Set objText = objMessage.AddComponent(emsComponent_Text)
objText.MessageText = "Happy Birthday"
objText.Alignment = emsTextAlign_Center
objText.FontSize = emsTextFont_Large
objText.Bold = True
'Refresh the PDUs
objMessage.GeneratePDU
'Iterate through PDUs collection to send
For Each objPDU In objMessage.PDUs
lResult =
SMPP1.SMSCSubmitMessage(sTargetNumber, txtOriginator.Text, _
128, SrcTON.Text,
SrcNPI.Text, DestTON.Text, DestNPI.Text, _
objEMSPDU.EMSUserData, Now(), 48)
Next
Here is an example for decoding an incoming EMS Message. Note that this code
is implemented in the SMSCMessageReceived event:
Private Sub SMPP1_SMSCMessageReceived(ByVal bstrDestination As String, ByVal
bstrOriginator As String, ByVal bstrMessage As String, ByVal lOption As Long,
ByVal SMSCTimeStamp As Date, ByVal Validity As Date)
Dim objDecoder As New
EMSMessageManager
Dim objEMSMessage As EMSMessage
Dim objPicture As EMSPictureComponent
Dim objText As EMSTextComponent
Dim objComponent As EMSComponent
Dim objPDU As EMSPDU
'Is this an EMS message?
'Note we could also query the lOption param for a value
of 128 as well
If objDecoder.IdentifyPDU(bstrMessage) <>
emsMessageType_EMSMessage Then
Exit Sub
End If
'Decode the incoming message
Set objEMSMessage = objDecoder.DecodePDU(bstrMessageString)
'Do we have the complete message?
If objEMSMessage.DecodeState = emsDecodeState_MultipartIncomplete Then
Exit Sub 'Come back
later with the next PDU
End If
'We now have the complete message
For Each objComponent In objEMSMessage.Components
Select Case
objComponent.ComponentType
Case emsComponent_Picture:
Set objPicture =
objComponent
'Report on some of the incoming message properties
Debug.Print "Image: " + objPicture.BitmapFileName
Debug.Print "Sent from: " + objPicture.SenderAddress
Case emsComponent_Text:
Set
objText = objComponent
'Report on some of the incoming message properties
Debug.Print "Text: " +
objText.MessageText
Debug.Print "Bold: " +
CStr(objText.Bold)
End Select
Next
End Sub
Click here to see the Derdack SMS SDK Code Sample |