Moved on ready to call on connect callback if shared key not required and connected. Moved text received event to else to get called on first message if shared key is off

This commit is contained in:
Joshua Gutenplan
2019-06-10 02:07:00 -07:00
parent 8362197030
commit 229723b50f

View File

@@ -382,6 +382,15 @@ namespace PepperDash.Core
//OnClientReadyForcommunications(false); // Should send false event //OnClientReadyForcommunications(false); // Should send false event
}, 15000); }, 15000);
} }
else
{
//CLient connected and shared key is not required so just raise the ready for communication event. if Shared key
//required this is called by the shared key being negotiated
if (IsReadyForCommunication == false)
{
OnClientReadyForcommunications(true); // Key not required
}
}
} }
else else
{ {
@@ -486,7 +495,6 @@ namespace PepperDash.Core
Debug.Console(2, this, "Client Received:\r--------\r{0}\r--------", str); Debug.Console(2, this, "Client Received:\r--------\r{0}\r--------", str);
if (!string.IsNullOrEmpty(checkHeartbeat(str))) if (!string.IsNullOrEmpty(checkHeartbeat(str)))
{ {
if (SharedKeyRequired && str == "SharedKey:") if (SharedKeyRequired && str == "SharedKey:")
{ {
Debug.Console(1, this, "Server asking for shared key, sending"); Debug.Console(1, this, "Server asking for shared key, sending");
@@ -495,19 +503,11 @@ namespace PepperDash.Core
else if (SharedKeyRequired && str == "Shared Key Match") else if (SharedKeyRequired && str == "Shared Key Match")
{ {
StopWaitForSharedKeyTimer(); StopWaitForSharedKeyTimer();
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Shared key confirmed. Ready for communication"); Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Shared key confirmed. Ready for communication");
OnClientReadyForcommunications(true); // Successful key exchange OnClientReadyForcommunications(true); // Successful key exchange
} }
else if (SharedKeyRequired == false && IsReadyForCommunication == false)
{
OnClientReadyForcommunications(true); // Key not required
}
else else
{ {
//var bytesHandler = BytesReceived; //var bytesHandler = BytesReceived;
//if (bytesHandler != null) //if (bytesHandler != null)
// bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes)); // bytesHandler(this, new GenericCommMethodReceiveBytesArgs(bytes));
@@ -699,6 +699,7 @@ namespace PepperDash.Core
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Socket status change: {0} ({1})", client.ClientStatus, (ushort)(client.ClientStatus)); Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Socket status change: {0} ({1})", client.ClientStatus, (ushort)(client.ClientStatus));
OnConnectionChange(); OnConnectionChange();
// The client could be null or disposed by this time... // The client could be null or disposed by this time...
if (Client == null || Client.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED) if (Client == null || Client.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED)
{ {