import React, { useCallback, useEffect, useRef, useState } from "react"; import ColorHash from "color-hash"; import styles from "./DevTools.module.css"; const colorHash = new ColorHash({ lightness: 0.8 }); function UserId({ userId, ...rest }) { const shortUserId = userId.split(":")[0]; const color = colorHash.hex(shortUserId); return ( {shortUserId} ); } function CallId({ callId, ...rest }) { const shortId = callId.substr(callId.length - 16); const color = colorHash.hex(shortId); return ( {shortId} ); } export function DevTools({ manager }) { const [debugState, setDebugState] = useState(manager.debugState); const [selectedEvent, setSelectedEvent] = useState(); useEffect(() => { function onRoomDebug() { setDebugState(manager.debugState); } manager.on("debug", onRoomDebug); return () => { manager.removeListener("debug", onRoomDebug); }; }, [manager]); return (
Event Type: {event.type}
{event.callId && (
Call Id:
New Call Id:
To:
Reason: {event.reason}
)} {event.content && ( <>Content:
{JSON.stringify(event.content, undefined, 2)}
>
)}