UNPKG

@four-leaf-studios/rl-socket-hook

Version:

A tiny React wrapper around a Rocket League WebSocket plugin (`ws://localhost:49122`). It provides:

18 lines (15 loc) • 1.33 kB
import { jsxs, jsx } from 'react/jsx-runtime'; import { useRocketLeagueSocket } from './useRocketLeagueSocket.js'; const STATE_LABELS = ["CONNECTING", "OPEN", "CLOSING", "CLOSED"]; const WebsocketData = () => { const { events, readyState, error } = useRocketLeagueSocket(); return (jsxs("div", { style: { fontFamily: "monospace", padding: "1rem" }, children: [jsx("h1", { children: "Rocket League Live Events" }), jsxs("p", { children: [jsx("strong", { children: "Connection:" }), " ", STATE_LABELS[readyState] ?? readyState] }), error && (jsxs("p", { style: { color: "red" }, children: [jsx("strong", { children: "Error:" }), " ", String(error)] })), Object.entries(events).map(([event, payload]) => (jsxs("div", { style: { border: "1px solid #ccc", marginBottom: "1rem", padding: "0.5rem", borderRadius: "4px", backgroundColor: "#f9f9f9", }, children: [jsx("h2", { children: event }), jsx("pre", { style: { whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: JSON.stringify(payload, null, 2) })] }, event))), Object.keys(events).length === 0 && jsx("p", { children: "No events received yet." })] })); }; export { WebsocketData, WebsocketData as default }; //# sourceMappingURL=WebSocketData.js.map