refactor: websocket connect

This commit is contained in:
hamster1963
2024-12-02 02:15:46 +08:00
parent 6344064977
commit a9186f1148
6 changed files with 83 additions and 32 deletions

View File

@@ -1,11 +1,11 @@
import { createContext } from "react";
export interface WebSocketContextType {
sendMessage: (message: string) => void;
lastMessage: MessageEvent | null;
readyState: number;
lastMessage: { data: string } | null;
connected: boolean;
}
export const WebSocketContext = createContext<WebSocketContextType | undefined>(
undefined,
);
export const WebSocketContext = createContext<WebSocketContextType>({
lastMessage: null,
connected: false,
});