network

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	Type      EventType
	Peer      enet.Peer
	Data      []byte
	ChannelID uint8
}

type EventType

type EventType int
const (
	EventTypeNone EventType = iota
	EventTypeConnect
	EventTypeDisconnect
	EventTypeReceive
)

type Server

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

func NewServer

func NewServer(port int, maxPeers int, logger *slog.Logger) (*Server, error)

func (*Server) Broadcast

func (s *Server) Broadcast(data []byte, reliable bool) error

func (*Server) DisconnectPeer

func (s *Server) DisconnectPeer(peer enet.Peer, immediate bool)

func (*Server) DisconnectPeerWithReason

func (s *Server) DisconnectPeerWithReason(peer enet.Peer, immediate bool, reason uint32)

func (*Server) GetPeerCount

func (s *Server) GetPeerCount() int

func (*Server) SendPacket

func (s *Server) SendPacket(peer enet.Peer, data []byte, reliable bool) error

func (*Server) Service

func (s *Server) Service(timeout time.Duration) (*Event, error)

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop()

Jump to

Keyboard shortcuts

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