structs

package
v0.0.0-...-7a9b2cb Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Conn          *websocket.Conn
	ID            uint64 // For client manager tracking only
	UGI           string
	IsHost        bool   // Set to true when CONFIG_HOST is received or the server makes another peer the host with HOST_RECLAIM, or a peer with CLAIM_HOST
	IsPeer        bool   // Set to true when CONFIG_PEER is received
	Authorization string // ULID session token
	Username      string
	ULID          string
	Expiry        int64 // UNIX time
	ValidSession  bool
	Origin        string // Hostname of the origin of the connection
	GameName      string
	DeveloperName string
	Lobby         string
	Lock          sync.RWMutex
	PublicKey     string // Set when CONFIG_HOST or CONFIG_PEER. ECDH-P256-AES-GCM with SPKI-BASE64 encoding.
}

type HostConfigPacket

type HostConfigPacket struct {
	Opcode  string `json:"opcode" validate:"required" label:"opcode"`
	Payload struct {
		LobbyID             string `json:"lobby_id" label:"lobby_id"`
		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,max=100" label:"max_peers"`
		Password            string `json:"password" validate:"omitempty,max=128" label:"password"`
		PublicKey           string `json:"pubkey,omitempty" validate:"omitempty" label:"pubkey"`
	} `json:"payload" validate:"required_with=LobbyID AllowHostReclaim AllowPeersToReclaim MaximumPeers" label:"payload"`
}

type InitOK

type InitOK struct {
	User      string `json:"user"`
	Id        string `json:"id"`
	Game      string `json:"game"`
	Developer string `json:"developer"`
}

JSON structure for signaling INIT_OK response.

type Load

type Load struct {
	UGI      string `json:"ugi" validate:"required" label:"ugi"`
	Token    string `json:"token" validate:"required" label:"token"`
	SaveSlot int    `json:"save_slot" validate:"required,min=1,max=10" label:"save_slot"`
}

JSON structure for loading a save slot.

type LobbyConfigStore

type LobbyConfigStore struct {
	ID                   string
	MaximumPeers         int
	AllowHostReclaim     bool
	AllowPeersToReclaim  bool
	CurrentOwnerID       uint64 // For client manager tracking only
	CurrentOwnerULID     string // For signaling
	CurrentOwnerUsername string // For lobby manager
	Password             string // Scrypt hash or empty
	IsPublic             bool
	Locked               bool
}

Managing lobbies

type LobbyInfo

type LobbyInfo struct {
	LobbyHostID       string `json:"lobby_host_id"`
	LobbyHostUsername string `json:"lobby_host_username"`
	MaximumPeers      int    `json:"max_peers"`
	CurrentPeers      int    `json:"current_peers"`
}

type Login

type Login struct {
	Email    string `json:"email" validate:"required,email,max=320" label:"email"`
	Password string `json:"password" validate:"required,min=8,max=128" label:"password"`
}

JSON structure for logging in.

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 struct {
		LobbyID   string `json:"lobby_id" validate:"required" label:"lobby_id"`
		Password  string `json:"password" validate:"omitempty,max=128" label:"password"`
		PublicKey string `json:"pubkey,omitempty" validate:"omitempty" label:"pubkey"`
	} `json:"payload" validate:"required_with=LobbyID" label:"payload"`
}

Declare the packet format for the CONFIG_PEER signaling command.

type PeerInfo

type PeerInfo struct {
	ID   string `json:"id"`
	User string `json:"user"`
}

type Register

type Register struct {
	Username string `json:"username" validate:"required,min=3,max=20" label:"username"`
	Password string `json:"password" validate:"required,min=8,max=128" label:"password"`
	Email    string `json:"email" validate:"required,email,max=320" label:"email"`
}

JSON structure for user creation.

type RootError

type RootError struct {
	Errors []map[string]string `json:"Validation error"`
}

type Save

type Save struct {
	UGI      string `json:"ugi" validate:"required" label:"ugi"`
	Token    string `json:"token" validate:"required" label:"token"`
	SaveSlot int    `json:"save_slot" validate:"required,min=1,max=10" label:"save_slot"`
	SaveData any    `json:"save_data" validate:"required,max=10000" label:"save_data"`
}

JSON structure for creating/updating a save slot.

type Session

type Session struct {
	UGI     string // ULID
	UserID  string // ULID
	State   int    // Bitfield, spec TBD
	Created int64  // Timestamp as UNIX time
	Expiry  int64  // Timestamp as UNIX time
	Origin  string // Tinytext
}

type SignalPacket

type SignalPacket struct {
	Opcode    string    `json:"opcode" validate:"required" label:"opcode"`                       // Required for protocol compliance
	Payload   any       `json:"payload,omitempty" validate:"required" label:"payload"`           // Required for protocol compliance
	Origin    *PeerInfo `json:"origin,omitempty" validate:"omitempty,ulid" label:"origin"`       // Server -> Client, identifies client that sent the message
	Recipient string    `json:"recipient,omitempty" validate:"omitempty,ulid" label:"recipient"` // Client -> Server, identifies client that should receive the message
	Listener  string    `json:"listener,omitempty" validate:"omitempty" label:"listener"`        // For clients to listen to server replies
}

Declare the packet format for signaling.

type UserQuery

type UserQuery struct {
	ID       string
	Username string
	Gamertag string
	Email    string
	Created  string
	Password string
	State    int
}

Jump to

Keyboard shortcuts

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