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