From Bright Pattern Documentation
Jump to: navigation, search
Tracy (talk | contribs)
No edit summary
 
Updated via BpDeleteTranslateTags script
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
<translate>= Conference=
= Conference=


The following code snippet shows how to merge calls into a [[agent-guide/HowtoHostaConference|conference]].  
The following code snippet shows how to merge calls into a [[agent-guide/HowtoHostaConference|conference]].  


* For an conference via consultation, it assumes existence of a held primary call and an active consult call. Execution of the code snippet would be triggered by an explicit user action (e.g., pressing of a ''Merge'' button).
* For an conference via consultation, it assumes existence of a held primary call and an active consult call. Execution of the code snippet would be triggered by an explicit user action (e.g., pressing of a ''Merge'' button).
* For a single-step conference, it assumes existence of an active primary call and another call attempt initiated by the logged-in user. Execution of the code snippet would be triggered by connection of the second call.
* For a single-step conference, it assumes existence of an active primary call and another call attempt initiated by the logged-in user. Execution of the code snippet would be triggered by connection of the second call.




{|border="1" style="border-collapse:collapse" cellpadding="5"
public void MergeCalls(List&lt;Call&gt; calls) {
|
''public void MergeCalls(List&lt;Call&gt; calls) {''
Call conferencingCall = FindConferencingCall(calls, null);
 
:''Call conferencingCall = FindConferencingCall(calls, null);''
if (conferencingCall == null)
 
:''if (conferencingCall == null)''
return;
 
::''return;''
 
List&lt;Call&gt; callsToMerge = new List&lt;Call&gt;();
 
:''List&lt;Call&gt; callsToMerge = new List&lt;Call&gt;();''
foreach (Call call in calls) {
 
:''foreach (Call call in calls) {''
if (call.id != conferencingCall.id &amp;&amp; call.state != CallState.Disconnected) {
 
::''if (call.id != conferencingCall.id &amp;&amp; call.state != CallState.Disconnected) {''
callsToMerge.Add(call);
 
:::''callsToMerge.Add(call);''
}
 
::''}''
}
 
:''}''
conferencingCall.mergeConference(callsToMerge);
 
:''conferencingCall.mergeConference(callsToMerge);''
}
 
''}''
 
private Call FindConferencingCall(List&lt;Call&gt; calls) {
 
''private Call FindConferencingCall(List&lt;Call&gt; calls) {''
Call bestCall = null;
 
:''Call bestCall = null;''
DateTime bestTime = DateTime.Now;
 
:''DateTime bestTime = DateTime.Now;''
 
foreach (Call call in calls) {
 
:''foreach (Call call in calls) {''
if (call.state != CallState.Disconnected &amp;&amp; call.state != CallState.Unknown) {
 
::''if (call.state != CallState.Disconnected &amp;&amp; call.state != CallState.Unknown) {''
foreach (CallParty cp in call.parties.Values) {
 
:::''foreach (CallParty cp in call.parties.Values) {''
switch (cp.phoneType) {
 
::::''switch (cp.phoneType) {''
case PhoneType.Trunk:
 
:::::''case PhoneType.Trunk:''
return call;
 
::::::''return call;''
case PhoneType.DialOut:
 
:::::''case PhoneType.DialOut:''
return call;
 
::::::''return call;''
case PhoneType.AccessNumber:
 
:::::''case PhoneType.AccessNumber:''
return call;
 
::::::''return call;''
case PhoneType.Phone:
 
:::::''case PhoneType.Phone:''
case PhoneType.Softphone:
 
:::::''case PhoneType.Softphone:''
 
if (bestCall == null) {
 
::::::''if (bestCall == null) {''
  bestCall = call;
 
:::::::''bestCall = call;''
  bestTime = call.startTime;
 
:::::::''bestTime = call.startTime;''
}
 
::::::''}''
else if (call.startTime &lt; bestTime) {
 
::::::''else if (call.startTime &lt; bestTime) {''
bestCall = call;
 
:::::::''bestCall = call;''
bestTime = call.startTime;
 
:::::::''bestTime = call.startTime;''
}
 
::::::''}''
break;
 
::::::''break;''
}
 
::::''}''
}
 
:::''}''
}
}
return bestCall;
}


::''}''
:''}''
:''return bestCall;''
''}''
|}




To remove a participant from a conference, the ''removeParty'' method from Call should be used as follows:
To remove a participant from a conference, the ''removeParty'' method from Call should be used as follows:


{|border="1" style="border-collapse:collapse" cellpadding="5"
void RemoveFromConference(string callId, string partyId)''
|''void RemoveFromConference(string callId, string partyId)''
{   
Call call = AgentPlace.call(callId);
if (call != null)
{
CallParty party = call.parties[partyId];
if (party != null)
{
call.removeParty(party);
}
}
}


''{''         
:''Call call = AgentPlace.call(callId);''
::''if (call != null)''
::''{''
:::''CallParty party = call.parties[partyId];''
:::''if (party != null)''
:::''{''
::::''call.removeParty(party);''                 
:::''}''
::''}''           
''}''
|}




To leave a conference (remove oneself from a conference), use the ''drop'' method from ''Call'':  
To leave a conference (remove oneself from a conference), use the ''drop'' method from ''Call'':  
 
public void drop();
:public void drop();




To end a conference, use the ''endConference'' method from ''Call'':
To end a conference, use the ''endConference'' method from ''Call'':
 
public void endConference();
:public void endConference();
 
 
 
<center>[[desktop-integration-api-net-version-tutorial/Transfers|< Previous]]  |  [[desktop-integration-api-net-version-tutorial/Receivingacall|Next >]]</center>
</translate>

Latest revision as of 04:02, 29 May 2024

Conference

The following code snippet shows how to merge calls into a conference.

  • For an conference via consultation, it assumes existence of a held primary call and an active consult call. Execution of the code snippet would be triggered by an explicit user action (e.g., pressing of a Merge button).
  • For a single-step conference, it assumes existence of an active primary call and another call attempt initiated by the logged-in user. Execution of the code snippet would be triggered by connection of the second call.


public void MergeCalls(List<Call> calls) {

Call conferencingCall = FindConferencingCall(calls, null);

if (conferencingCall == null)

return;


List<Call> callsToMerge = new List<Call>();

foreach (Call call in calls) {

if (call.id != conferencingCall.id && call.state != CallState.Disconnected) {

callsToMerge.Add(call);

}

}

conferencingCall.mergeConference(callsToMerge);

}


private Call FindConferencingCall(List<Call> calls) {

Call bestCall = null;

DateTime bestTime = DateTime.Now;


foreach (Call call in calls) {

if (call.state != CallState.Disconnected && call.state != CallState.Unknown) {

foreach (CallParty cp in call.parties.Values) {

switch (cp.phoneType) {

case PhoneType.Trunk:

return call;

case PhoneType.DialOut:

return call;

case PhoneType.AccessNumber:

return call;

case PhoneType.Phone:

case PhoneType.Softphone:


if (bestCall == null) {

 bestCall = call;

 bestTime = call.startTime;

}

else if (call.startTime < bestTime) {

bestCall = call;

bestTime = call.startTime;

}

break;

}

}

}

}

return bestCall;

}


To remove a participant from a conference, the removeParty method from Call should be used as follows:

void RemoveFromConference(string callId, string partyId)

{     
Call call = AgentPlace.call(callId);
if (call != null)
{
CallParty party = call.parties[partyId];
if (party != null)
{
call.removeParty(party);
}
}

}


To leave a conference (remove oneself from a conference), use the drop method from Call:

public void drop();


To end a conference, use the endConference method from Call:

public void endConference();

< Previous | Next >