Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | 'use client'
import { createContext, useContext } from 'react'
/**
* Context for co-play mode (observer joining a game as a participant).
*
* When present, game Providers that support drop-in co-play should
* auto-send a JOIN_GAME move for the observer when the session loads.
*/
export interface CoPlayInfo {
/** Observer's player ID (their user ID) */
playerId: string
/** Observer's display name */
playerName: string
/** Observer's emoji */
emoji: string
/** Observer's color */
color: string
}
const CoPlayContext = createContext<CoPlayInfo | null>(null)
export function CoPlayProvider({
info,
children,
}: {
info: CoPlayInfo
children: React.ReactNode
}) {
return <CoPlayContext.Provider value={info}>{children}</CoPlayContext.Provider>
}
/**
* Returns co-play info if the current viewer is a co-play participant.
* Returns null if in normal play or spectator mode.
*/
export function useCoPlayInfo(): CoPlayInfo | null {
return useContext(CoPlayContext)
}
|