<html>
<head>
    <base href="https://wiki.asterisk.org/wiki">
            <link rel="stylesheet" href="/wiki/s/en/2172/18/9/_/styles/combined.css?spaceKey=TOP&amp;forWysiwyg=true" type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://wiki.asterisk.org/wiki/display/TOP/The+SessionController">The SessionController</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://wiki.asterisk.org/wiki/display/~beagles">Brent Eagles</a>
    </h4>
        <br/>
                         <h4>Changes (3)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h1. The Interfaces <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">The {{AsteriskSCF::SessionCommunications::V1::Session}} interface has two methods for managing its association of an external {{SessionController}}.  <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{info} <br>The Slice for the SessionController interface can be found in [AsteriskSCF/SessionCommunications/SessionCommunicationsIf.ice|http://git.asterisk.org/gitweb/?p=asterisk-scf/release/slice.git;a=blob;f=slice/AsteriskSCF/SessionCommunications/SessionCommunicationsIf.ice;h=fac949fb897ea5456ce5a36243e78cbe2a42f118;hb=HEAD] <br>{info} <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The {{AsteriskSCF::SessionCommunications::V1::Session}} interface has two methods for managing its association of an external {{SessionController}}.  <br></td></tr>
            <tr><td class="diff-unchanged" >{{AsteriskSCF::SessionCommunications::V1::Session::setAndGetSessionController()}} overrides the session&#39;s internal implementation of the {{SessionController}} interface. This method may only be used to replace the internal {{SessionController}}. To change the controller from one external instance to another {{AsteriskSCF::SessionCommunications::V1::Session::removeSessionController()}} must be called before calling {{setAndGetSessionController()}} to set the new controller object. If {{removeSessionController()}} is not called first, the {{AsteriskSCF::SessionCommunications::V1::ControllerAlreadySet}} exception will be thrown. <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="TheSessionController-Overview"></a>Overview</h1>

<p>Instances of <tt>AsteriskSCF::SessionCommunications::V1::Session</tt> may have media objects and other elements closely associated with them. It is often necessary to modify these objects but querying the <tt>Session</tt> instance to obtain proxies to modify the objects directly requires multiple procedure calls which is both "expensive" and can lead to consistency errors and race conditions. It also does not take into account requirements of the <tt>Session</tt> implementation or allow for extension of the overall behavior. The <tt>AsteriskSCF::SessionCommunications::V1::SessionController</tt> interface defines a higher level contract for modifying the state of a <tt>Session</tt> object's constituents while it is "running". The interface defines key methods for updating telephony oriented details as well as updating the state of media streams associated with a "live" <tt>Session</tt> object. Each <tt>Session</tt> object typically has a single active <tt>SessionController</tt> instance which may be replaced to extend and modify the default behavior. Overriding the <tt>SessionController</tt> is a standard part of <em>bridging</em>. The bridge object interposes its own <tt>SessionController</tt> implementation to receive directives and updates for the <tt>Session</tt> object and notifies or modifies other <tt>Session</tt> objects that have been added to it. External or internal, the <tt>SessionController</tt> is used for all operations, essentially allowing an external object to <em>interpose</em> itself into the <tt>Session</tt> object's internal operations.</p>

<h1><a name="TheSessionController-TheInterfaces"></a>The Interfaces</h1>

<div class='panelMacro'><table class='infoMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>The Slice for the SessionController interface can be found in <a href="http://git.asterisk.org/gitweb/?p=asterisk-scf/release/slice.git;a=blob;f=slice/AsteriskSCF/SessionCommunications/SessionCommunicationsIf.ice;h=fac949fb897ea5456ce5a36243e78cbe2a42f118;hb=HEAD" class="external-link" rel="nofollow">AsteriskSCF/SessionCommunications/SessionCommunicationsIf.ice</a></td></tr></table></div>

<p>The <tt>AsteriskSCF::SessionCommunications::V1::Session</tt> interface has two methods for managing its association of an external <tt>SessionController</tt>. <br/>
<tt>AsteriskSCF::SessionCommunications::V1::Session::setAndGetSessionController()</tt> overrides the session's internal implementation of the <tt>SessionController</tt> interface. This method may only be used to replace the internal <tt>SessionController</tt>. To change the controller from one external instance to another <tt>AsteriskSCF::SessionCommunications::V1::Session::removeSessionController()</tt> must be called before calling <tt>setAndGetSessionController()</tt> to set the new controller object. If <tt>removeSessionController()</tt> is not called first, the <tt>AsteriskSCF::SessionCommunications::V1::ControllerAlreadySet</tt> exception will be thrown.</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">idempotent SessionController *setAndGetSessionController(
    AsteriskSCF::System::V1::OperationContext operationContext,
            SessionController* controller) throws
              ControllerAlreadySet;
   
idempotent void removeSessionController(
    AsteriskSCF::System::V1::OperationContext operationContext,
            SessionController* controller);</pre>
</div></div>

<p>The <tt>AsteriskSCF::SessionCommunications::V1::SessionController</tt> interface defines the following methods: </p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="theme: Confluence; brush: java; gutter: false">idempotent void changeStreamStates(
            AsteriskSCF::System::V1::OperationContext operationContext,
            AsteriskSCF::Media::V1::StreamStateDict streams);

idempotent AsteriskSCF::Media::V1::StreamInformationDict addStreams(
           AsteriskSCF::System::V1::OperationContext operationContext,
           AsteriskSCF::Media::V1::StreamInformationDict streams);

idempotent void removeStreams(
           AsteriskSCF::System::V1::OperationContext operationContext,
           AsteriskSCF::Media::V1::StreamInformationDict streams);

idempotent void updateConnectedLine(
           AsteriskSCF::System::V1::OperationContext operationContext,
           AsteriskSCF::SessionCommunications::PartyIdentification::V1::ConnectedLine connectedLine);

idempotent void updateCallerID(
           AsteriskSCF::System::V1::OperationContext operationContext,
           AsteriskSCF::SessionCommunications::PartyIdentification::V1::Caller callerID);

idempotent void updateRedirections(
           AsteriskSCF::System::V1::OperationContext operationContext,
           AsteriskSCF::SessionCommunications::PartyIdentification::V1::Redirections redirections);</pre>
</div></div>


<h1><a name="TheSessionController-UseCases"></a>Use Cases</h1>

<p>How the <tt>SessionController</tt> can be leveraged is best illustrated by examining some of the cases where it is used. Each of the following events occur <em>within</em> a <tt>Session</tt> implementation.</p>

<div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Event </th>
<th class='confluenceTh'> Result </th>
</tr>
<tr>
<td class='confluenceTd'> Reinvite resulted in change to current media streams </td>
<td class='confluenceTd'> Possible removeStreams(), changeStreamStates() or addStreams() calls </td>
</tr>
<tr>
<td class='confluenceTd'> Target session is established </td>
<td class='confluenceTd'> updatedConnectedLine() is called </td>
</tr>
<tr>
<td class='confluenceTd'> Call to a target session has been redirected </td>
<td class='confluenceTd'> updateRedirections() is called </td>
</tr>
<tr>
<td class='confluenceTd'> Connected session changes identifying information </td>
<td class='confluenceTd'> updateCallerID() is called on connected sessions </td>
</tr>
</tbody></table>
</div>


<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td valign='top'><img src="/wiki/images/icons/emoticons/warning.gif" width="16" height="16" align="absmiddle" alt="" border="0"></td><td>Some of the controller calls are (e.g. updateRedirections) not fully implemented.</td></tr></table></div>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;" class="grey">
                        <a href="https://wiki.asterisk.org/wiki/users/removespacenotification.action?spaceKey=TOP">Stop watching space</a>
            <span style="padding: 0px 5px;">|</span>
                <a href="https://wiki.asterisk.org/wiki/users/editmyemailsettings.action">Change email notification preferences</a>
</div>
        <a href="https://wiki.asterisk.org/wiki/display/TOP/The+SessionController">View Online</a>
        |
        <a href="https://wiki.asterisk.org/wiki/pages/diffpagesbyversion.action?pageId=19726374&revisedVersion=3&originalVersion=2">View Changes</a>
                |
        <a href="https://wiki.asterisk.org/wiki/display/TOP/The+SessionController?showComments=true&amp;showCommentArea=true#addcomment">Add Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>