Implement WebSocket connection management and settings UI

This commit is contained in:
Mo Tarbin
2025-06-12 20:38:34 -04:00
parent 2162397575
commit a443582ca9
6 changed files with 632 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
import { createContext, useContext } from 'react'
import { useWebSocket } from '../hooks/useWebSocket'
const WebSocketContext = createContext({
connectionState: 3, // CLOSED
isConnected: false,
isConnecting: false,
lastEvent: null,
error: null,
connect: () => {},
disconnect: () => {},
getConnectionStatus: () => 'disconnected',
})
export const useWebSocketContext = () => {
return useContext(WebSocketContext)
}
export const WebSocketProvider = ({ children }) => {
const webSocketState = useWebSocket()
return (
<WebSocketContext.Provider value={webSocketState}>
{children}
</WebSocketContext.Provider>
)
}
export default WebSocketProvider