signaling

package
v0.0.0-...-e92409c Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const LobbyCleanInterval = 30 * time.Minute
View Source
const LobbyCleanThreshold = 24 * time.Hour
View Source
const MaxConnectionTime = 1 * time.Hour

Variables

This section is empty.

Functions

func Handler

Types

type ClosePacket

type ClosePacket struct {
	Type string `json:"type"`

	ID     string `json:"id"`
	Reason string `json:"reason"`
}

type ConnectPacket

type ConnectPacket struct {
	Type string `json:"type"`

	ID     string `json:"id"`
	Polite bool   `json:"polite"`
}

type CreatePacket

type CreatePacket struct {
	RequestID string `json:"rid"`
	Type      string `json:"type"`

	CodeFormat string         `json:"codeFormat"`
	Public     bool           `json:"public"`
	Password   string         `json:"password"`
	MaxPlayers int            `json:"maxPlayers"`
	CustomData map[string]any `json:"customData"`
}

type CredentialsPacket

type CredentialsPacket struct {
	cloudflare.Credentials
	Type      string `json:"type"`
	RequestID string `json:"rid,omitempty"`
}

type DisconnectPacket

type DisconnectPacket struct {
	Type string `json:"type"`

	ID     string `json:"id"`
	Reason string `json:"reason"`
}

type EventPacket

type EventPacket struct {
	metrics.EventParams
	Type string `json:"type"`
}

type ForwardablePacket

type ForwardablePacket struct {
	Type string `json:"type"`

	Source    string `json:"source"`
	Recipient string `json:"recipient"`
}

type HelloPacket

type HelloPacket struct {
	Type string `json:"type"`

	Game   string `json:"game"`
	ID     string `json:"id"`
	Secret string `json:"secret"`
}

type JoinPacket

type JoinPacket struct {
	RequestID string `json:"rid"`
	Type      string `json:"type"`

	Lobby string `json:"lobby"`
}

type JoinedPacket

type JoinedPacket struct {
	RequestID string `json:"rid"`
	Type      string `json:"type"`

	Lobby string `json:"lobby"`
}

type ListPacket

type ListPacket struct {
	RequestID string `json:"rid"`
	Type      string `json:"type"`

	Filter string `json:"filter"`
}

type LobbiesPacket

type LobbiesPacket struct {
	RequestID string `json:"rid"`
	Type      string `json:"type"`

	Lobbies []stores.Lobby `json:"lobbies"`
}

type MissingRecipientError

type MissingRecipientError struct {
	Recipient string `json:"recipient"`
	Cause     error  `json:"cause"`
}

func (*MissingRecipientError) Error

func (e *MissingRecipientError) Error() string

func (*MissingRecipientError) ErrorCode

func (e *MissingRecipientError) ErrorCode() string

func (*MissingRecipientError) MarshalJSON

func (e *MissingRecipientError) MarshalJSON() ([]byte, error)

func (*MissingRecipientError) Unwrap

func (e *MissingRecipientError) Unwrap() error

type Peer

type Peer struct {
	ID     string
	Secret string
	Game   string
	Lobby  string
	// contains filtered or unexported fields
}

func (*Peer) Close

func (p *Peer) Close(ctx context.Context)

func (*Peer) ForwardMessage

func (p *Peer) ForwardMessage(ctx context.Context, raw []byte)

func (*Peer) HandleClosePacket

func (p *Peer) HandleClosePacket(ctx context.Context, packet ClosePacket) error

func (*Peer) HandleCreatePacket

func (p *Peer) HandleCreatePacket(ctx context.Context, packet CreatePacket) error

func (*Peer) HandleHelloPacket

func (p *Peer) HandleHelloPacket(ctx context.Context, packet HelloPacket) error

func (*Peer) HandleJoinPacket

func (p *Peer) HandleJoinPacket(ctx context.Context, packet JoinPacket) error

func (*Peer) HandleListPacket

func (p *Peer) HandleListPacket(ctx context.Context, packet ListPacket) error

func (*Peer) HandlePacket

func (p *Peer) HandlePacket(ctx context.Context, typ string, raw []byte) error

func (*Peer) RequestConnection

func (p *Peer) RequestConnection(ctx context.Context, otherID string) error

func (*Peer) Send

func (p *Peer) Send(ctx context.Context, packet interface{}) error

type PingPacket

type PingPacket struct {
	Type string `json:"type"`
}

type TimeoutManager

type TimeoutManager struct {
	DisconnectThreshold time.Duration

	Store stores.Store
}

func (*TimeoutManager) Disconnected

func (i *TimeoutManager) Disconnected(ctx context.Context, p *Peer)

func (*TimeoutManager) Reconnected

func (i *TimeoutManager) Reconnected(ctx context.Context, id, secret, game string) (bool, []string, error)

func (*TimeoutManager) Run

func (i *TimeoutManager) Run(ctx context.Context)

func (*TimeoutManager) RunOnce

func (i *TimeoutManager) RunOnce(ctx context.Context)

type WelcomePacket

type WelcomePacket struct {
	Type string `json:"type"`

	ID     string `json:"id"`
	Secret string `json:"secret"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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