From Bright Pattern Documentation
No edit summary |
No edit summary |
||
| Line 4: | Line 4: | ||
* 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. | ||
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: | 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'': | 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'': | To end a conference, use the ''endConference'' method from ''Call'': | ||
public void endConference(); | |||
</translate> | </translate> | ||
Revision as of 01:31, 7 May 2019
<translate>= 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();
</translate>