mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
ResponseObject.cs updates: Added and tested SortParticipantListtByHandStatus method. Found an issue with HandStatus response, property names include ': ', updated JsonProperty definitions to account for issues with expected returns vs. actual returns.
This commit is contained in:
@@ -848,7 +848,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
|||||||
private bool _offHook;
|
private bool _offHook;
|
||||||
|
|
||||||
public string CallId { get; set; }
|
public string CallId { get; set; }
|
||||||
public bool IsIncomingCall {
|
public bool IsIncomingCall
|
||||||
|
{
|
||||||
get { return _isIncomingCall; }
|
get { return _isIncomingCall; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
@@ -856,7 +857,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
|||||||
|
|
||||||
_isIncomingCall = value;
|
_isIncomingCall = value;
|
||||||
NotifyPropertyChanged("IsIncomingCall");
|
NotifyPropertyChanged("IsIncomingCall");
|
||||||
} }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public string PeerDisplayName
|
public string PeerDisplayName
|
||||||
{
|
{
|
||||||
@@ -1180,7 +1182,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
|||||||
private string _selectedId;
|
private string _selectedId;
|
||||||
|
|
||||||
[JsonProperty("selectedId")]
|
[JsonProperty("selectedId")]
|
||||||
public string SelectedId {
|
public string SelectedId
|
||||||
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _selectedId;
|
return _selectedId;
|
||||||
@@ -1325,14 +1328,27 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
|||||||
|
|
||||||
public class HandStatus
|
public class HandStatus
|
||||||
{
|
{
|
||||||
[JsonProperty("is_raise_hand")]
|
// example return of the "hand_status" object
|
||||||
|
// !!!! Note the properties contain ': ' within the property name !!!
|
||||||
|
//"hand_status": {
|
||||||
|
// "is_raise_hand: ": false,
|
||||||
|
// "is_valid: ": "on",
|
||||||
|
// "time_stamp: ": "11825083"
|
||||||
|
//},
|
||||||
|
[JsonProperty("is_raise_hand: ")]
|
||||||
public bool IsRaiseHand { get; set; }
|
public bool IsRaiseHand { get; set; }
|
||||||
[JsonProperty("is_valid")]
|
[JsonProperty("is_valid: ")]
|
||||||
public bool IsValid { get; set; }
|
public string IsValid { get; set; }
|
||||||
[JsonProperty("time_stamp")]
|
[JsonProperty("time_stamp: ")]
|
||||||
public string TimeStamp { get; set; }
|
public string TimeStamp { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Retuns a boolean value if the participant hand state is raised and is valid (both need to be true)
|
||||||
|
/// </summary>
|
||||||
|
public bool HandIsRaisedAndValid
|
||||||
|
{
|
||||||
|
get { return IsValid != null && IsValid == "on" && IsRaiseHand; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ListParticipant
|
public class ListParticipant
|
||||||
{
|
{
|
||||||
[JsonProperty("audio_status state")]
|
[JsonProperty("audio_status state")]
|
||||||
@@ -1395,13 +1411,28 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
|||||||
HandStatus = new HandStatus();
|
HandStatus = new HandStatus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Converts ZoomRoom pariticpant list response to an Essentials participant list
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="participants"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static List<Participant> GetGenericParticipantListFromParticipantsResult(
|
public static List<Participant> GetGenericParticipantListFromParticipantsResult(
|
||||||
List<ListParticipant> participants)
|
List<ListParticipant> participants)
|
||||||
{
|
{
|
||||||
return
|
//return participants.Select(p => new Participant
|
||||||
participants.Select(
|
// {
|
||||||
p =>
|
// UserId = p.UserId,
|
||||||
new Participant
|
// Name = p.UserName,
|
||||||
|
// IsHost = p.IsHost,
|
||||||
|
// CanMuteVideo = p.IsVideoCanMuteByHost,
|
||||||
|
// CanUnmuteVideo = p.IsVideoCanUnmuteByHost,
|
||||||
|
// AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED",
|
||||||
|
// VideoMuteFb = p.VideoStatusIsSending,
|
||||||
|
// HandIsRaisedFb = p.HandStatus.HandIsRaisedAndValid,
|
||||||
|
// }).ToList();
|
||||||
|
|
||||||
|
var sortedParticipants = SortParticipantListByHandStatus(participants);
|
||||||
|
return sortedParticipants.Select(p => new Participant
|
||||||
{
|
{
|
||||||
UserId = p.UserId,
|
UserId = p.UserId,
|
||||||
Name = p.UserName,
|
Name = p.UserName,
|
||||||
@@ -1410,9 +1441,57 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
|||||||
CanUnmuteVideo = p.IsVideoCanUnmuteByHost,
|
CanUnmuteVideo = p.IsVideoCanUnmuteByHost,
|
||||||
AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED",
|
AudioMuteFb = p.AudioStatusState == "AUDIO_MUTED",
|
||||||
VideoMuteFb = p.VideoStatusIsSending,
|
VideoMuteFb = p.VideoStatusIsSending,
|
||||||
HandIsRaisedFb = p.HandStatus.IsValid && p.HandStatus.IsRaiseHand,
|
HandIsRaisedFb = p.HandStatus.HandIsRaisedAndValid,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Will sort by hand-raise status and then alphabetically
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="participants">Zoom Room response list of participants</param>
|
||||||
|
/// <returns>List</returns>
|
||||||
|
public static List<ListParticipant> SortParticipantListByHandStatus(List<ListParticipant> participants)
|
||||||
|
{
|
||||||
|
if (participants == null)
|
||||||
|
{
|
||||||
|
Debug.Console(1, "SortParticiapntListByHandStatu(participants == null)");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// debug testing
|
||||||
|
foreach (ListParticipant participant in participants)
|
||||||
|
{
|
||||||
|
Debug.Console(1, "{0} | IsValid: {1} | IsRaiseHand: {2} | HandIsRaisedAndValid: {3}",
|
||||||
|
participant.UserName, participant.HandStatus.IsValid, participant.HandStatus.IsRaiseHand.ToString(), participant.HandStatus.HandIsRaisedAndValid.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ListParticipant> handRaisedParticipantsList = participants.Where(p => p.HandStatus.HandIsRaisedAndValid).ToList();
|
||||||
|
|
||||||
|
if (handRaisedParticipantsList != null)
|
||||||
|
{
|
||||||
|
IOrderedEnumerable<ListParticipant> orderByDescending = handRaisedParticipantsList.OrderByDescending(p => p.HandStatus.TimeStamp);
|
||||||
|
|
||||||
|
foreach (var participant in handRaisedParticipantsList)
|
||||||
|
Debug.Console(1, "handRaisedParticipantList: {0} | {1}", participant.UserName, participant.UserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<ListParticipant> allOtherParticipantsList = participants.Where(p => !p.HandStatus.HandIsRaisedAndValid).ToList();
|
||||||
|
|
||||||
|
if (allOtherParticipantsList != null)
|
||||||
|
{
|
||||||
|
allOtherParticipantsList.OrderBy(p => p.UserName);
|
||||||
|
|
||||||
|
foreach (var participant in allOtherParticipantsList)
|
||||||
|
Debug.Console(1, "allOtherParticipantsList: {0} | {1}", participant.UserName, participant.UserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// merge the lists
|
||||||
|
List<ListParticipant> sortedList = handRaisedParticipantsList.Union(allOtherParticipantsList).ToList();
|
||||||
|
|
||||||
|
// return the sorted list
|
||||||
|
return sortedList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CallinCountryList
|
public class CallinCountryList
|
||||||
|
|||||||
Reference in New Issue
Block a user