freeroam

package module
v0.0.0-...-d361f56 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteSubpacket

func WriteSubpacket(buf *bytes.Buffer, typ uint8, data []byte)

WriteSubpacket writes a subpacket with specified type and payload to a bytes.Buffer

Types

type ArrayDiffResult

type ArrayDiffResult struct {
	Kept    []*Client
	Added   []*Client
	Removed []*Client
}

func ArrayDiff

func ArrayDiff(old []*Client, new []*Client) ArrayDiffResult

type CarPosPacket

type CarPosPacket struct {
	// contains filtered or unexported fields
}

func (*CarPosPacket) Packet

func (p *CarPosPacket) Packet() []byte

Packet returns the packet data with the packet time replaced by the argument.

func (*CarPosPacket) Pos

func (p *CarPosPacket) Pos() math.Vector2D

Pos returns the car position as a Vector2D.

func (*CarPosPacket) Rotation

func (p *CarPosPacket) Rotation() float64

Rotation returns the car rotation in degrees.

func (*CarPosPacket) Update

func (p *CarPosPacket) Update(packet []byte)

Update updates CarPosPacket with the specified byte slice. The supplied slice shouldn't be modified after calling this method.

func (*CarPosPacket) Valid

func (p *CarPosPacket) Valid() bool

Valid returns true if CarPosPacket contains valid packet data.

type Client

type Client struct {
	Addr *net.UDPAddr

	LastPacket  time.Time
	PersonaName string
	// contains filtered or unexported fields
}

func (Client) Active

func (c Client) Active() bool

Active returns true if the client has communicated with the server lately.

func (Client) GetPos

func (c Client) GetPos() math.Vector2D

GetPos returns the current position of the client.

func (Client) GetRotation

func (c Client) GetRotation() float64

GetRotation returns the current rotation of the client.

func (Client) IsReady

func (c Client) IsReady() bool

IsReady returns true if the client is ready to be broadcasted to other clients. This means that the server has valid channel info, player info and position data of the client.

func (*Client) SendRawPacket

func (c *Client) SendRawPacket(b []byte) error

SendRawPacket sends a raw UDP packet to the client.

type ClientConfig

type ClientConfig struct {
	InitialTick     uint16
	Addr            *net.UDPAddr
	Conn            *net.UDPConn
	Buffers         *sync.Pool
	Clients         map[string]*Client
	AllowedPersonas []int
}

type Config

type Config struct {
	UDP UDPConfig
	FMS FMSConfig
}

func DefaultConfig

func DefaultConfig() Config

type FMSConfig

type FMSConfig struct {
	ListenAddress  string
	AllowedOrigin  string
	UpdateInterval int
}

type Server

type Server struct {
	sync.Mutex

	Clients map[string]*Client
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) Listen

func (i *Server) Listen(addrStr string) error

func (*Server) RunPacketRead

func (i *Server) RunPacketRead()

func (*Server) RunTimer

func (i *Server) RunTimer()

type UDPConfig

type UDPConfig struct {
	ListenAddress string
}

Directories

Path Synopsis
cmd
This Source Code Form is subject to the terms of the Mozilla Public License, v.
This Source Code Form is subject to the terms of the Mozilla Public License, v.

Jump to

Keyboard shortcuts

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