fix(essentials): Adds logic to recover from malformed json response on initial communication.

Adds better formatting for active calls list print to console
This commit is contained in:
Neil Dorin
2022-02-09 17:07:18 -07:00
parent 7a2e99f145
commit bfdc882eb6
2 changed files with 13 additions and 1 deletions

View File

@@ -1182,6 +1182,16 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
} }
catch (Exception ex) catch (Exception ex)
{ {
if (ex is Newtonsoft.Json.JsonReaderException)
{
Debug.Console(1, this, "Received malformed response from codec. Unable to serialize. Disconnecting and attmpting to recconnect");
Communication.Disconnect();
Initialize();
}
Debug.Console(1, this, "Error Deserializing feedback from codec: {0}", ex); Debug.Console(1, this, "Error Deserializing feedback from codec: {0}", ex);
} }
} }

View File

@@ -257,10 +257,12 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
/// </summary> /// </summary>
public virtual void ListCalls() public virtual void ListCalls()
{ {
Debug.Console(1, this, "Active Calls:");
var sb = new StringBuilder(); var sb = new StringBuilder();
foreach (var c in ActiveCalls) foreach (var c in ActiveCalls)
{ {
sb.AppendFormat("{0} {1} -- {2} {3}\n", c.Id, c.Number, c.Name, c.Status); sb.AppendFormat("id: {0} number: {1} -- name: {2} status: {3} onHold: {4}\r\n", c.Id, c.Number, c.Name, c.Status, c.IsOnHold);
} }
Debug.Console(1, this, "\n{0}\n", sb.ToString()); Debug.Console(1, this, "\n{0}\n", sb.ToString());
} }