PackageSmsHttp
Classpublic class SmsHttpConnection
Implementsflash.events.IEventDispatcher

Class for handling a session to the server, credentials and application specific values needed for communicating to the server is also kept while the session is active. Methods for sending specific request to the server, response to requests are dispatched by an event. All requests has their own eventtype to handle the responses individually. The different types of events are defined as static string variables in SmsHttpEvent.


Example
  ...
   private var SmsCon:SmsHttpConnection;
  public function Main():void
  {   
   SmsCon = new SmsHttpConnection("0012345678", "password");
   SmsCon.addEventListener(SmsHttpEvent.SENDSMS, this.OnSmsHttpResult);
   SmsCon.SendSMS("00133787654321", "Hello!");
  }
  private function OnSmsHttpResult(event:SmsHttpEvent):void {
   trace(event);   
  }
   ...
   
Event dispatched, at response from server:
[SmsHttpEvent type="SendSMS" bubbles=false cancelable=false eventPhase=2 Result=[SMSHttpResult CreditsLeftToday=2 CreditsLeft=100 ErrorDescription="OK" Tel="0087654321" ErrorCode=200]]

See also

SmsHttpEvent


Public Properties
 PropertyDefined by
  CurrentPassword : String
[static][read-only] Global variable to access the credentials that is kept for the lifetime of the application.
SmsHttpConnection
  CurrentUserTel : String
[static][read-only] Global variable to access the credentials that is kept for the lifetime of the application.
SmsHttpConnection
  GetInstance : SmsHttpConnection
[static][read-only] Gets the instance first created, as a singelton.
SmsHttpConnection
Public Methods
 MethodDefined by
  
SmsHttpConnection(UserTel:String = null, Password:String = null)
Session-state handler with methods for services and connectivity towards to the server.
SmsHttpConnection
  
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
SmsHttpConnection
  
CreateContact(ContactTel:String, ContactName:String):void
Sends a request to the server for creating a new contact.
SmsHttpConnection
  
DeleteContact(ContactTel:String):void
Sends a request to the server to delete a contact.
SmsHttpConnection
  
DeleteSMS(MsgID:int):void
Send a request to the server to delete an SMS.
SmsHttpConnection
  
dispatchEvent(evt:Event):Boolean
SmsHttpConnection
  
GetBalance():void
Sends a request to the server to get the current balance for account that this session belongs to.
SmsHttpConnection
  
GetContacts():void
Sends a request to the server to get all the contacts.
SmsHttpConnection
  
Sends a request to the server to get any waiting deliveryreports for previously messages sent for the account that this session belongs to.
SmsHttpConnection
  
GetMsgCreditCost(Tel:String, Msg:String):void
Sends a request to the server to check price for a message for its destiation.
SmsHttpConnection
  
hasEventListener(type:String):Boolean
SmsHttpConnection
  
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
SmsHttpConnection
  
SendSms(Tel:String, Msg:String):void
Sends a request to the server to submit a message, the account that this session belongs will be adjusted for each message sent.
SmsHttpConnection
  
willTrigger(type:String):Boolean
SmsHttpConnection
Public Constants
 ConstantDefined by
  APPID : int = 0123456789
[static] Identifies this unique application, this should remain constant and not be changed.
SmsHttpConnection
Property detail
CurrentPasswordproperty
CurrentPassword:String  [read-only]

Global variable to access the credentials that is kept for the lifetime of the application.

Implementation
    public static function get CurrentPassword():String
CurrentUserTelproperty 
CurrentUserTel:String  [read-only]

Global variable to access the credentials that is kept for the lifetime of the application.

Implementation
    public static function get CurrentUserTel():String
GetInstanceproperty 
GetInstance:SmsHttpConnection  [read-only]

Gets the instance first created, as a singelton.

Implementation
    public static function get GetInstance():SmsHttpConnection
Constructor detail
SmsHttpConnection()constructor
public function SmsHttpConnection(UserTel:String = null, Password:String = null)

Session-state handler with methods for services and connectivity towards to the server. The username and password is static and kept for the lifetime of the application. When using the Flash IDE, create new instance with no arguments to reuse previous credentials when creating UI at different frames.

Parameters
UserTel:String (default = null) — Phonenumber used as identification for using the services.
 
Password:String (default = null) — The password corresponding to the account using for teh services.
Method detail
addEventListener()method
public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
 
priority:int (default = 0)
 
useWeakReference:Boolean (default = false)
CreateContact()method 
public function CreateContact(ContactTel:String, ContactName:String):void

Sends a request to the server for creating a new contact.

Parameters
ContactTel:String — Phonenumber of the new contact.
 
ContactName:String — Displayname of the corresponding number to the new contact.
DeleteContact()method 
public function DeleteContact(ContactTel:String):void

Sends a request to the server to delete a contact.

Parameters
ContactTel:String — Phonenumber for a contact.
DeleteSMS()method 
public function DeleteSMS(MsgID:int):void

Send a request to the server to delete an SMS.

Parameters
MsgID:int — Unique ID of an existing message.
dispatchEvent()method 
public function dispatchEvent(evt:Event):Boolean

Parameters
evt:Event

Returns
Boolean
GetBalance()method 
public function GetBalance():void

Sends a request to the server to get the current balance for account that this session belongs to. An event of type ONGETBALANCERESULT will be dispatched when the response is received.

GetContacts()method 
public function GetContacts():void

Sends a request to the server to get all the contacts.

GetDeliveries()method 
public function GetDeliveries():void

Sends a request to the server to get any waiting deliveryreports for previously messages sent for the account that this session belongs to. An event of type OnGetDeliveryResult will be dispatched when the response is received.

GetMsgCreditCost()method 
public function GetMsgCreditCost(Tel:String, Msg:String):void

Sends a request to the server to check price for a message for its destiation. An event of type OnGetBalanceResult will be dispatched when the response is received.

Parameters
Tel:String
 
Msg:String
hasEventListener()method 
public function hasEventListener(type:String):Boolean

Parameters
type:String

Returns
Boolean
removeEventListener()method 
public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void

Parameters
type:String
 
listener:Function
 
useCapture:Boolean (default = false)
SendSms()method 
public function SendSms(Tel:String, Msg:String):void

Sends a request to the server to submit a message, the account that this session belongs will be adjusted for each message sent. An event of type OnSendSmsResult will be dispatched when the response is received.

Parameters
Tel:String — Receipent of the message, in international format.
 
Msg:String — The message body to send.
willTrigger()method 
public function willTrigger(type:String):Boolean

Parameters
type:String

Returns
Boolean
Constant detail
APPIDconstant
public static const APPID:int = 0123456789

Identifies this unique application, this should remain constant and not be changed.