diff --git a/.github/workflows/add-issues-to-project.yml b/.github/workflows/add-issues-to-project.yml new file mode 100644 index 0000000..8811c0c --- /dev/null +++ b/.github/workflows/add-issues-to-project.yml @@ -0,0 +1,37 @@ +name: Add bugs to bugs project + +on: + issues: + types: + - opened + - labeled + +jobs: + check-secret: + runs-on: ubuntu-latest + outputs: + my-key: ${{ steps.my-key.outputs.defined }} + steps: + - id: my-key + if: "${{ env.MY_KEY != '' }}" + run: echo "::set-output name=defined::true" + env: + MY_KEY: ${{ secrets.PROJECT_URL }} + throw-error: + name: Check + runs-on: ubuntu-latest + needs: [check-secret] + if: needs.check-secret.outputs.my-key != 'true' + steps: + - run: echo "The Project URL Repo Secret is empty" + add-to-project: + name: Add issue to project + runs-on: ubuntu-latest + needs: [check-secret] + if: needs.check-secret.outputs.my-key == 'true' + steps: + - uses: actions/add-to-project@main + with: + project-url: ${{ secrets.PROJECT_URL }} + github-token: ${{ secrets.GH_PROJECTS_PASSWORD }} + diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs index 88f9682..4c93278 100644 --- a/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs +++ b/Pepperdash Core/Pepperdash Core/Comm/GenericSshClient.cs @@ -312,17 +312,15 @@ namespace PepperDash.Core /// public void Disconnect() { - try - { - connectLock.Enter(); - // Stop trying reconnects, if we are - ReconnectTimer.Stop(); - KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY); - } - finally - { - connectLock.Leave(); - } + ConnectEnabled = false; + // Stop trying reconnects, if we are + if (ReconnectTimer != null) + { + ReconnectTimer.Stop(); + ReconnectTimer = null; + } + + KillClient(SocketStatus.SOCKET_STATUS_BROKEN_LOCALLY); } /// @@ -331,24 +329,45 @@ namespace PepperDash.Core private void KillClient(SocketStatus status) { KillStream(); - + if (Client != null) { - try - { - Client.Disconnect(); - Client.Dispose(); - Client = null; - ClientStatus = status; - Debug.Console(1, this, "Disconnected client"); - } - catch (Exception ex) - { - Debug.Console(1, this, "Exception killing client: {0}", ex.Message); - } + IsConnecting = false; + Client.Disconnect(); + Client = null; + ClientStatus = status; + Debug.Console(1, this, "Disconnected"); } } + /// + /// Anything to do with reestablishing connection on failures + /// + void HandleConnectionFailure() + { + KillClient(SocketStatus.SOCKET_STATUS_CONNECT_FAILED); + + Debug.Console(1, this, "Client nulled due to connection failure. AutoReconnect: {0}, ConnectEnabled: {1}", AutoReconnect, ConnectEnabled); + if (AutoReconnect && ConnectEnabled) + { + Debug.Console(1, this, "Checking autoreconnect: {0}, {1}ms", AutoReconnect, AutoReconnectIntervalMs); + if (ReconnectTimer == null) + { + ReconnectTimer = new CTimer(o => + { + Connect(); + }, AutoReconnectIntervalMs); + Debug.Console(1, this, "Attempting connection in {0} seconds", + (float) (AutoReconnectIntervalMs/1000)); + } + else + { + Debug.Console(1, this, "{0} second reconnect cycle running", + (float) (AutoReconnectIntervalMs/1000)); + } + } + } + /// /// Kills the stream ///