清除注释

This commit is contained in:
al 2024-12-26 20:23:39 +08:00
parent c4650da62e
commit 04beb7b6a3
1 changed files with 6 additions and 5 deletions

View File

@ -21,7 +21,7 @@ const WebSocketComponent = ({ getData, authInfo }) => {
if (!socketRef.current && account) { if (!socketRef.current && account) {
retryInterval = Math.min(retryInterval * 2, maxInterval); retryInterval = Math.min(retryInterval * 2, maxInterval);
const timer = setInterval(() => { const timer = setInterval(() => {
if (socketRef.current?.readyState !== 1) { if (socketRef.current?.readyState !== 1 && account) {
if (socketRef.current) { if (socketRef.current) {
socketRef.current?.close(); socketRef.current?.close();
socketRef.current = null; socketRef.current = null;
@ -47,7 +47,8 @@ const WebSocketComponent = ({ getData, authInfo }) => {
const connect_socket = () => { const connect_socket = () => {
const base = baseRequest(); const base = baseRequest();
const account = get("account"); const account = get("account");
if (socketRef.current?.readyState === 1) return; // console.log(account);
if (socketRef.current?.readyState === 1 || !account) return;
// WebSocket // WebSocket
socketRef.current = new WebSocket( socketRef.current = new WebSocket(
`${process.env.NEXT_PUBLIC_WEBSOCKET_URL}/ws?b_mid=${base.b_mid}&b_dt=1&b_token=${base.b_token}&b_ch=h5` `${process.env.NEXT_PUBLIC_WEBSOCKET_URL}/ws?b_mid=${base.b_mid}&b_dt=1&b_token=${base.b_token}&b_ch=h5`
@ -69,7 +70,7 @@ const WebSocketComponent = ({ getData, authInfo }) => {
reader.readAsText(event.data, "utf-8"); reader.readAsText(event.data, "utf-8");
reader.onload = function (e) { reader.onload = function (e) {
if (reader.result === "pong") { if (reader.result === "pong") {
console.log("pong received"); // console.log("pong received");
} }
try { try {
const data = JSON.parse(reader.result); const data = JSON.parse(reader.result);
@ -97,11 +98,11 @@ const WebSocketComponent = ({ getData, authInfo }) => {
// //
socketRef.current.onclose = () => { socketRef.current.onclose = () => {
console.log("WebSocket closed.", socketRef.current.readyState); // console.log("WebSocket closed.", socketRef.current.readyState);
clearInterval(interval); clearInterval(interval);
if (account) { if (account) {
console.log("WebSocket closed--------.", account); // console.log("WebSocket closed--------.", account);
setTimeout(connect_socket, 1000); setTimeout(connect_socket, 1000);
// retryInterval = Math.min(retryInterval * 2, maxInterval); // retryInterval = Math.min(retryInterval * 2, maxInterval);
} }