Moved some enums into separate files; modifying simulation methods on MockVC; Added Connecting state to eCodecStatus; ...

This commit is contained in:
Heath Volmer
2017-09-20 09:51:48 -06:00
parent f13978368f
commit 82465e8789
10 changed files with 238 additions and 50 deletions

View File

@@ -13,6 +13,7 @@ using Cisco_SX80_Corporate_Phone_Book;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Routing;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
@@ -28,6 +29,12 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public BoolFeedback StandbyIsOnFeedback { get; private set; }
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
public BoolFeedback PeopleCountFeedback { get; private set; }
public BoolFeedback SpeakerTrackIsOnFeedback { get; private set; }
private CiscoOneButtonToPush CodecObtp;
private Corporate_Phone_Book PhoneBook;
@@ -36,7 +43,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
private CiscoCodecStatus.RootObject CodecStatus;
<<<<<<< HEAD
private CiscoCodecEvents.RootObject CodecEvent;
=======
//private CiscoCodecEvents.RootObject CodecEvent;
>>>>>>> origin/feature/cisco-spark-2
/// <summary>
/// Gets and returns the scaled volume of the codec
@@ -67,12 +78,42 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
protected override Func<string> SharingSourceFeedbackFunc
{
get { return () => "Fix me fuckers"; }
get
{
return () => "Todo";
}
}
protected override Func<bool> MuteFeedbackFunc
{
get { return () => false; }
get
{
return () => CodecStatus.Status.Audio.VolumeMute.BoolValue;
}
}
protected Func<bool> RoomIsOccupiedFeedbackFunc
{
get
{
return () => CodecStatus.Status.RoomAnalytics.PeoplePresence.BoolValue;
}
}
protected Func<int> PeopleCountFeedbackFunc
{
get
{
return () => CodecStatus.Status.RoomAnalytics.PeopleCount.Current.IntValue;
}
}
protected Func<bool> SpeakerTrackIsOnFeedbackFunc
{
get
{
return () => CodecStatus.Status.Cameras.SpeakerTrack.Status.BoolValue;
}
}
//private HttpsClient Client;
@@ -125,7 +166,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
CodecStatus = new CiscoCodecStatus.RootObject();
CodecEvent = new CiscoCodecEvents.RootObject();
//CodecEvent = new CiscoCodecEvents.RootObject();
CodecStatus.Status.Audio.Volume.ValueChangedAction = VolumeLevelFeedback.FireUpdate;
CodecStatus.Status.Audio.VolumeMute.ValueChangedAction = MuteFeedback.FireUpdate;
@@ -482,6 +523,38 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
if (response.IndexOf("\"Status\":{") > -1)
{
// Check to see if this is a call status message received after the initial status message
if(SyncState.InitialStatusMessageWasReceived && response.IndexOf("\"Call\":{") > -1)
{
CiscoCodecStatus.RootObject callStatus = new CiscoCodecStatus.RootObject();
JsonConvert.PopulateObject(response, callStatus);
// Iterate through the call objects in the response
foreach (CiscoCodecStatus.Call call in callStatus.Status.Call)
{
// Look for a matching call id in the existing status structure
var existingCall = CodecStatus.Status.Call.FirstOrDefault(c => c.id.Equals(call.id));
if (existingCall != null)
{
// If an existing call object is found with a matching ID, populate the existing call with the new data.
// (must reserialize the object so that we can use PopulateObject() to overlay the new or updated properties on the existing object)
JsonConvert.PopulateObject(JsonConvert.SerializeObject(call), existingCall);
}
else
{
// Add the call
callStatus.Status.Call.Add(call);
// Add a call to the ActiveCalls List
//ActiveCalls.Add(new CodecActiveCallItem() { Id = call.id, Status = call.Status.Value, Name = call.DisplayName.Value, Number = call.RemoteNumber.Value, Type = call.Status.Value.ToString()
}
// Handle call.status to determine if we need to fire an event notifying of an incoming call or a call disconnect
}
}
JsonConvert.PopulateObject(response, CodecStatus);
if (!SyncState.InitialStatusMessageWasReceived)
@@ -507,7 +580,11 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
}
else if (response.IndexOf("\"Event\":{") > -1)
{
JsonConvert.PopulateObject(response, CodecEvent);
CiscoCodecEvents.RootObject eventReceived = new CiscoCodecEvents.RootObject();
JsonConvert.PopulateObject(response, eventReceived);
EvalutateEvent(eventReceived);
}
}
@@ -517,6 +594,24 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
}
}
/// <summary>
/// Evaluates an event received from the codec
/// </summary>
/// <param name="eventReceived"></param>
void EvalutateEvent(CiscoCodecEvents.RootObject eventReceived)
{
if (eventReceived.Event.CallDisconnect != null)
{
var tempCall = CodecStatus.Status.Call.FirstOrDefault(c => c.id.Equals(eventReceived.Event.CallDisconnect.CallId));
if(tempCall != null)
{
CodecStatus.Status.Call.Remove(tempCall);
}
}
}
public override void ExecuteSwitch(object selector)
{
(selector as Action)();
@@ -551,11 +646,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
SendText(string.Format("xCommand Dial BookingId: {0}", s));
}
<<<<<<< HEAD
public override void EndCall(string s)
{
SendText(string.Format("xCommand Call Disconnect CallId: {0}", GetCallId()));
=======
public override void EndCall(CodecActiveCallItem activeCall)
{
SendText(string.Format("xCommand Call Disconnect CallId: {0}", activeCall.Id));
@@ -567,15 +657,14 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
{
SendText(string.Format("xCommand Call Disconnect CallId: {0}", activeCall.Id));
}
>>>>>>> origin/feature/cisco-spark-2
}
public override void AcceptCall()
public override void AcceptCall(CodecActiveCallItem item)
{
SendText("xCommand Call Accept");
}
public override void RejectCall()
public override void RejectCall(CodecActiveCallItem item)
{
SendText("xCommand Call Reject");
}