Merge pull request #111 from PepperDash/hotfix/sshclient-add-check-before-sending

fix(GenericSshClient): #110 Adds check to ensure TheStream != null and IsConnected in SendText() and SentBytes()
This commit is contained in:
Andrew Welker
2021-07-31 22:37:53 -06:00
committed by GitHub

View File

@@ -435,7 +435,7 @@ namespace PepperDash.Core
{
try
{
if (Client != null)
if (Client != null && TheStream != null && IsConnected)
{
if (StreamDebugging.TxStreamDebuggingIsEnabled)
Debug.Console(0, this, "Sending {0} characters of text: '{1}'", text.Length, ComTextHelper.GetDebugText(text));
@@ -443,6 +443,10 @@ namespace PepperDash.Core
TheStream.Write(text);
TheStream.Flush();
}
else
{
Debug.Console(2, this, "Client is null or disconnected. Cannot Send Text");
}
}
catch (Exception ex)
@@ -464,13 +468,17 @@ namespace PepperDash.Core
{
try
{
if (Client != null)
if (Client != null && TheStream != null && IsConnected)
{
if (StreamDebugging.TxStreamDebuggingIsEnabled)
Debug.Console(0, this, "Sending {0} bytes: '{1}'", bytes.Length, ComTextHelper.GetEscapedText(bytes));
TheStream.Write(bytes, 0, bytes.Length);
TheStream.Flush();
}
else
{
Debug.Console(2, this, "Client is null or disconnected. Cannot Send Bytes");
}
}
catch