peer

package
v0.0.0-...-bd170c5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Broadcast

func Broadcast(relays []*structs.Relay, channel string, message interface{})

Broadcast sends the given message to all the given DataChannels. If the message is a RelayPacket, it will be marshaled using go-json before being sent. If a channel is nil, it is skipped.

func Code

func Code(r *structs.Relay, code string, channel string, message interface{}, origin *structs.PeerInfo) error

Code sends a RelayPacket over the given DataChannel with the given opcode and optional payload. If the channel is nil, it logs the error and returns nil.

The payload is marshaled using go-json. If the origin is not nil, it is included in the RelayPacket.

func HandleAnswer

func HandleAnswer(r *structs.Relay, answer *webrtc.SessionDescription)

func HandleIce

func HandleIce(r *structs.Relay, ice *webrtc.ICECandidateInit)

func MakeAnswerFromOffer

func MakeAnswerFromOffer(r *structs.Relay, offer *webrtc.SessionDescription) *webrtc.SessionDescription

func MakeOffer

func MakeOffer(r *structs.Relay) *webrtc.SessionDescription

func Send

func Send(r *structs.Relay, channel string, message interface{}) error

Send marshals the given message using go-json and sends it over the given webrtc DataChannel. If the channel is nil, it logs the error and returns nil.

func Spawn

func Spawn(s *structs.Server, ugi string, lobby string, peer *structs.Client) *structs.Relay

Types

type Relay

type Relay struct {
	*structs.Relay
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL