Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) AmIAHost() bool
- func (c *Client) AmIAuthorized() bool
- func (c *Client) AmIInALobby() bool
- func (c *Client) AmINew() bool
- func (c *Client) AmIPeer() bool
- func (c *Client) ClearLobby()
- func (c *Client) ClearMode()
- func (c *Client) SetHostMode()
- func (c *Client) SetLobby(lobby string)
- func (c *Client) SetPeerMode()
- func (c *Client) StoreAuthorization(token string)
- type Game
- type GameStore
- type HostConfigPacket
- type InitOK
- type InitPacket
- type Lobby
- type LobbyInfo
- type LobbySettings
- type NewHostParams
- type NewPeerParams
- type PeerConfigPacket
- type PeerConfigParams
- type PeerInfo
- type Relay
- type RelayCandidate
- type RelayCandidatePacket
- type RelayInboundIce
- type RelayInboundIcePacket
- type RelayOutboundIce
- type RelayOutboundIcePacket
- type RelayPacket
- type RootError
- type Server
- type Session
- type SessionStore
- type SignalPacket
Constants ¶
This section is empty.
Variables ¶
View Source
var DATA_CANDIDATE uint8 = 0
As per CL5 spec, there are two kinds of candidates - data and voice.
View Source
var VOICE_CANDIDATE uint8 = 1
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Conn *websocket.Conn Session uint64 Username string ULID ulid.ULID UGI ulid.ULID Mode uint // 0 - none, 1 - host, 2 - peer Authorization any // session token Lobby string // lobby id InLobby bool Mux *sync.RWMutex // To prevent concurrent writes to the websocket connection Metadata map[string]any // arbitrary metadata that the client can specify PublicKey string TransitionDone chan bool }
func (*Client) AmIAuthorized ¶
func (*Client) AmIInALobby ¶
func (*Client) ClearLobby ¶
func (c *Client) ClearLobby()
func (*Client) SetHostMode ¶
func (c *Client) SetHostMode()
func (*Client) SetPeerMode ¶
func (c *Client) SetPeerMode()
func (*Client) StoreAuthorization ¶
type HostConfigPacket ¶
type HostConfigPacket struct { Opcode string `json:"opcode" validate:"required" label:"opcode"` Payload *LobbySettings `json:"payload" validate:"required" label:"payload"` Listener string `json:"listener,omitempty" validate:"omitempty,omitnil" label:"listener"` // For clients to listen to server replies }
type InitOK ¶
type InitOK struct { User string `json:"user"` Id string `json:"id"` SessionID any `json:"session_id"` Game string `json:"game"` Developer string `json:"developer"` }
JSON structure for signaling INIT_OK response.
type InitPacket ¶
type Lobby ¶
type Lobby struct { Mutex sync.RWMutex Host *Client Settings *LobbySettings Clients []*Client }
type LobbySettings ¶
type LobbySettings struct { LobbyID string `json:"lobby_id" label:"lobby_id" validate:"required"` UseServerRelay bool `json:"use_server_relay" validate:"boolean" label:"use_server_relay"` AllowHostReclaim bool `json:"allow_host_reclaim" validate:"boolean" label:"allow_host_reclaim"` AllowPeersToReclaim bool `json:"allow_peers_to_claim_host" validate:"boolean" label:"allow_peers_to_claim_host"` MaximumPeers int `json:"max_peers" validate:"min=0" label:"max_peers"` Password string `json:"password" validate:"omitempty,omitnil,max=128" label:"password"` Locked bool `json:"locked" validate:"boolean" label:"locked"` PublicKey string `json:"pubkey,omitempty" validate:"omitempty,omitnil" label:"pubkey"` ReclaimInProgress bool `json:"reclaim_in_progress,omitempty" validate:"omitempty,omitnil"` // This is an internal flag, not to be used by clients. }
type NewHostParams ¶
type NewHostParams struct { ID string `json:"id"` User string `json:"user"` LobbyID string `json:"lobby_id"` PublicKey string `json:"pubkey,omitempty"` }
Declare the packet format for the NEW_HOST signaling event.
type NewPeerParams ¶
type NewPeerParams struct { ID string `json:"id"` User string `json:"user"` PublicKey string `json:"pubkey,omitempty"` }
Declare the packet format for the NEW_PEER signaling event.
type PeerConfigPacket ¶
type PeerConfigPacket struct { Opcode string `json:"opcode" validate:"required" label:"opcode"` Payload *PeerConfigParams `json:"payload" validate:"required_with=LobbyID" label:"payload"` Listener string `json:"listener,omitempty" validate:"omitempty,omitnil" label:"listener"` // For clients to listen to server replies }
Declare the packet format for the CONFIG_PEER signaling command.
type PeerConfigParams ¶
type RelayCandidate ¶
type RelayCandidate struct { Type uint8 `json:"type" validate:"required" label:"type"` Contents *webrtc.SessionDescription `json:"contents" validate:"required" label:"contents"` }
Declare the packet format for handling relay candidate data.
type RelayCandidatePacket ¶
type RelayCandidatePacket struct { Opcode string `json:"opcode" validate:"required" label:"opcode"` // Required for protocol compliance Payload *RelayCandidate `json:"payload,omitempty" validate:"omitempty,omitnil,required" label:"payload"` // Required for protocol compliance Origin *PeerInfo `json:"origin,omitempty" validate:"omitempty,omitnil" label:"origin"` // Relay -> Peer, identifies client that sent the message Recipient string `json:"recipient,omitempty" validate:"omitempty,omitnil" label:"recipient"` // Peer -> Relay, identifies client that should receive the message }
type RelayInboundIce ¶
type RelayInboundIce struct { Type uint8 `json:"type" validate:"required" label:"type"` Contents *webrtc.ICECandidateInit `json:"contents" validate:"required" label:"contents"` }
Declare the packet format for handling relay inbound ICE data.
type RelayInboundIcePacket ¶
type RelayInboundIcePacket struct { Opcode string `json:"opcode" validate:"required" label:"opcode"` // Required for protocol compliance Payload *RelayInboundIce `json:"payload,omitempty" validate:"omitempty,omitnil,required" label:"payload"` // Required for protocol compliance Origin *PeerInfo `json:"origin,omitempty" validate:"omitempty,omitnil" label:"origin"` // Relay -> Peer, identifies client that sent the message Recipient string `json:"recipient,omitempty" validate:"omitempty,omitnil" label:"recipient"` // Peer -> Relay, identifies client that should receive the message }
type RelayOutboundIce ¶
type RelayOutboundIce struct { Type uint8 `json:"type" validate:"required" label:"type"` Contents *webrtc.ICECandidate `json:"contents" validate:"required" label:"contents"` }
Declare the packet format for handling relay outbound ICE data.
type RelayOutboundIcePacket ¶
type RelayOutboundIcePacket struct { Opcode string `json:"opcode" validate:"required" label:"opcode"` // Required for protocol compliance Payload *RelayOutboundIce `json:"payload,omitempty" validate:"omitempty,omitnil,required" label:"payload"` // Required for protocol compliance Origin *PeerInfo `json:"origin,omitempty" validate:"omitempty,omitnil" label:"origin"` // Relay -> Peer, identifies client that sent the message Recipient string `json:"recipient,omitempty" validate:"omitempty,omitnil" label:"recipient"` // Peer -> Relay, identifies client that should receive the message }
type RelayPacket ¶
type RelayPacket struct { Opcode string `json:"opcode" validate:"required" label:"opcode"` // Required for protocol compliance Payload any `json:"payload,omitempty" validate:"omitempty,omitnil,required" label:"payload"` // Required for protocol compliance Origin *PeerInfo `json:"origin,omitempty" validate:"omitempty,omitnil" label:"origin"` // Relay -> Peer, identifies client that sent the message Recipient string `json:"recipient,omitempty" validate:"omitempty,omitnil" label:"recipient"` // Peer -> Relay, identifies client that should receive the message Channel string `json:"channel,omitempty" validate:"omitempty,omitnil" label:"channel"` // Used to specify what channel the relayed packet belongs to }
Declare the packet format for webrtc relay.
type SignalPacket ¶
type SignalPacket struct { Opcode string `json:"opcode" validate:"required" label:"opcode"` // Required for protocol compliance Payload any `json:"payload,omitempty" validate:"omitempty,omitnil,required" label:"payload"` // Required for protocol compliance Origin *PeerInfo `json:"origin,omitempty" validate:"omitempty,omitnil" label:"origin"` // Server -> Client, identifies client that sent the message Recipient string `json:"recipient,omitempty" validate:"omitempty,omitnil" label:"recipient"` // Client -> Server, identifies client that should receive the message Listener string `json:"listener,omitempty" validate:"omitempty,omitnil" label:"listener"` // For clients to listen to server replies }
Declare the packet format for signaling.
Click to show internal directories.
Click to hide internal directories.