Click or drag to resize
Handling Events

The .NET SMS API enables applications to add a lot of destinations to a single message to be submitted at once. For example, hundreds and thousands of phone numbers can be added to the destinations list for a composed message and this can be submitted at once to the SMS server.

Although the API is designed to quickly process and submit such volumes of destinations for messages, applications can request to be notified of the progress of SMS submission as well as when SMS submission is completed. This will be very helpful, particularly, in GUI applications so that users can see the progress of message submission.

To be notified of the progress of message submission as well as its completion, applications can install a handler to the SubmitProgressChanged and SubmitCompleted events. The events use the delegates declared in the Zenoph.SMSLib.Events namespace so the appropriate use of the namespace must be set in addition to the use of the other namespaces used earlier.

using Zenoph.SMSLib;
using Zenoph.SMSLib.Enums;
using Zenoph.SMSLib.Events;    // this must be present.

Handlers can be installed for the SubmitProgressChanged and SubmitCompleted events as follows:

using System;
using System.Collections.Generic;

using Zenoph.SMSLib;
using Zenoph.SMSLib.Enums;
using Zenoph.SMSLib.Events;

public class SMSTEST
{
    public static void Main()
    {
        // initialise the SMS object.
        ZenophSMS sms = new ZenophSMS();
        sms.setUser("account_login");
        sms.setPassword("account_password");
        sms.authenticate();

        sms.setMessage("Hello there!");
        sms.setMessageType(MSGTYPE.TEXT);
        sms.setSenderId("EVENTS");
        sms.addRecipient("0287439564");

        // now install handlers to the events so that we can be notified 
        // of submission progress and completion.
        sms.SubmitProgressChanged += new SubmitProgressChanged(ProgressChangedHandler);
        sms.SubmitCompleted += new SubmitCompleted(SubmitCompletedHandler);

        // message submission can now be initiated.
        sms.submit();
    }

    static void ProgressChangedHandler(ZenophSMS sender, SubmitProgressChangedEventArgs ea)
    {

    }

    static void SubmitCompletedHandler(ZenophSMS sender, SubmitCompletedEventArgs ea)
    {

    }
}

The handler to the SubmitProgressChanged event will be notified when message submission progress changes. When message submission completes, the handler to the SubmitCompleted event will also be notified. For GUI applications that show progress bar for submission, this is an appropriate time to close the progress bar.