lan

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2019 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package lan implements a mocked Warcraft III LAN client that can be used to discover local games.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Broadcast

func Broadcast(game *w3gs.GameInfo) (err error)

Broadcast hosted game information to LAN Safe for concurrent invocation

func FindGame

func FindGame(ctx context.Context, gv w3gs.GameVersion) (addr string, hostCounter uint32, entryKey uint32, err error)

FindGame returns the an arbitrary game hosted in LAN

Types

type GameList

type GameList struct {
	network.EventEmitter
	network.W3GSPacketConn

	// Set once before Run(), read-only after that
	GameVersion       w3gs.GameVersion
	BroadcastInterval time.Duration
	// contains filtered or unexported fields
}

GameList keeps track of all the hosted games in the Local Area Network Emits events for every received packet and Update{} when the output of Games() changes Public methods/fields are thread-safe unless explicitly stated otherwise

func NewGameList

func NewGameList(gv w3gs.GameVersion, port int) (*GameList, error)

NewGameList opens a new UDP socket to listen for LAN GameList updates

func (*GameList) Games

func (g *GameList) Games() map[string]w3gs.GameInfo

Games returns the current list of LAN games. Map key is the remote address.

func (*GameList) InitDefaultHandlers

func (g *GameList) InitDefaultHandlers()

InitDefaultHandlers adds the default callbacks for relevant packets

func (*GameList) Run

func (g *GameList) Run() error

Run reads packets from Conn and emits an event for each received packet Not safe for concurrent invocation

type Update

type Update struct{}

Update event

Jump to

Keyboard shortcuts

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