testing dynamic tcp server and secure tcp client, still need to finish testing and comment

This commit is contained in:
Joshua Gutenplan
2017-03-16 18:48:15 -07:00
parent ab2d0a1197
commit e28d1eaf5c
13 changed files with 110 additions and 114 deletions

Binary file not shown.

View File

@@ -6,7 +6,7 @@ using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronSockets; using Crestron.SimplSharp.CrestronSockets;
using PepperDash.Core; using PepperDash.Core;
namespace PepperDash_Core namespace PepperDash.Core
{ {
public class DynamicTCPServer : Device public class DynamicTCPServer : Device
{ {
@@ -40,7 +40,14 @@ namespace PepperDash_Core
public string status public string status
{ {
get { return Secure ? SecureServer.State.ToString() : UnsecureServer.State.ToString(); } get
{
if (Secure ? SecureServer != null : UnsecureServer != null)
return Secure ? SecureServer.State.ToString() : UnsecureServer.State.ToString();
else
return "";
}
} }
/// <summary> /// <summary>
@@ -48,7 +55,8 @@ namespace PepperDash_Core
/// </summary> /// </summary>
public bool IsConnected public bool IsConnected
{ {
get { return Secure ? SecureServer.State == ServerState.SERVER_CONNECTED : UnsecureServer.State == ServerState.SERVER_CONNECTED; } get { return (Secure ? SecureServer != null : UnsecureServer != null) &&
(Secure ? SecureServer.State == ServerState.SERVER_CONNECTED : UnsecureServer.State == ServerState.SERVER_CONNECTED); }
} }
/// <summary> /// <summary>
@@ -64,11 +72,10 @@ namespace PepperDash_Core
/// </summary> /// </summary>
public bool IsListening public bool IsListening
{ {
get { return Secure ? SecureServer.State == ServerState.SERVER_LISTENING : UnsecureServer.State == ServerState.SERVER_LISTENING; } get { return (Secure ? SecureServer != null : UnsecureServer != null) &&
(Secure ? SecureServer.State == ServerState.SERVER_LISTENING : UnsecureServer.State == ServerState.SERVER_LISTENING); }
} }
public ushort MaxConnections { get; set; } // should be set by parameter in SIMPL+ in the MAIN method, Should not ever need to be configurable
/// <summary> /// <summary>
/// S+ helper for IsConnected /// S+ helper for IsConnected
/// </summary> /// </summary>
@@ -77,12 +84,18 @@ namespace PepperDash_Core
get { return (ushort)(IsListening ? 1 : 0); } get { return (ushort)(IsListening ? 1 : 0); }
} }
public ushort MaxClients { get; set; } // should be set by parameter in SIMPL+ in the MAIN method, Should not ever need to be configurable
/// <summary> /// <summary>
/// Number of clients currently connected. /// Number of clients currently connected.
/// </summary> /// </summary>
public ushort NumberOfClientsConnected public ushort NumberOfClientsConnected
{ {
get { return Secure ? (ushort)SecureServer.NumberOfClientsConnected : (ushort)UnsecureServer.NumberOfClientsConnected; } get
{
if (Secure ? SecureServer != null : UnsecureServer != null)
return Secure ? (ushort)SecureServer.NumberOfClientsConnected : (ushort)UnsecureServer.NumberOfClientsConnected;
return 0;
}
} }
/// <summary> /// <summary>
@@ -122,19 +135,7 @@ namespace PepperDash_Core
/// SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module. /// SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module.
/// If SharedKey changes while server is listening or clients are connected, disconnect and stop listening will be called /// If SharedKey changes while server is listening or clients are connected, disconnect and stop listening will be called
/// </summary> /// </summary>
public string SharedKey public string SharedKey { get; set; }
{
get
{
return _SharedKey;
}
set
{
DisconnectAllClients();
_SharedKey = value;
}
}
private string _SharedKey;
/// <summary> /// <summary>
/// flags to show the secure server is waiting for client at index to send the shared key /// flags to show the secure server is waiting for client at index to send the shared key
@@ -152,17 +153,7 @@ namespace PepperDash_Core
/// </summary> /// </summary>
public int BufferSize { get; set; } public int BufferSize { get; set; }
public string OnlyAcceptConnectionFromAddress public string OnlyAcceptConnectionFromAddress { get; set; }
{
get { return _OnlyAcceptConnectionFromAddress; }
set
{
DisconnectAllClients();
MaxConnections = 1;
_OnlyAcceptConnectionFromAddress = value;
}
}
private string _OnlyAcceptConnectionFromAddress;
private bool ServerStopped { get; set; } private bool ServerStopped { get; set; }
@@ -190,66 +181,72 @@ namespace PepperDash_Core
public void Listen() public void Listen()
{ {
if (Port < 1 || Port > 65535) try
{ {
Debug.Console(1, Debug.ErrorLogLevel.Warning, "GenericSecureTcpClient '{0}': Invalid port", Key); if (Port < 1 || Port > 65535)
ErrorLog.Warn(string.Format("GenericSecureTcpClient '{0}': Invalid port", Key)); {
return; Debug.Console(1, Debug.ErrorLogLevel.Warning, "GenericSecureTcpClient '{0}': Invalid port", Key);
} ErrorLog.Warn(string.Format("GenericSecureTcpClient '{0}': Invalid port", Key));
if (string.IsNullOrEmpty(SharedKey) && RequiresPresharedKey)
{
Debug.Console(1, Debug.ErrorLogLevel.Warning, "GenericSecureTcpClient '{0}': No Shared Key set", Key);
ErrorLog.Warn(string.Format("GenericSecureTcpClient '{0}': No Shared Key set", Key));
return;
}
if (Secure)
{
if (SecureServer.State == ServerState.SERVER_LISTENING)
return; return;
SecureServer = new SecureTCPServer(Port, MaxConnections); }
SecureServer.SocketStatusChange += new SecureTCPServerSocketStatusChangeEventHandler(SecureServer_SocketStatusChange); if (string.IsNullOrEmpty(SharedKey) && RequiresPresharedKey)
ServerStopped = false; {
if (!string.IsNullOrEmpty(OnlyAcceptConnectionFromAddress)) Debug.Console(1, Debug.ErrorLogLevel.Warning, "GenericSecureTcpClient '{0}': No Shared Key set", Key);
SecureServer.WaitForConnectionAsync(OnlyAcceptConnectionFromAddress, SecureConnectCallback); ErrorLog.Warn(string.Format("GenericSecureTcpClient '{0}': No Shared Key set", Key));
else
SecureServer.WaitForConnectionAsync(IPAddress.Any, SecureConnectCallback);
Debug.Console(0, "Secure Server Status: {0}, Socket Status: {1}\r\n", SecureServer.State.ToString(), SecureServer.ServerSocketStatus);
}
else
{
if (UnsecureServer.State == ServerState.SERVER_LISTENING)
return; return;
UnsecureServer = new TCPServer(Port, MaxConnections); }
UnsecureServer.SocketStatusChange += new TCPServerSocketStatusChangeEventHandler(UnsecureServer_SocketStatusChange); if (IsListening)
ServerStopped = false; return;
if (!string.IsNullOrEmpty(OnlyAcceptConnectionFromAddress)) if (Secure)
UnsecureServer.WaitForConnectionAsync(OnlyAcceptConnectionFromAddress, UnsecureConnectCallback); {
SecureServer = new SecureTCPServer(Port, MaxClients);
SecureServer.SocketStatusChange += new SecureTCPServerSocketStatusChangeEventHandler(SecureServer_SocketStatusChange);
ServerStopped = false;
if (!string.IsNullOrEmpty(OnlyAcceptConnectionFromAddress))
SecureServer.WaitForConnectionAsync(OnlyAcceptConnectionFromAddress, SecureConnectCallback);
else
SecureServer.WaitForConnectionAsync(IPAddress.Any, SecureConnectCallback);
onServerStateChange();
Debug.Console(2, "Secure Server Status: {0}, Socket Status: {1}\r\n", SecureServer.State.ToString(), SecureServer.ServerSocketStatus);
}
else else
UnsecureServer.WaitForConnectionAsync(IPAddress.Any, UnsecureConnectCallback); {
Debug.Console(0, "Unsecure Server Status: {0}, Socket Status: {1}\r\n", UnsecureServer.State.ToString(), UnsecureServer.ServerSocketStatus); UnsecureServer = new TCPServer(Port, MaxClients);
UnsecureServer.SocketStatusChange += new TCPServerSocketStatusChangeEventHandler(UnsecureServer_SocketStatusChange);
ServerStopped = false;
if (!string.IsNullOrEmpty(OnlyAcceptConnectionFromAddress))
UnsecureServer.WaitForConnectionAsync(OnlyAcceptConnectionFromAddress, UnsecureConnectCallback);
else
UnsecureServer.WaitForConnectionAsync(IPAddress.Any, UnsecureConnectCallback);
onServerStateChange();
Debug.Console(2, "Unsecure Server Status: {0}, Socket Status: {1}\r\n", UnsecureServer.State.ToString(), UnsecureServer.ServerSocketStatus);
}
}
catch (Exception ex)
{
ErrorLog.Error("Error with Dynamic Server: {0}", ex.ToString());
} }
} }
public void StopListening() public void StopListening()
{ {
Debug.Console(0, "Stopping Listener"); Debug.Console(2, "Stopping Listener");
if (SecureServer != null && SecureServer.State == ServerState.SERVER_LISTENING) if (SecureServer != null && SecureServer.State == ServerState.SERVER_LISTENING)
SecureServer.Stop(); SecureServer.Stop();
if (UnsecureServer != null && UnsecureServer.State == ServerState.SERVER_LISTENING) if (UnsecureServer != null && UnsecureServer.State == ServerState.SERVER_LISTENING)
UnsecureServer.Stop(); UnsecureServer.Stop();
var handler = ServerStateChange;
if (ServerStateChange != null)
ServerStateChange(this, new DynamicTCPServerStateChangedEventArgs(this, Secure));
ServerStopped = true; ServerStopped = true;
onServerStateChange();
} }
public void DisconnectAllClients() public void DisconnectAllClients()
{ {
Debug.Console(0, "Disconnecting All Clients"); Debug.Console(2, "Disconnecting All Clients");
if (SecureServer != null && SecureServer.NumberOfClientsConnected > 0) if (SecureServer != null && SecureServer.NumberOfClientsConnected > 0)
SecureServer.DisconnectAll(); SecureServer.DisconnectAll();
if (UnsecureServer != null && UnsecureServer.NumberOfClientsConnected > 0) if (UnsecureServer != null && UnsecureServer.NumberOfClientsConnected > 0)
UnsecureServer.DisconnectAll(); UnsecureServer.DisconnectAll();
onServerStateChange(); //State shows both listening and connected
} }
public void BroadcastText(string text) public void BroadcastText(string text)
@@ -260,7 +257,7 @@ namespace PepperDash_Core
{ {
foreach (uint i in ConnectedClientsIndexes) foreach (uint i in ConnectedClientsIndexes)
{ {
byte[] b = Encoding.ASCII.GetBytes(text); byte[] b = Encoding.GetEncoding(28591).GetBytes(text);
SecureServer.SendDataAsync(i, b, b.Length, SecureSendDataAsyncCallback); SecureServer.SendDataAsync(i, b, b.Length, SecureSendDataAsyncCallback);
} }
} }
@@ -268,7 +265,7 @@ namespace PepperDash_Core
{ {
foreach (uint i in ConnectedClientsIndexes) foreach (uint i in ConnectedClientsIndexes)
{ {
byte[] b = Encoding.ASCII.GetBytes(text); byte[] b = Encoding.GetEncoding(28591).GetBytes(text);
UnsecureServer.SendDataAsync(i, b, b.Length, UnsecureSendDataAsyncCallback); UnsecureServer.SendDataAsync(i, b, b.Length, UnsecureSendDataAsyncCallback);
} }
} }
@@ -284,12 +281,12 @@ namespace PepperDash_Core
{ {
if (Secure) if (Secure)
{ {
byte[] b = Encoding.ASCII.GetBytes(text); byte[] b = Encoding.GetEncoding(28591).GetBytes(text);
SecureServer.SendDataAsync(clientIndex, b, b.Length, SecureSendDataAsyncCallback); SecureServer.SendDataAsync(clientIndex, b, b.Length, SecureSendDataAsyncCallback);
} }
else else
{ {
byte[] b = Encoding.ASCII.GetBytes(text); byte[] b = Encoding.GetEncoding(28591).GetBytes(text);
UnsecureServer.SendDataAsync(clientIndex, b, b.Length, UnsecureSendDataAsyncCallback); UnsecureServer.SendDataAsync(clientIndex, b, b.Length, UnsecureSendDataAsyncCallback);
} }
} }
@@ -298,7 +295,7 @@ namespace PepperDash_Core
#region Methods - Socket Status Changed Callbacks #region Methods - Socket Status Changed Callbacks
void SecureServer_SocketStatusChange(SecureTCPServer mySecureTCPServer, uint clientIndex, SocketStatus serverSocketStatus) void SecureServer_SocketStatusChange(SecureTCPServer mySecureTCPServer, uint clientIndex, SocketStatus serverSocketStatus)
{ {
Debug.Console(0, "Client at {0} ServerSocketStatus {1}", Debug.Console(2, "Client at {0} ServerSocketStatus {1}",
mySecureTCPServer.GetAddressServerAcceptedConnectionFromForSpecificClient(clientIndex), serverSocketStatus.ToString()); mySecureTCPServer.GetAddressServerAcceptedConnectionFromForSpecificClient(clientIndex), serverSocketStatus.ToString());
if (mySecureTCPServer.GetServerSocketStatusForSpecificClient(clientIndex) == SocketStatus.SOCKET_STATUS_CONNECTED) if (mySecureTCPServer.GetServerSocketStatusForSpecificClient(clientIndex) == SocketStatus.SOCKET_STATUS_CONNECTED)
{ {
@@ -317,7 +314,7 @@ namespace PepperDash_Core
void UnsecureServer_SocketStatusChange(TCPServer mySecureTCPServer, uint clientIndex, SocketStatus serverSocketStatus) void UnsecureServer_SocketStatusChange(TCPServer mySecureTCPServer, uint clientIndex, SocketStatus serverSocketStatus)
{ {
Debug.Console(0, "Client at {0} ServerSocketStatus {1}", Debug.Console(2, "Client at {0} ServerSocketStatus {1}",
mySecureTCPServer.GetAddressServerAcceptedConnectionFromForSpecificClient(clientIndex), serverSocketStatus.ToString()); mySecureTCPServer.GetAddressServerAcceptedConnectionFromForSpecificClient(clientIndex), serverSocketStatus.ToString());
if (mySecureTCPServer.GetServerSocketStatusForSpecificClient(clientIndex) == SocketStatus.SOCKET_STATUS_CONNECTED) if (mySecureTCPServer.GetServerSocketStatusForSpecificClient(clientIndex) == SocketStatus.SOCKET_STATUS_CONNECTED)
{ {
@@ -340,12 +337,12 @@ namespace PepperDash_Core
{ {
if (RequiresPresharedKey) if (RequiresPresharedKey)
{ {
byte[] b = Encoding.ASCII.GetBytes(SharedKey + "\n"); byte[] b = Encoding.GetEncoding(28591).GetBytes(SharedKey + "\n");
mySecureTCPServer.SendDataAsync(clientIndex, b, b.Length, SecureSendDataAsyncCallback); mySecureTCPServer.SendDataAsync(clientIndex, b, b.Length, SecureSendDataAsyncCallback);
Debug.Console(0, "Sent Shared Key to client at {0}", mySecureTCPServer.GetAddressServerAcceptedConnectionFromForSpecificClient(clientIndex)); Debug.Console(2, "Sent Shared Key to client at {0}", mySecureTCPServer.GetAddressServerAcceptedConnectionFromForSpecificClient(clientIndex));
} }
mySecureTCPServer.ReceiveDataAsync(clientIndex, SecureReceivedCallback); mySecureTCPServer.ReceiveDataAsync(clientIndex, SecureReceivedCallback);
if (mySecureTCPServer.State != ServerState.SERVER_LISTENING && MaxConnections > 1 && !ServerStopped) if (mySecureTCPServer.State != ServerState.SERVER_LISTENING && MaxClients > 1 && !ServerStopped)
SecureServer.WaitForConnectionAsync(IPAddress.Any, SecureConnectCallback); SecureServer.WaitForConnectionAsync(IPAddress.Any, SecureConnectCallback);
} }
} }
@@ -354,10 +351,10 @@ namespace PepperDash_Core
{ {
if (myTCPServer.ClientConnected(clientIndex)) if (myTCPServer.ClientConnected(clientIndex))
{ {
Debug.Console(0, "Connected to client at {0}", myTCPServer.GetAddressServerAcceptedConnectionFromForSpecificClient(clientIndex)); Debug.Console(2, "Connected to client at {0}", myTCPServer.GetAddressServerAcceptedConnectionFromForSpecificClient(clientIndex));
myTCPServer.ReceiveDataAsync(clientIndex, UnsecureReceivedCallback); myTCPServer.ReceiveDataAsync(clientIndex, UnsecureReceivedCallback);
} }
if (myTCPServer.State != ServerState.SERVER_LISTENING && MaxConnections > 1 && !ServerStopped) if (myTCPServer.State != ServerState.SERVER_LISTENING && MaxClients > 1 && !ServerStopped)
UnsecureServer.WaitForConnectionAsync(IPAddress.Any, UnsecureConnectCallback); UnsecureServer.WaitForConnectionAsync(IPAddress.Any, UnsecureConnectCallback);
} }
#endregion #endregion
@@ -379,17 +376,15 @@ namespace PepperDash_Core
{ {
string received = "Nothing"; string received = "Nothing";
byte[] bytes = mySecureTCPServer.GetIncomingDataBufferForSpecificClient(clientIndex); byte[] bytes = mySecureTCPServer.GetIncomingDataBufferForSpecificClient(clientIndex);
received = System.Text.Encoding.ASCII.GetString(bytes, 0, numberOfBytesReceived); received = System.Text.Encoding.GetEncoding(28591).GetString(bytes, 0, numberOfBytesReceived);
Debug.Console(0, "Secure Server Listening on Port: {0}, client IP: {1}, NumberOfBytesReceived: {2}, Received: {3}\r\n",
mySecureTCPServer.PortNumber, mySecureTCPServer.AddressServerAcceptedConnectionFrom, numberOfBytesReceived, received);
if (WaitingForSharedKey.Contains(clientIndex)) if (WaitingForSharedKey.Contains(clientIndex))
{ {
received = received.Replace("\r", ""); received = received.Replace("\r", "");
received = received.Replace("\n", ""); received = received.Replace("\n", "");
if (received != SharedKey) if (received != SharedKey)
{ {
byte[] b = Encoding.ASCII.GetBytes("Shared key did not match server. Disconnecting"); byte[] b = Encoding.GetEncoding(28591).GetBytes("Shared key did not match server. Disconnecting");
Debug.Console(0, "Client at index {0} Shared key did not match the server, disconnecting client", clientIndex); Debug.Console(2, "Client at index {0} Shared key did not match the server, disconnecting client", clientIndex);
ErrorLog.Error("Client at index {0} Shared key did not match the server, disconnecting client", clientIndex); ErrorLog.Error("Client at index {0} Shared key did not match the server, disconnecting client", clientIndex);
mySecureTCPServer.SendDataAsync(clientIndex, b, b.Length, null); mySecureTCPServer.SendDataAsync(clientIndex, b, b.Length, null);
mySecureTCPServer.Disconnect(clientIndex); mySecureTCPServer.Disconnect(clientIndex);
@@ -397,14 +392,16 @@ namespace PepperDash_Core
if (mySecureTCPServer.NumberOfClientsConnected > 0) if (mySecureTCPServer.NumberOfClientsConnected > 0)
mySecureTCPServer.ReceiveDataAsync(SecureReceivedCallback); mySecureTCPServer.ReceiveDataAsync(SecureReceivedCallback);
WaitingForSharedKey.Remove(clientIndex); WaitingForSharedKey.Remove(clientIndex);
byte[] skResponse = Encoding.ASCII.GetBytes("Shared Key Match, Connected and ready for communication"); byte[] skResponse = Encoding.GetEncoding(28591).GetBytes("Shared Key Match, Connected and ready for communication");
mySecureTCPServer.SendDataAsync(clientIndex, skResponse, skResponse.Length, null); mySecureTCPServer.SendDataAsync(clientIndex, skResponse, skResponse.Length, null);
mySecureTCPServer.ReceiveDataAsync(SecureReceivedCallback); mySecureTCPServer.ReceiveDataAsync(SecureReceivedCallback);
} }
else else
{ {
onTextReceived(received);
mySecureTCPServer.ReceiveDataAsync(SecureReceivedCallback); mySecureTCPServer.ReceiveDataAsync(SecureReceivedCallback);
Debug.Console(2, "Secure Server Listening on Port: {0}, client IP: {1}, NumberOfBytesReceived: {2}, Received: {3}\r\n",
mySecureTCPServer.PortNumber, mySecureTCPServer.AddressServerAcceptedConnectionFrom, numberOfBytesReceived, received);
onTextReceived(received);
} }
} }
if (mySecureTCPServer.GetServerSocketStatusForSpecificClient(clientIndex) == SocketStatus.SOCKET_STATUS_CONNECTED) if (mySecureTCPServer.GetServerSocketStatusForSpecificClient(clientIndex) == SocketStatus.SOCKET_STATUS_CONNECTED)
@@ -417,11 +414,11 @@ namespace PepperDash_Core
{ {
string received = "Nothing"; string received = "Nothing";
byte[] bytes = myTCPServer.GetIncomingDataBufferForSpecificClient(clientIndex); byte[] bytes = myTCPServer.GetIncomingDataBufferForSpecificClient(clientIndex);
received = System.Text.Encoding.ASCII.GetString(bytes, 0, numberOfBytesReceived); received = System.Text.Encoding.GetEncoding(28591).GetString(bytes, 0, numberOfBytesReceived);
Debug.Console(0, "Unsecure Server Listening on Port: {0}, client IP: {1}, NumberOfBytesReceived: {2}, Received: {3}\r\n", Debug.Console(2, "Unsecure Server Listening on Port: {0}, client IP: {1}, NumberOfBytesReceived: {2}, Received: {3}\r\n",
myTCPServer.PortNumber, myTCPServer.AddressServerAcceptedConnectionFrom, numberOfBytesReceived, received); myTCPServer.PortNumber, myTCPServer.AddressServerAcceptedConnectionFrom, numberOfBytesReceived, received);
myTCPServer.ReceiveDataAsync(UnsecureReceivedCallback);
onTextReceived(received); onTextReceived(received);
myTCPServer.ReceiveDataAsync(UnsecureReceivedCallback);
} }
if (myTCPServer.GetServerSocketStatusForSpecificClient(clientIndex) == SocketStatus.SOCKET_STATUS_CONNECTED) if (myTCPServer.GetServerSocketStatusForSpecificClient(clientIndex) == SocketStatus.SOCKET_STATUS_CONNECTED)
myTCPServer.ReceiveDataAsync(clientIndex, UnsecureReceivedCallback); myTCPServer.ReceiveDataAsync(clientIndex, UnsecureReceivedCallback);
@@ -435,9 +432,9 @@ namespace PepperDash_Core
if (handler != null) if (handler != null)
{ {
if (Secure) if (Secure)
ClientConnectionChange(this, new DynamicTCPServerSocketStatusChangeEventArgs(SecureServer, Secure)); handler(this, new DynamicTCPServerSocketStatusChangeEventArgs(SecureServer, Secure));
else else
ClientConnectionChange(this, new DynamicTCPServerSocketStatusChangeEventArgs(UnsecureServer, Secure)); handler(this, new DynamicTCPServerSocketStatusChangeEventArgs(UnsecureServer, Secure));
} }
} }
@@ -445,7 +442,19 @@ namespace PepperDash_Core
{ {
var handler = TextReceived; var handler = TextReceived;
if (handler != null) if (handler != null)
TextReceived(this, new GenericCommMethodReceiveTextArgs(text)); handler(this, new GenericCommMethodReceiveTextArgs(text));
}
void onServerStateChange()
{
var handler = ServerStateChange;
if(handler != null)
{
if(Secure)
handler(this, new DynamicTCPServerStateChangedEventArgs(SecureServer, Secure));
else
handler(this, new DynamicTCPServerStateChangedEventArgs(UnsecureServer, Secure));
}
} }
void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType) void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType)

View File

@@ -63,20 +63,7 @@ namespace PepperDash.Core
/// <summary> /// <summary>
/// SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module /// SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module
/// </summary> /// </summary>
public string SharedKey public string SharedKey { get; set; }
{
get
{
return _SharedKey;
}
set
{
if (Client.ClientStatus == SocketStatus.SOCKET_STATUS_CONNECTED)
Client.DisconnectFromServer();
_SharedKey = value;
}
}
private string _SharedKey;
/// <summary> /// <summary>
/// flag to show the client is waiting for the server to send the shared key /// flag to show the client is waiting for the server to send the shared key
@@ -362,7 +349,7 @@ namespace PepperDash.Core
void Client_SocketStatusChange(SecureTCPClient client, SocketStatus clientSocketStatus) void Client_SocketStatusChange(SecureTCPClient client, SocketStatus clientSocketStatus)
{ {
Debug.Console(2, this, "Socket status change {0} ({1})", clientSocketStatus, ClientStatusText); Debug.Console(2, this, "Socket status change {0} ({1})", clientSocketStatus, ClientStatusText);
if (client.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED && !DisconnectCalledByUser) if (client.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED && !DisconnectCalledByUser && AutoReconnect)
WaitAndTryReconnect(); WaitAndTryReconnect();
// Probably doesn't need to be a switch since all other cases were eliminated // Probably doesn't need to be a switch since all other cases were eliminated

View File

@@ -313,7 +313,7 @@ namespace PepperDash.Core
void Client_SocketStatusChange(TCPClient client, SocketStatus clientSocketStatus) void Client_SocketStatusChange(TCPClient client, SocketStatus clientSocketStatus)
{ {
Debug.Console(2, this, "Socket status change {0} ({1})", clientSocketStatus, ClientStatusText); Debug.Console(2, this, "Socket status change {0} ({1})", clientSocketStatus, ClientStatusText);
if (client.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED && !DisconnectCalledByUser) if (client.ClientStatus != SocketStatus.SOCKET_STATUS_CONNECTED && !DisconnectCalledByUser && AutoReconnect)
WaitAndTryReconnect(); WaitAndTryReconnect();
// Probably doesn't need to be a switch since all other cases were eliminated // Probably doesn't need to be a switch since all other cases were eliminated

View File

@@ -10,8 +10,8 @@
<ArchiveName /> <ArchiveName />
</RequiredInfo> </RequiredInfo>
<OptionalInfo> <OptionalInfo>
<CompiledOn>3/15/2017 3:30:41 PM</CompiledOn> <CompiledOn>3/16/2017 4:29:50 PM</CompiledOn>
<CompilerRev>1.0.6283.26120</CompilerRev> <CompilerRev>1.0.6284.27894</CompilerRev>
</OptionalInfo> </OptionalInfo>
<Plugin> <Plugin>
<Version>Crestron.SIMPLSharp, Version=2.0.52.0, Culture=neutral, PublicKeyToken=812d080f93e2de10</Version> <Version>Crestron.SIMPLSharp, Version=2.0.52.0, Culture=neutral, PublicKeyToken=812d080f93e2de10</Version>

View File

@@ -1,4 +1,4 @@
MainAssembly=PepperDash_Core.dll:36d08f49a05b4a3b41534e1c11044524 MainAssembly=PepperDash_Core.dll:6f9c7beaa687813ff469ca17ed4a2b09
MainAssemblyMinFirmwareVersion=1.007.0017 MainAssemblyMinFirmwareVersion=1.007.0017
MainAssemblyResource=SimplSharpData.dat:315526abf906cded47fb0c7510266a7e MainAssemblyResource=SimplSharpData.dat:315526abf906cded47fb0c7510266a7e
ü ü