mCore™ .NET SMS Library 1.2

mCore.SMS.NewUSSDReceived Event

Description:

The NewUSSDReceived Event is raised whenever a new USSD message is received, if NewUSSDIndication property is set as True.

The NewUSSDReceived event is raised on a secondary thread when a new USSD message is received.

Namespace: mCore
Assembly: mCoreLib (in mCoreLib.dll)

Remarks:

Exceptions:

mCore.GeneralException

Usage Example:

Visual Basic

Public Class MyClass
   Public WithEvents objSMS As New mCore.SMS
  
   Public Sub New()
      Try     
         SetCommParameters()
         objSMS.NewUSSDIndication = True
         objSMS.SendUSSD("*101#")
      Catch ex As mCore.GeneralException
         MsgBox(ex.Message)
      End Try
   End Sub

   'New USSD Message Event Handling
   'A message box will pop-up whenever
   'a new USSD message is received

   Private Sub objSMS_NewUSSDReceived(ByVal sender As Object, _
               ByVal e As mCore.NewUSSDReceivedEventArgs) _
               Handles objSMS.NewUSSDReceived

      MsgBox(e.Message & vbCrLf & vbCrLf & _
         "STATUS: " & e.Status.ToString, _
         MsgBoxStyle.Information, "NEW USSD RECEIVED")

   End Sub

   Public Sub SetCommParameters()
      Try
         objSMS.Port = "COM1"
         objSMS.BaudRate = mCore.BaudRate.BaudRate_19200
         objSMS.DataBits = mCore.DataBits.Eight
         objSMS.StopBits = mCore.StopBits.One
         objSMS.Parity = mCore.Parity.None
         objSMS.FlowControl = mCore.FlowControl.RTS_CTS

      Catch ex As mCore.GeneralException
         MsgBox(ex.Message)
      Catch ex As Exception
      End Try
   End Function
End Class

 
C#

class MyClass
{
   public mCore.SMS objSMS = new mCore.SMS();

   public MyClass()

   {
      try
      {
         SetCommParameters();
         objSMS.NewUSSDIndication = true;
         objSMS.SendUSSD("*101#");
      }
      catch (mCore.GeneralException e)
      {
         MessageBox.Show(e.ToString());
      }

      objSMS.NewUSSDReceived +=
         new mCore.SMS.NewUSSDReceivedHandler(objSMS_NewUSSDReceived);
   }

   //New USSD Message Event Handling
   //A message box will pop-up whenever
   //a new USSD message is received

   private void objSMS_NewUSSDReceived
      (object sender, mCore.NewUSSDReceivedEventArgs e)
   {
      MessageBox.Show("NEW USSD RECEIVED" + "\r\n" +
         e.Message + "\r\n\r\n" +
         "STATUS: " + e.Status.ToString);
   }

   public static void SetCommParameters()
   {
      try
      {
         objSMS.Port = "COM1";
         objSMS.BaudRate = mCore.BaudRate.BaudRate_19200;
         objSMS.DataBits = mCore.DataBits.Eight;
         objSMS.StopBits = mCore.StopBits.One;
         objSMS.Parity = mCore.Parity.None;
         objSMS.FlowControl = mCore.FlowControl.RTS_CTS;
      }

      catch (mCore.GeneralException e)
      {
         MessageBox.Show(e.ToString());
      }
      catch (Exception e)
      {
      }
   }
}

See Also:

mCore.SMS.SendUSSD Method
mCore.SMS.CancelUSSDSession Method
mCore.SMS.NewUSSDIndication Property
mCore.NewUSSDReceivedEventArgs Class
mCore.SMS.NewUSSDReceivedEventHandler Delegate

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved