Documentation ¶
Overview ¶
Package peer implements a mocked Warcraft III client that can be used to manage peer connections in lobbies.
Index ¶
- Variables
- type Chat
- type Connected
- type Deregistered
- type Disconnected
- type Event
- type Host
- func (h *Host) Accept(conn net.Conn) (*Player, error)
- func (h *Host) Close()
- func (h *Host) Deregister(playerID uint8)
- func (h *Host) Dial(playerID uint8) (*Player, error)
- func (h *Host) GameTicks() uint32
- func (h *Host) IncGameTicks(t uint32)
- func (h *Host) ListenAndServe() error
- func (h *Host) Peer(playerID uint8) *Player
- func (h *Host) PeerSet() protocol.BitSet32
- func (h *Host) Register(info *w3gs.PlayerInfo) (*Player, error)
- func (h *Host) Say(s string) []uint8
- func (h *Host) Wait()
- type Player
- type Registered
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidFirstPacket = errors.New("peer: Invalid first packet") ErrUnknownPeerID = errors.New("peer: Unknown ID") ErrDupPeerID = errors.New("peer: Duplicate peer ID") ErrAlreadyConnected = errors.New("peer: Already connected") ErrInvalidEntryKey = errors.New("peer: Wrong entry key") ErrInvalidJoinCounter = errors.New("peer: Wrong join counter") )
Errors
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host struct { network.EventEmitter // Set once before ListenAndServe(), read-only after that Encoding w3gs.Encoding PlayerInfo w3gs.PlayerInfo EntryKey uint32 PingInterval time.Duration // contains filtered or unexported fields }
Host manages (incoming/outgoing) peer connections in a game lobby Public methods/fields are thread-safe unless explicitly stated otherwise
func (*Host) Deregister ¶
Deregister (and disconnect) player
func (*Host) IncGameTicks ¶
IncGameTicks increments the GameTicks state with t
func (*Host) ListenAndServe ¶
ListenAndServe opens a new TCP listener on InternalAddr and serves incoming peer connections On success, listening address overrides InternalAddr/ExternalAddr Not safe for concurrent invocation
func (*Host) Register ¶
func (h *Host) Register(info *w3gs.PlayerInfo) (*Player, error)
Register new player info
type Player ¶
type Player struct { network.EventEmitter network.W3GSConn // Set once before Run(), read-only after that PlayerInfo w3gs.PlayerInfo StartTime time.Time // contains filtered or unexported fields }
Player represents a (real) player in game Public methods/fields are thread-safe unless explicitly stated otherwise
func NewPlayer ¶
func NewPlayer(info *w3gs.PlayerInfo) *Player
NewPlayer initializes a new Player struct
func (*Player) InitDefaultHandlers ¶
func (p *Player) InitDefaultHandlers()
InitDefaultHandlers adds the default callbacks for relevant packets