/client

Usage Overview

Communication Outline

The following diagram shows functions and events flow in communication session:

Communication outline diagram

Create Instance


SMSCclientSMPP clientSMPP = new smscc.SMPP.SMSCclientSMPP();

Connect

The tcpConnect method establishes connection between the library and the SMSC on the TCP/IP network level:


int result = clientSMPP.tcpConnect("smsc.tele.com", 3300, "");

if(result == 0) {
  // Connection established correctly
} else {
  // Connection error
}

Login

Session initialization means authorizing client to the SMSC:


int result = clientSMPP.smppInitializeSession("user", "password",
  1, 1, "");

if(result == 0) {
  // Session initialized correctly
} else {
  // Error initializing session
}

Send Message

A code shown below illustrates the way the SubmitMessage function is used to send messages:


List MessageIDs;

string smContent = "Hello World from SMSC Client Library!";

int options = (int)SubmitOptionEnum.soRequestStatusReport;

int result = clientSMPP.smppSubmitMessage("48999123456", 1, 1,
  "79123", 1, 1, smContent, EncodingEnum.etUCS2Text, smUDH, 0,
  messageIDs);

if(result == 0) {
  // Message submitted correctly
} else {
  // Error while submitting message
}

After the code has been executed MessageID variable will contain a message identifier returned by the SMSC. In other protocols TimeStamp variable respectively will represent time of transferring the message to the SMSC. Both these are later used to identify and match status reports received asynchronously from the SMSC.

Send Unicode Message

The example below shows the way of creating a message with a text containing national characters not included in the standard characters set serviced by the GSM alphabet table.


// [...]

string smContent = "C'est un message en Français. N'est pas?";

// [...]

result = clientSMPP.smppSubmitMessage("48999123456", 1, 1,
  "79123", 1, 1, smContent, EncodingEnum.etUCS2Text, smUDH, 0,
  messageIDs);

Receive Message

Handling of MessageReceived and MessageCompleted events:


private void clientSMPP_OnSmppMessageCompleted(object sender,
  SMSCclient.SMPP.smppMessageCompletedEventArgs e)
{
  // Message received here is completed if it was a long/multipart
  // message or if no completing is necessary.

  // In most cases it is enough to implement just this case.

  // Received message parameters are handled within
  // 'MessageCompletedEventArgs' class fields like e.Destination,
  // e.Originator, e.Content, e.Encoding, e.UserDataHeader etc.
}

private void clientSMPP_OnSmppMessageReceived(object sender,
  SMSCclient.SMPP.smppMessageReceivedEventArgs e)
{
  // Here every basic partial message is reported to the user.

  // Received message parameters are handled within
  // 'MessageReceivedEventArgs' class fields like e.Destination,
  // e.Originator, e.Content, e.Encoding, e.UserDataHeader etc.
}

Receive Status Report

The example below shows a code handling OnStatusReportReceived event.


private void clientSMPP_OnSmppStatusReportReceived(object
  sender, SMSCclient.SMPP.smppStatusReportReceivedEventArgs e)
{
  // Here insert code to handle received status report

  // Received message parameters are handled
  // within 'StatusReportReceivedEventArgs'
  // class fields like e.Destination, e.Originator,
  // e.SMStatus, e.FailureReason etc.
}

The OnStatusReportReceived event will be called up as a consequence of setting soRequestStatusReport option during call of any of the SubmitMessage function family. SMSC may also deliver status reports queued in the SMSC from previous session thus not related to messages submitted in current session.

Logout

Session finalization may not be present in all protocols supported by the library.


int result = clientSMPP.smppFinalizeSession();

if(result == 0) {
  // Session finalized correctly
} else {
  // Error during session finalization
}

Disconnect

The code shown below ends the connection on the TCP/IP level.


clientSMPP.tcpDisconnect();

// Connection disconnected

As a consequence of Disconnect function call tcpDisconnected event will be fired. It will also be fired when the SMSC disconnects the connection.

Other Protocols

All the above examples use SMPP protocol prefix part of the name. To translate the examples to other protocol this part has to be changed to ucp, cimd2 or sema respectively. For example:

smppInitializeSession  ucpInitializeSession

See Also

SMSCclientSMPP, SMSCclientUCP, SMSCclientCIMD2, SMSCclientSEMA