Session

From FreeSWITCH Wiki
Jump to: navigation, search
Warning

See the Mod_lua page for the full list of session methods. This page currently lists only the subset of methods available to the Javascript module.

 


The session object provides methods that allow you to interact with the channel. The different parts of the session object are listed below in alphabetical order.

Note for applications written in Javascript: While the JavaScript application will continue to execute after a hangup is detected the session object will be gone and any attempt to access it will cause the JavaScript to terminate. Save off any variables you might need for post hangup processing and use your local variables instead.

Constructor

You can create a new session with the following:

s = new Session();

Creates an empty session object that provides methods that allow you to interact with the channel.

s = new Session(uuid);

Creates a session object from an existing uuid. This allows you to interact with an existing channel.

To create a new session and automatically dial out, proceeding only once the call has been answered (ignoring early media information), try this code (Javascript):

s = new Session("{ignore_early_media=true}sofia/default/foo@bar.com");
while (s.ready()) {
 // The call has been answered
}

Other options, as found in Mod_commands#originate, may be used:

s = new Session("{ignore_early_media=true,origination_caller_id_name=Jack}sofia/default/foo@bar.com");
while (s.ready()) {
 // The call has been answered
}

You do not need to create a default session. 'session' is created automatically for the current session.

Methods

Properties