Initialize StreamDebugging from S+ constructors

This commit is contained in:
Andrew Welker
2020-08-14 10:51:49 -06:00
parent a8696b356d
commit 6133df971d
3 changed files with 14 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ namespace PepperDash.Core
/// </summary>
public class GenericSshClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
{
private const string SPlusKey = "Uninitialized SshClient";
public CommunicationStreamDebugging StreamDebugging { get; private set; }
/// <summary>
@@ -155,8 +156,9 @@ namespace PepperDash.Core
/// S+ Constructor - Must set all properties before calling Connect
/// </summary>
public GenericSshClient()
: base("Uninitialized SshClient")
: base(SPlusKey)
{
StreamDebugging = new CommunicationStreamDebugging(SPlusKey);
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
AutoReconnectIntervalMs = 5000;
}
@@ -437,8 +439,11 @@ namespace PepperDash.Core
}
}
catch
catch (Exception ex)
{
Debug.Console(0, "Exception: {0}", ex.Message);
Debug.Console(0, "Stack Trace: {0}", ex.StackTrace);
Debug.Console(1, this, "Stream write failed. Disconnected, closing");
ClientStatus = SocketStatus.SOCKET_STATUS_BROKEN_REMOTELY;
HandleConnectionFailure();

View File

@@ -15,7 +15,8 @@ namespace PepperDash.Core
/// A class to handle basic TCP/IP communications with a server
/// </summary>
public class GenericTcpIpClient : Device, ISocketStatusWithStreamDebugging, IAutoReconnect
{
{
private const string SplusKey = "Uninitialized TcpIpClient";
public CommunicationStreamDebugging StreamDebugging { get; private set; }
/// <summary>
@@ -204,8 +205,9 @@ namespace PepperDash.Core
/// Default constructor for S+
/// </summary>
public GenericTcpIpClient()
: base("Uninitialized TcpIpClient")
: base(SplusKey)
{
StreamDebugging = new CommunicationStreamDebugging(SplusKey);
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
AutoReconnectIntervalMs = 5000;
BufferSize = 2000;

View File

@@ -17,6 +17,7 @@ namespace PepperDash.Core
{
public class GenericUdpServer : Device, ISocketStatusWithStreamDebugging
{
private const string SplusKey = "Uninitialized Udp Server";
public CommunicationStreamDebugging StreamDebugging { get; private set; }
/// <summary>
///
@@ -119,8 +120,9 @@ namespace PepperDash.Core
/// Constructor for S+. Make sure to set key, address, port, and buffersize using init method
/// </summary>
public GenericUdpServer()
: base("Uninitialized Udp Server")
: base(SplusKey)
{
StreamDebugging = new CommunicationStreamDebugging(SplusKey);
BufferSize = 5000;
DequeueLock = new CCriticalSection();
MessageQueue = new CrestronQueue<GenericUdpReceiveTextExtraArgs>();