C# Class SIPSorcery.AppServer.DialPlan.DialPlanScriptFacade

Helper functions for use in dial plan scripts.
Mostra file Open project: sipsorcery/sipsorcery Class Usage Examples

Public Properties

Property Type Description
LastDialled List
PublicIPAddress IPAddress

Public Methods

Method Description
Callback ( string dest1, string dest2 ) : void

See Callback method below.

Callback ( string dest1, string dest2, int delaySeconds ) : void
Callback ( string dest1, string dest2, int delaySeconds, int ringTimeoutLeg1, int ringTimeoutLeg2 ) : void
Callback ( string dest1, string dest2, int delaySeconds, int ringTimeoutLeg1, int ringTimeoutLeg2, string customHeadersCallLeg1, string customHeadersCallLeg2 ) : void
Cleanup ( ) : void
ClearCustomBody ( ) : void

Clears the custom body so that the incoming request body will again be used on forwarded requests.

ClearCustomSIPHeaders ( ) : void

Clears all the custom SIP header values from the list.

ClearFromHeader ( ) : void

Reset the custom From header values so that the corresponding values from the originating request will be used.

CommitTransaction ( ) : void
DBDelete ( string key ) : void
DBDelete ( string dbType, string dbConnStr, string key ) : void
DBExecuteNonQuery ( string dbType, string dbConnStr, string query ) : void
DBExecuteScalar ( string dbType, string dbConnStr, string query ) : string
DBGetKeys ( ) : List
DBRead ( string key ) : string
DBRead ( string dbType, string dbConnStr, string key ) : string
DBReadForUpdate ( string key ) : string
DBWrite ( string key, string value ) : void
DBWrite ( string dbType, string dbConnStr, string key, string value ) : void
Dial ( string data ) : DialPlanAppResult

Attempts to dial a series of forwards and bridges the first one that connects with the client call.

Dial ( string data, int ringTimeout ) : DialPlanAppResult

Attempts to dial a series of forwards and bridges the first one that connects with the client call.

Dial ( string data, int ringTimeout, int answeredCallLimit ) : DialPlanAppResult

Attempts to dial a series of forwards and bridges the first one that connects with the client call.

Dial ( string data, int ringTimeout, int answeredCallLimit, CRMHeaders contact ) : DialPlanAppResult
DialPlanScriptFacade ( SIPTransport sipTransport, DialPlanExecutingScript executingScript, SIPMonitorLogDelegate logDelegate, DialogueBridgeCreatedDelegate createBridge, SIPRequest sipRequest, SIPCallDirection callDirection, DialPlanContext dialPlanContext, GetCanonicalDomainDelegate getCanonicalDomain, ISIPCallManager callManager, SIPSorceryPersistor sipSorceryPersistor, SIPEndPoint outboundProxySocket, DialPlanEngine dialPlanEngine ) : System
DoesSIPAccountExist ( string username ) : bool

Used to check for the existence of a SIP account in the default domain.

DoesSIPAccountExist ( string username, string domain ) : bool

Used to check for the existence of a SIP account in the specified domain.

ENUMLookup ( string number ) : string

Trys an ENUM lookup on the specified number.

Email ( string to, string subject, string body ) : void

Sends an email from the dialplan. There are a number of restrictions put in place and this is a privileged application that users must be manually authorised for.

ExtendScriptTimeout ( int seconds ) : void
GTalk ( string username, string password, string sendToUser, string message ) : void
GTalk ( string username, string password, string sendToUser, string message, int connectionTimeout ) : void

Attempts to send a gTalk IM to the specified account.

GetBalance ( string accountCode ) : decimal

Gets the balance for a customer account record.

GetBindings ( ) : SIPRegistrarBinding[]

Gets an array of the registered contacts for the dialplan owner's SIP account.

GetBindings ( string username, string domain ) : SIPRegistrarBinding[]

Gets an array of the registered contacts for the specified SIP account. Only the owner of the SIP account will be allowed to retrieve a list of bindings for it.

GetCanonicalDomain ( string host ) : string

Allows a hostname to be tested to determine if it is a sipsorcery serviced domain and if it is the canonical domain will be returned.

GetCurrentCallCount ( ) : int

Gets the number of currently active calls for the dial plan owner.

GetCurrentCalls ( ) : List

Gets a list of currently active calls for the dial plan owner.

GetRate ( string rateCode, string destination ) : SIPSorcery.Entities.Rate
GetRate ( string rateCode, string destination, int ratePlan ) : SIPSorcery.Entities.Rate
GetSIPAccounts ( ) : List

Allows a list of all the dialplan owner's SIP accounts to be retrieved.

GetTimezone ( ) : string

Retrieves the timezone setting for the owner of the executing dialplan.

GetTimezoneOffsetMinutes ( ) : int

Retrieves the timezone offset minutes from UTC for the owner of the executing dialplan.

GoogleContactLookup ( string oAuthToken, string lookup ) : string
GoogleContactLookup ( string username, string password, string lookup ) : string
GoogleVoiceCall ( string emailAddress, string password, string forwardingNumber, string destinationNumber ) : void
GoogleVoiceCall ( string emailAddress, string password, string forwardingNumber, string destinationNumber, string fromURIUserToMatch ) : void
GoogleVoiceCall ( string emailAddress, string password, string forwardingNumber, string destinationNumber, string fromURIUserToMatch, int phoneType ) : void
GoogleVoiceCall ( string emailAddress, string password, string forwardingNumber, string destinationNumber, string fromURIUserToMatch, int phoneType, int waitForCallbackTimeout ) : void
GoogleVoiceSMS ( string emailAddress, string password, string destinationNumber, string message ) : void
IsAvailable ( ) : bool

Checks whether the dialplan owner's default SIP account is online (has any current bindings).

IsAvailable ( string username ) : bool

Checks whether SIP account belonging to the default server domain is online (has any current bindings).

IsAvailable ( string username, string domain ) : bool

Checks whether the specified SIP account is online (has any current bindings).

IsMine ( string username ) : bool

Checks whether the specified SIP account and default domain belongs to the dialplan owner.

IsMine ( string username, string domain ) : bool

Checks whether the specified SIP account belongs to the dialplan owner.

Log ( string message ) : void

Logs a message with the proxy. Typically this records the message in the database and also prints it out on the proxy monitor telnet console.

PrintCustomSIPHeaders ( ) : void

Dumps the currently stored custom SIP headers to the console or monitoring screen to allow users to troubleshoot.

RemoveCustomSIPHeader ( string headerName ) : void

If present removes a SIP header from the list of custom headers.

Respond ( int statusCode, string reason ) : void
Respond ( int statusCode, string reason, string customHeaders ) : void

Sends a SIP response to the client call. If a final response is sent then the client call will hang up.

RollbackTransaction ( ) : void
SendRequest ( string methodStr, string destination, string contentType, string body, int responseTimeoutSeconds ) : void
SendRequest ( string methodStr, string destination, string contentType, string body, int responseTimeoutSeconds, string username, string password ) : void
SetCallerCRMDetails ( CRMHeaders crmHeader ) : void

Sets CRM headers for the dialplan context. Typically the CRM headers will contain extra information about the caller that has been obtained from an external CRM system.

SetCustomContent ( string content ) : void

Sets the custom body that will override the incoming request body for forwarded INVITE requests.

SetCustomContent ( string contentType, string content ) : void

Sets the custom body that will override the incoming request body for forwarded INVITE requests.

SetCustomSIPHeader ( string headerName, string headerValue ) : void

Adds a name value pair to the custom SIP headers list. The custom headers will be added to any forwarded call requests.

SetFromHeader ( string fromName, string fromUser, string fromHost ) : void

Sets the value of part or all of the From header that will be set on forwarded calls. Leaving a part of the header as null will result in the corresponding value from the originating request being used.

StartTransaction ( ) : void
TurnOffAutoCleanup ( ) : void
WebGet ( string url ) : string
WebGet ( string url, int timeout ) : string

Executes a HTTP GET request and if succesful returns up to the first 1024 bytes read from the response to the caller.

WhoAmI ( ) : string

Private Methods

Method Description
ApplyENUMRules ( string number, RecordNAPTR naptrRecords ) : string

Applies a set of NAPTR rules obtained from an ENUM lookup to attempt to get a SIP URI. This functionality should be moved closer to the DNS classes once it becomes more mature and universal. See RFC 2915.

CleanupDialPlanScript ( ) : void

A function that gets attached to the executing thread object and that will be called when the dialplan script is complete and immediately prior to a possible thread abortion.

ClientCallTerminated ( CallCancelCause cancelCause ) : void This method will be called on the thread that owns the dialplan context object so it's critical that Thread abort is not called in it or from it.
DBDelete ( StorageTypes storageType, string dbConnStr, string key ) : void
DBRead ( StorageTypes storageType, string dbConnStr, string key, bool forUpdate ) : string
DBWrite ( StorageTypes storageType, string dbConnStr, string key, string value ) : void
Dial ( string data, int ringTimeout, int answeredCallLimit, SIPRequest clientRequest, CRMHeaders contact ) : DialPlanAppResult

DialPlanScriptFacade ( ) : System
FireProxyLogEvent ( SIPMonitorEvent monitorEvent ) : void
FormatForENUMLookup ( string number ) : string

Attempts to put a number into e164 format for an ENUM lookup.

GetDatabaseConnection ( StorageTypes storageType, string dbConnStr ) : IDbConnection
GetStorageType ( string dbType ) : StorageTypes
IsAppAuthorised ( string authorisedApps, string applicationName ) : bool

Used to authorise calls to privileged dialplan applications. For example sending an email requires that the dialplan has the "email" in its list of authorised apps.

SendGoogleAnalyticsEvent ( string category, string action, string label, int value ) : void

Method Details

Callback() public method

See Callback method below.
public Callback ( string dest1, string dest2 ) : void
dest1 string
dest2 string
return void

Callback() public method

public Callback ( string dest1, string dest2, int delaySeconds ) : void
dest1 string
dest2 string
delaySeconds int
return void

Callback() public method

public Callback ( string dest1, string dest2, int delaySeconds, int ringTimeoutLeg1, int ringTimeoutLeg2 ) : void
dest1 string
dest2 string
delaySeconds int
ringTimeoutLeg1 int
ringTimeoutLeg2 int
return void

Callback() public method

public Callback ( string dest1, string dest2, int delaySeconds, int ringTimeoutLeg1, int ringTimeoutLeg2, string customHeadersCallLeg1, string customHeadersCallLeg2 ) : void
dest1 string
dest2 string
delaySeconds int
ringTimeoutLeg1 int
ringTimeoutLeg2 int
customHeadersCallLeg1 string
customHeadersCallLeg2 string
return void

Cleanup() public method

public Cleanup ( ) : void
return void

ClearCustomBody() public method

Clears the custom body so that the incoming request body will again be used on forwarded requests.
public ClearCustomBody ( ) : void
return void

ClearCustomSIPHeaders() public method

Clears all the custom SIP header values from the list.
public ClearCustomSIPHeaders ( ) : void
return void

ClearFromHeader() public method

Reset the custom From header values so that the corresponding values from the originating request will be used.
public ClearFromHeader ( ) : void
return void

CommitTransaction() public method

public CommitTransaction ( ) : void
return void

DBDelete() public method

public DBDelete ( string key ) : void
key string
return void

DBDelete() public method

public DBDelete ( string dbType, string dbConnStr, string key ) : void
dbType string
dbConnStr string
key string
return void

DBExecuteNonQuery() public method

public DBExecuteNonQuery ( string dbType, string dbConnStr, string query ) : void
dbType string
dbConnStr string
query string
return void

DBExecuteScalar() public method

public DBExecuteScalar ( string dbType, string dbConnStr, string query ) : string
dbType string
dbConnStr string
query string
return string

DBGetKeys() public method

public DBGetKeys ( ) : List
return List

DBRead() public method

public DBRead ( string key ) : string
key string
return string

DBRead() public method

public DBRead ( string dbType, string dbConnStr, string key ) : string
dbType string
dbConnStr string
key string
return string

DBReadForUpdate() public method

public DBReadForUpdate ( string key ) : string
key string
return string

DBWrite() public method

public DBWrite ( string key, string value ) : void
key string
value string
return void

DBWrite() public method

public DBWrite ( string dbType, string dbConnStr, string key, string value ) : void
dbType string
dbConnStr string
key string
value string
return void

Dial() public method

Attempts to dial a series of forwards and bridges the first one that connects with the client call.
public Dial ( string data ) : DialPlanAppResult
data string The dial string containing the list of call legs to attempt to forward the call to.
return DialPlanAppResult

Dial() public method

Attempts to dial a series of forwards and bridges the first one that connects with the client call.
public Dial ( string data, int ringTimeout ) : DialPlanAppResult
data string The dial string containing the list of call legs to attempt to forward the call to.
ringTimeout int The period in seconds to perservere with the dial command attempt without a final response before giving up.
return DialPlanAppResult

Dial() public method

Attempts to dial a series of forwards and bridges the first one that connects with the client call.
public Dial ( string data, int ringTimeout, int answeredCallLimit ) : DialPlanAppResult
data string The dial string containing the list of call legs to attempt to forward the call to.
ringTimeout int The period in seconds to perservere with the dial command attempt without a final response before giving up.
answeredCallLimit int If greater than 0 this specifies the period in seconds an answered call will be hungup after.
return DialPlanAppResult

Dial() public method

public Dial ( string data, int ringTimeout, int answeredCallLimit, CRMHeaders contact ) : DialPlanAppResult
data string
ringTimeout int
answeredCallLimit int
contact CRMHeaders
return DialPlanAppResult

DialPlanScriptFacade() public method

public DialPlanScriptFacade ( SIPTransport sipTransport, DialPlanExecutingScript executingScript, SIPMonitorLogDelegate logDelegate, DialogueBridgeCreatedDelegate createBridge, SIPRequest sipRequest, SIPCallDirection callDirection, DialPlanContext dialPlanContext, GetCanonicalDomainDelegate getCanonicalDomain, ISIPCallManager callManager, SIPSorceryPersistor sipSorceryPersistor, SIPEndPoint outboundProxySocket, DialPlanEngine dialPlanEngine ) : System
sipTransport SIPTransport
executingScript DialPlanExecutingScript
logDelegate SIPMonitorLogDelegate
createBridge DialogueBridgeCreatedDelegate
sipRequest SIPRequest
callDirection SIPCallDirection
dialPlanContext DialPlanContext
getCanonicalDomain GetCanonicalDomainDelegate
callManager ISIPCallManager
sipSorceryPersistor SIPSorceryPersistor
outboundProxySocket SIPEndPoint
dialPlanEngine DialPlanEngine
return System

DoesSIPAccountExist() public method

Used to check for the existence of a SIP account in the default domain.
public DoesSIPAccountExist ( string username ) : bool
username string The SIP account username to check for.
return bool

DoesSIPAccountExist() public method

Used to check for the existence of a SIP account in the specified domain.
public DoesSIPAccountExist ( string username, string domain ) : bool
username string The SIP account username to check for.
domain string The SIP domain to check for the account in.
return bool

ENUMLookup() public method

Trys an ENUM lookup on the specified number.
public ENUMLookup ( string number ) : string
number string
return string

Email() public method

Sends an email from the dialplan. There are a number of restrictions put in place and this is a privileged application that users must be manually authorised for.
public Email ( string to, string subject, string body ) : void
to string The list of addressees to send the email to. Limited to a maximum of ALLOWED_ADDRESSES_PER_EMAIL.
subject string The email subject. Limited to a maximum length of MAX_EMAIL_SUBJECT_LENGTH.
body string The email body. Limited to a maximum length of MAX_EMAIL_BODY_LENGTH.
return void

ExtendScriptTimeout() public method

public ExtendScriptTimeout ( int seconds ) : void
seconds int
return void

GTalk() public method

public GTalk ( string username, string password, string sendToUser, string message ) : void
username string
password string
sendToUser string
message string
return void

GTalk() public method

Attempts to send a gTalk IM to the specified account.
public GTalk ( string username, string password, string sendToUser, string message, int connectionTimeout ) : void
username string
password string
sendToUser string
message string
connectionTimeout int
return void

GetBalance() public method

Gets the balance for a customer account record.
public GetBalance ( string accountCode ) : decimal
accountCode string The account code to get the record for.
return decimal

GetBindings() public method

Gets an array of the registered contacts for the dialplan owner's SIP account.
public GetBindings ( ) : SIPRegistrarBinding[]
return SIPRegistrarBinding[]

GetBindings() public method

Gets an array of the registered contacts for the specified SIP account. Only the owner of the SIP account will be allowed to retrieve a list of bindings for it.
public GetBindings ( string username, string domain ) : SIPRegistrarBinding[]
username string
domain string
return SIPRegistrarBinding[]

GetCanonicalDomain() public method

Allows a hostname to be tested to determine if it is a sipsorcery serviced domain and if it is the canonical domain will be returned.
public GetCanonicalDomain ( string host ) : string
host string The hostname to attempt to retrieve the canonical domain for.
return string

GetCurrentCallCount() public method

Gets the number of currently active calls for the dial plan owner.
public GetCurrentCallCount ( ) : int
return int

GetCurrentCalls() public method

Gets a list of currently active calls for the dial plan owner.
public GetCurrentCalls ( ) : List
return List

GetRate() public method

public GetRate ( string rateCode, string destination ) : SIPSorcery.Entities.Rate
rateCode string
destination string
return SIPSorcery.Entities.Rate

GetRate() public method

public GetRate ( string rateCode, string destination, int ratePlan ) : SIPSorcery.Entities.Rate
rateCode string
destination string
ratePlan int
return SIPSorcery.Entities.Rate

GetSIPAccounts() public method

Allows a list of all the dialplan owner's SIP accounts to be retrieved.
public GetSIPAccounts ( ) : List
return List

GetTimezone() public method

Retrieves the timezone setting for the owner of the executing dialplan.
public GetTimezone ( ) : string
return string

GetTimezoneOffsetMinutes() public method

Retrieves the timezone offset minutes from UTC for the owner of the executing dialplan.
public GetTimezoneOffsetMinutes ( ) : int
return int

GoogleContactLookup() public method

public GoogleContactLookup ( string oAuthToken, string lookup ) : string
oAuthToken string
lookup string
return string

GoogleContactLookup() public method

public GoogleContactLookup ( string username, string password, string lookup ) : string
username string
password string
lookup string
return string

GoogleVoiceCall() public method

public GoogleVoiceCall ( string emailAddress, string password, string forwardingNumber, string destinationNumber ) : void
emailAddress string
password string
forwardingNumber string
destinationNumber string
return void

GoogleVoiceCall() public method

public GoogleVoiceCall ( string emailAddress, string password, string forwardingNumber, string destinationNumber, string fromURIUserToMatch ) : void
emailAddress string
password string
forwardingNumber string
destinationNumber string
fromURIUserToMatch string
return void

GoogleVoiceCall() public method

public GoogleVoiceCall ( string emailAddress, string password, string forwardingNumber, string destinationNumber, string fromURIUserToMatch, int phoneType ) : void
emailAddress string
password string
forwardingNumber string
destinationNumber string
fromURIUserToMatch string
phoneType int
return void

GoogleVoiceCall() public method

public GoogleVoiceCall ( string emailAddress, string password, string forwardingNumber, string destinationNumber, string fromURIUserToMatch, int phoneType, int waitForCallbackTimeout ) : void
emailAddress string
password string
forwardingNumber string
destinationNumber string
fromURIUserToMatch string
phoneType int
waitForCallbackTimeout int
return void

GoogleVoiceSMS() public method

public GoogleVoiceSMS ( string emailAddress, string password, string destinationNumber, string message ) : void
emailAddress string
password string
destinationNumber string
message string
return void

IsAvailable() public method

Checks whether the dialplan owner's default SIP account is online (has any current bindings).
public IsAvailable ( ) : bool
return bool

IsAvailable() public method

Checks whether SIP account belonging to the default server domain is online (has any current bindings).
public IsAvailable ( string username ) : bool
username string
return bool

IsAvailable() public method

Checks whether the specified SIP account is online (has any current bindings).
public IsAvailable ( string username, string domain ) : bool
username string
domain string
return bool

IsMine() public method

Checks whether the specified SIP account and default domain belongs to the dialplan owner.
public IsMine ( string username ) : bool
username string
return bool

IsMine() public method

Checks whether the specified SIP account belongs to the dialplan owner.
public IsMine ( string username, string domain ) : bool
username string
domain string
return bool

Log() public method

Logs a message with the proxy. Typically this records the message in the database and also prints it out on the proxy monitor telnet console.
public Log ( string message ) : void
message string
return void

PrintCustomSIPHeaders() public method

Dumps the currently stored custom SIP headers to the console or monitoring screen to allow users to troubleshoot.
public PrintCustomSIPHeaders ( ) : void
return void

RemoveCustomSIPHeader() public method

If present removes a SIP header from the list of custom headers.
public RemoveCustomSIPHeader ( string headerName ) : void
headerName string The name of the SIP header to remove.
return void

Respond() public method

public Respond ( int statusCode, string reason ) : void
statusCode int
reason string
return void

Respond() public method

Sends a SIP response to the client call. If a final response is sent then the client call will hang up.
public Respond ( int statusCode, string reason, string customHeaders ) : void
statusCode int
reason string
customHeaders string
return void

RollbackTransaction() public method

public RollbackTransaction ( ) : void
return void

SendRequest() public method

public SendRequest ( string methodStr, string destination, string contentType, string body, int responseTimeoutSeconds ) : void
methodStr string
destination string
contentType string
body string
responseTimeoutSeconds int
return void

SendRequest() public method

public SendRequest ( string methodStr, string destination, string contentType, string body, int responseTimeoutSeconds, string username, string password ) : void
methodStr string
destination string
contentType string
body string
responseTimeoutSeconds int
username string
password string
return void

SetCallerCRMDetails() public method

Sets CRM headers for the dialplan context. Typically the CRM headers will contain extra information about the caller that has been obtained from an external CRM system.
public SetCallerCRMDetails ( CRMHeaders crmHeader ) : void
crmHeader CRMHeaders
return void

SetCustomContent() public method

Sets the custom body that will override the incoming request body for forwarded INVITE requests.
public SetCustomContent ( string content ) : void
content string
return void

SetCustomContent() public method

Sets the custom body that will override the incoming request body for forwarded INVITE requests.
public SetCustomContent ( string contentType, string content ) : void
contentType string
content string
return void

SetCustomSIPHeader() public method

Adds a name value pair to the custom SIP headers list. The custom headers will be added to any forwarded call requests.
public SetCustomSIPHeader ( string headerName, string headerValue ) : void
headerName string The name of the SIP header to add.
headerValue string The value of the SIP header to add.
return void

SetFromHeader() public method

Sets the value of part or all of the From header that will be set on forwarded calls. Leaving a part of the header as null will result in the corresponding value from the originating request being used.
public SetFromHeader ( string fromName, string fromUser, string fromHost ) : void
fromName string The custom From header display name to set.
fromUser string The custom From header URI user value to set.
fromHost string The custom From header URI host value to set.
return void

StartTransaction() public method

public StartTransaction ( ) : void
return void

TurnOffAutoCleanup() public method

public TurnOffAutoCleanup ( ) : void
return void

WebGet() public method

public WebGet ( string url ) : string
url string
return string

WebGet() public method

Executes a HTTP GET request and if succesful returns up to the first 1024 bytes read from the response to the caller.
public WebGet ( string url, int timeout ) : string
url string The URL of the server to call.
timeout int
return string

WhoAmI() public method

public WhoAmI ( ) : string
return string

Property Details

LastDialled public_oe property

public List LastDialled
return List

PublicIPAddress public_oe static_oe property

public static IPAddress PublicIPAddress
return IPAddress