Skip to content

Commit

Permalink
Changes the conditions under which the server would restart.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason T Alborough committed Jan 18, 2020
1 parent dd3227d commit b5f611f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
Binary file added ._Readme.md
Binary file not shown.
49 changes: 24 additions & 25 deletions Pepperdash Core/Pepperdash Core/Comm/GenericSecureTcpIpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -403,31 +403,26 @@ public void Listen()
ErrorLog.Warn(string.Format("Server '{0}': No Shared Key set", Key));
return;
}
if (IsListening)
return;

if (SecureServer == null)
{
SecureServer = new SecureTCPServer(Port, MaxClients);
if(HeartbeatRequired)
SecureServer.SocketSendOrReceiveTimeOutInMs = (this.HeartbeatRequiredIntervalMs * 5);
SecureServer.HandshakeTimeout = 30;
SecureServer.SocketStatusChange += new SecureTCPServerSocketStatusChangeEventHandler(SecureServer_SocketStatusChange);
}
else
{
//KillServer(); Remove this to be able to reactivate listener if it stops itself due to max clients without disconnecting connected clients.
SecureServer.PortNumber = Port;
}
ServerStopped = false;
SecureServer.WaitForConnectionAsync(IPAddress.Any, SecureConnectCallback);
OnServerStateChange(SecureServer.State);
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Secure Server Status: {0}, Socket Status: {1}", SecureServer.State, SecureServer.ServerSocketStatus);

// StartMonitorClient();


ServerCCSection.Leave();
if (SecureServer == null)
{
SecureServer = new SecureTCPServer(Port, MaxClients);
if (HeartbeatRequired)
SecureServer.SocketSendOrReceiveTimeOutInMs = (this.HeartbeatRequiredIntervalMs * 5);
SecureServer.HandshakeTimeout = 30;
SecureServer.SocketStatusChange += new SecureTCPServerSocketStatusChangeEventHandler(SecureServer_SocketStatusChange);
}
else
{
SecureServer.PortNumber = Port;
}
ServerStopped = false;
SecureServer.WaitForConnectionAsync(IPAddress.Any, SecureConnectCallback);
OnServerStateChange(SecureServer.State);
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Secure Server Status: {0}, Socket Status: {1}", SecureServer.State, SecureServer.ServerSocketStatus);
ServerCCSection.Leave();

}
catch (Exception ex)
{
Expand Down Expand Up @@ -677,10 +672,13 @@ void SecureServer_SocketStatusChange(SecureTCPServer server, uint clientIndex, S
{
try
{


Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "SecureServerSocketStatusChange Index:{0} status:{1} Port:{2} IP:{3}", clientIndex, serverSocketStatus, this.SecureServer.GetPortNumberServerAcceptedConnectionFromForSpecificClient(clientIndex), this.SecureServer.GetLocalAddressServerAcceptedConnectionFromForSpecificClient(clientIndex));
// Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "SecureServerSocketStatusChange Index:{0} status:{1} Port:{2} IP:{3}", clientIndex, serverSocketStatus, this.SecureServer.GetPortNumberServerAcceptedConnectionFromForSpecificClient(clientIndex), this.SecureServer.GetLocalAddressServerAcceptedConnectionFromForSpecificClient(clientIndex));
if (serverSocketStatus != SocketStatus.SOCKET_STATUS_CONNECTED)
{
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "SecureServerSocketStatusChange ConnectedCLients: {0} ServerState: {1} Port: {2}", SecureServer.NumberOfClientsConnected, SecureServer.State, SecureServer.PortNumber);

if (ConnectedClientsIndexes.Contains(clientIndex))
ConnectedClientsIndexes.Remove(clientIndex);
if (HeartbeatRequired && HeartbeatTimerDictionary.ContainsKey(clientIndex))
Expand All @@ -693,7 +691,7 @@ void SecureServer_SocketStatusChange(SecureTCPServer server, uint clientIndex, S
ClientReadyAfterKeyExchange.Remove(clientIndex);
if (WaitingForSharedKey.Contains(clientIndex))
WaitingForSharedKey.Remove(clientIndex);
if (SecureServer.MaxNumberOfClientSupported > SecureServer.NumberOfClientsConnected && SecureServer.State == ServerState.SERVER_NOT_LISTENING)
if (SecureServer.MaxNumberOfClientSupported > SecureServer.NumberOfClientsConnected)
{
Listen();
}
Expand Down Expand Up @@ -797,6 +795,7 @@ void SecureReceivedDataAsyncCallback(SecureTCPServer mySecureTCPServer, uint cli
{
if (numberOfBytesReceived > 0)
{

string received = "Nothing";
var handler = TextReceivedQueueInvoke;
try
Expand Down
2 changes: 2 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@
- Build the project
- Copy PepperDash_Core.cpz and PepperDash_Core.dll from the bin folder to the CLZ Builds folder in the repo root. Commit.
- Merge the PR in Bitbucket


0 comments on commit b5f611f

Please sign in to comment.