com

package
v0.0.0-...-507577e Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: GPL-3.0 Imports: 3 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 {
	// Messages is a channel that receives messages from the server and forwards the parsed message.
	Messages chan any

	// Commands is a channel that receives commands from the client and sends the encoded command over the ws connection.
	Commands chan Command

	// Errors is a channel that distributes any errors that occur during the connection.
	Errors chan error
	// contains filtered or unexported fields
}

Client represents a connection to the game management server.

func Connect

func Connect(url string, flow Flow) (*Client, error)

Connect establishes a connection to the game management server based on the configuration in the environment.

func (Client) Close

func (c Client) Close() error

Close closes the connection to the server.

func (Client) Ping

func (c Client) Ping() int64

Ping returns the last measured ping to the server. If the ping is not yet measured, 0 is returned.

type Command

type Command interface {
	// Encode encodes the command into a JSON string.
	Encode() string
}

Command is an interface for all commands that can be sent to the backend.

type Flow

type Flow interface {
	// Parse parses a message from the server.
	Parse(key string, data []byte) (any, error)
}

Flow is an interface that is used to parse messages sent by the server. Differnt flows are used for different types of messages.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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