🔌 Setting autoReconnect to true in the ADCPP constructor
This commit is contained in:
@@ -37,12 +37,27 @@ function sleep(ms: number): Promise<NodeJS.Timeout> {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
export const setAirDCPPSocketConnectionAsActive = () => async (dispatch) => {
|
||||
console.log("fire, fire, fire");
|
||||
dispatch({
|
||||
type: AIRDCPP_SOCKET_CONNECTED,
|
||||
});
|
||||
};
|
||||
export const toggleAirDCPPSocketConnectionStatus =
|
||||
(status: String) => async (dispatch) => {
|
||||
console.log("sanul", status);
|
||||
switch (status) {
|
||||
case "connected":
|
||||
dispatch({
|
||||
type: AIRDCPP_SOCKET_CONNECTED,
|
||||
});
|
||||
break;
|
||||
|
||||
case "disconnected":
|
||||
dispatch({
|
||||
type: AIRDCPP_SOCKET_DISCONNECTED,
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
console.log("Can't set AirDC++ socket status.");
|
||||
break;
|
||||
}
|
||||
};
|
||||
export const search =
|
||||
(data: SearchData, ADCPPSocket: any, credentials: any) =>
|
||||
async (dispatch) => {
|
||||
|
||||
@@ -10,9 +10,10 @@ const Navbar: React.FunctionComponent = (props) => {
|
||||
(state: RootState) => state.airdcpp.downloadProgressData,
|
||||
);
|
||||
|
||||
// const airDCPPSocketConnectionStatus = useSelector((state: RootState) => {
|
||||
// console.log(state);
|
||||
// });
|
||||
const airDCPPSocketConnectionStatus = useSelector((state: RootState) => {
|
||||
console.log(state);
|
||||
return state.airdcpp.isAirDCPPSocketConnected;
|
||||
});
|
||||
|
||||
return (
|
||||
<nav className="navbar is-fixed-top">
|
||||
@@ -88,9 +89,15 @@ const Navbar: React.FunctionComponent = (props) => {
|
||||
</div>
|
||||
{/* AirDC++ socket connection status */}
|
||||
<div className="navbar-item has-dropdown is-hoverable">
|
||||
<a className="navbar-link is-arrowless has-text-success">
|
||||
<i className="fa-solid fa-bolt"></i>
|
||||
</a>
|
||||
{airDCPPSocketConnectionStatus ? (
|
||||
<a className="navbar-link is-arrowless has-text-success">
|
||||
<i className="fa-solid fa-bolt"></i>
|
||||
</a>
|
||||
) : (
|
||||
<a className="navbar-link is-arrowless has-text-danger">
|
||||
<i className="fa-solid fa-bolt"></i>
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="navbar-item has-dropdown is-hoverable is-mega">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { isEmpty, isUndefined } from "lodash";
|
||||
import React, { createContext, useEffect, useState } from "react";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { setAirDCPPSocketConnectionAsActive } from "../actions/airdcpp.actions";
|
||||
import { toggleAirDCPPSocketConnectionStatus } from "../actions/airdcpp.actions";
|
||||
import { getSettings } from "../actions/settings.actions";
|
||||
|
||||
import AirDCPPSocket from "../services/DcppSearchService";
|
||||
@@ -57,18 +57,20 @@ const AirDCPPSocketContextProvider = ({ children }) => {
|
||||
const initializedAirDCPPSocket = new AirDCPPSocket({
|
||||
protocol: `${host.protocol}`,
|
||||
hostname: `${host.hostname}:${host.port}`,
|
||||
username: `${host.username}`,
|
||||
password: `${host.password}`,
|
||||
});
|
||||
|
||||
// connect and disconnect handlers
|
||||
initializedAirDCPPSocket.onConnected = (sessionInfo) => {
|
||||
dispatch(setAirDCPPSocketConnectionAsActive());
|
||||
dispatch(toggleAirDCPPSocketConnectionStatus("connected"));
|
||||
};
|
||||
initializedAirDCPPSocket.onDisconnected = async (
|
||||
reason,
|
||||
code,
|
||||
wasClean,
|
||||
) => {
|
||||
console.log("kulkarni kamal kulthe", reason, code, wasClean);
|
||||
dispatch(toggleAirDCPPSocketConnectionStatus("disconnected"));
|
||||
};
|
||||
|
||||
const socketConnectionInformation = await initializedAirDCPPSocket.connect(
|
||||
|
||||
@@ -10,7 +10,7 @@ class AirDCPPSocket {
|
||||
}
|
||||
const options = {
|
||||
url: `${socketProtocol}://${configuration.hostname}/api/v1/`,
|
||||
autoReconnect: false,
|
||||
autoReconnect: true,
|
||||
reconnectInterval: 5,
|
||||
logLevel: "verbose",
|
||||
ignoredListenerEvents: [
|
||||
@@ -18,6 +18,8 @@ class AirDCPPSocket {
|
||||
"hash_statistics",
|
||||
"hub_counts_updated",
|
||||
],
|
||||
username: `${configuration.username}`,
|
||||
password: `${configuration.password}`,
|
||||
};
|
||||
const AirDCPPSocketInstance = Socket(options, window.WebSocket as any);
|
||||
return AirDCPPSocketInstance;
|
||||
|
||||
Reference in New Issue
Block a user