@fishjam-cloud/react-client
Version:
React client library for Fishjam
23 lines (22 loc) • 744 B
JavaScript
import { useCallback, useContext } from "react";
import { FishjamClientContext } from "../contexts/fishjamClient";
/**
* Hook provides a method to update the metadata of the local peer.
* @category Connection
* @group Hooks
* @returns
*/
export const useUpdatePeerMetadata = () => {
const fishjamClientRef = useContext(FishjamClientContext);
if (!fishjamClientRef)
throw Error("useUpdatePeerMetadata must be used within FishjamProvider");
const updatePeerMetadata = useCallback((peerMetadata) => {
fishjamClientRef.current.updatePeerMetadata(peerMetadata);
}, [fishjamClientRef]);
return {
/**
* Updates metadata visible to other peers
*/
updatePeerMetadata,
};
};