Documentation ¶
Overview ¶
Package network implements common utilities for higher-level (emulated) Warcraft III network components.
Index ¶
- Constants
- Variables
- func IsConnClosedError(err error) bool
- func IsConnRefusedError(err error) bool
- func IsSysCallError(err error, errno syscall.Errno) bool
- func IsUseClosedNetworkError(err error) bool
- func UnnestError(err error) error
- type AsyncError
- type BNCSConn
- func (c *BNCSConn) Close() error
- func (c *BNCSConn) Conn() net.Conn
- func (c *BNCSConn) NextClientPacket(timeout time.Duration) (bncs.Packet, error)
- func (c *BNCSConn) NextServerPacket(timeout time.Duration) (bncs.Packet, error)
- func (c *BNCSConn) RunClient(f Emitter, timeout time.Duration) error
- func (c *BNCSConn) RunServer(f Emitter, timeout time.Duration) error
- func (c *BNCSConn) Send(pkt bncs.Packet) (int, error)
- func (c *BNCSConn) SendRL(pkt bncs.Packet) (int, error)
- func (c *BNCSConn) SetConn(conn net.Conn)
- type CAPIConn
- func (c *CAPIConn) Close() error
- func (c *CAPIConn) Conn() *websocket.Conn
- func (c *CAPIConn) NextPacket(timeout time.Duration) (*capi.Packet, error)
- func (c *CAPIConn) Run(f Emitter, timeout time.Duration) error
- func (c *CAPIConn) Send(pkt *capi.Packet) error
- func (c *CAPIConn) SetConn(conn *websocket.Conn)
- type Emitter
- type Event
- type EventArg
- type EventEmitter
- type EventHandler
- type EventID
- type Listener
- type RWMutex
- type RunStart
- type RunStop
- type W3GSConn
- func (c *W3GSConn) Close() error
- func (c *W3GSConn) Conn() net.Conn
- func (c *W3GSConn) NextPacket(timeout time.Duration) (w3gs.Packet, error)
- func (c *W3GSConn) Run(f Emitter, timeout time.Duration) error
- func (c *W3GSConn) Send(pkt w3gs.Packet) (int, error)
- func (c *W3GSConn) SetConn(conn net.Conn)
- type W3GSPacketConn
- func (c *W3GSPacketConn) Broadcast(pkt w3gs.Packet) (int, error)
- func (c *W3GSPacketConn) Close() error
- func (c *W3GSPacketConn) Conn() net.PacketConn
- func (c *W3GSPacketConn) NextPacket(timeout time.Duration) (w3gs.Packet, net.Addr, error)
- func (c *W3GSPacketConn) Run(f Emitter, timeout time.Duration) error
- func (c *W3GSPacketConn) Send(addr net.Addr, pkt w3gs.Packet) (int, error)
- func (c *W3GSPacketConn) SetConn(conn net.PacketConn)
Constants ¶
const WSAECONNREFUSED = 10061
WSAECONNREFUSED is ECONNREFUSED on Windows
const WSAECONNRESET = 10054
WSAECONNRESET is ECONNRESET on Windows
Variables ¶
var W3GSBroadcastAddr = net.UDPAddr{IP: net.IPv4bcast, Port: 6112}
W3GSBroadcastAddr is used to broadcast W3GS packets to LAN
Functions ¶
func IsConnClosedError ¶
IsConnClosedError checks if net.error is a "connection closed" error
func IsConnRefusedError ¶ added in v1.2.0
IsConnRefusedError checks if net.error is a "connection refused" error
func IsSysCallError ¶
IsSysCallError checks if net.error is syscall.Errno
func IsUseClosedNetworkError ¶
IsUseClosedNetworkError checks if net.error is poll.ErrNetClosed
Types ¶
type AsyncError ¶
AsyncError keeps track of where a non-fatal asynchronous error orignated
func (*AsyncError) Error ¶
func (e *AsyncError) Error() string
type BNCSConn ¶ added in v1.2.0
type BNCSConn struct {
// contains filtered or unexported fields
}
BNCSConn manages a TCP connection that transfers BNCS packets from/to client. Public methods/fields are thread-safe unless explicitly stated otherwise
func NewBNCSConn ¶ added in v1.2.0
NewBNCSConn returns conn wrapped in BNCSConn
func (*BNCSConn) NextClientPacket ¶ added in v1.2.0
NextClientPacket waits for the next client packet (with given timeout) and returns its deserialized representation Not safe for concurrent invocation
func (*BNCSConn) NextServerPacket ¶ added in v1.2.0
NextServerPacket waits for the next server packet (with given timeout) and returns its deserialized representation Not safe for concurrent invocation
func (*BNCSConn) RunClient ¶ added in v1.2.0
RunClient reads server packets (with given max time between packets) from Conn and emits an event for each received packet Not safe for concurrent invocation
func (*BNCSConn) RunServer ¶ added in v1.2.0
RunServer reads client packets (with given max time between packets) from Conn and emits an event for each received packet Not safe for concurrent invocation
type CAPIConn ¶ added in v1.2.0
type CAPIConn struct {
// contains filtered or unexported fields
}
CAPIConn manages a websocket connection that processes CAPI requests. Public methods/fields are thread-safe unless explicitly stated otherwise
func NewCAPIConn ¶ added in v1.2.0
NewCAPIConn returns conn wrapped in CAPIConn
func (*CAPIConn) NextPacket ¶ added in v1.2.0
NextPacket waits for the next packet (with given timeout) and returns its deserialized representation Not safe for concurrent invocation
func (*CAPIConn) Run ¶ added in v1.2.0
Run reads packets (with given max time between packets) from Conn and fires an event through f for each received packet Not safe for concurrent invocation
type Event ¶
Event structure passed to event handlers
func (*Event) PreventNext ¶
func (e *Event) PreventNext()
PreventNext prevents any other handlers from being called for this event
type EventArg ¶
type EventArg interface{}
EventArg identifies an event (and with it the type of its Arg)
type EventEmitter ¶
type EventEmitter struct {
// contains filtered or unexported fields
}
EventEmitter is an event emitter based on argument types For every type, a listener can register callbacks. Callbacks will be fired in reverse order of registration. The structure is thread-safe and functions can be called from multiple goroutines at the same time.
func (*EventEmitter) Fire ¶
func (e *EventEmitter) Fire(a EventArg, o ...EventArg) bool
Fire new event of type a
func (*EventEmitter) Off ¶
func (e *EventEmitter) Off(id EventID)
Off stops id from listening to future events
func (*EventEmitter) OffAll ¶
func (e *EventEmitter) OffAll(a EventArg)
OffAll clears the current listeners for events of type a
func (*EventEmitter) On ¶
func (e *EventEmitter) On(a EventArg, h EventHandler) EventID
On an event of type a is, call handler h
func (*EventEmitter) Once ¶
func (e *EventEmitter) Once(a EventArg, h EventHandler) EventID
Once an event of type a is fired, call handler h once
type EventID ¶
type EventID struct {
// contains filtered or unexported fields
}
EventID identifies a single event handler
type Listener ¶ added in v1.2.0
type Listener interface { On(a EventArg, h EventHandler) EventID Once(a EventArg, h EventHandler) EventID Off(id EventID) OffAll(a EventArg) }
Listener is the interface that wraps the basic On/Once methods
type W3GSConn ¶
type W3GSConn struct {
// contains filtered or unexported fields
}
W3GSConn manages a TCP connection that transfers W3GS packets. Public methods/fields are thread-safe unless explicitly stated otherwise
func NewW3GSConn ¶
NewW3GSConn returns conn wrapped in W3GSConn
func (*W3GSConn) NextPacket ¶
NextPacket waits for the next packet (with given timeout) and returns its deserialized representation Not safe for concurrent invocation
func (*W3GSConn) Run ¶
Run reads packets (with given max time between packets) from Conn and fires an event through f for each received packet Not safe for concurrent invocation
type W3GSPacketConn ¶
type W3GSPacketConn struct {
// contains filtered or unexported fields
}
W3GSPacketConn manages a UDP connection that transfers W3GS packets. Public methods/fields are thread-safe unless explicitly stated otherwise
func NewW3GSPacketConn ¶
func NewW3GSPacketConn(conn net.PacketConn) *W3GSPacketConn
NewW3GSPacketConn returns conn wrapped in W3GSPacketConn
func (*W3GSPacketConn) Broadcast ¶
func (c *W3GSPacketConn) Broadcast(pkt w3gs.Packet) (int, error)
Broadcast a packet over LAN
func (*W3GSPacketConn) Conn ¶
func (c *W3GSPacketConn) Conn() net.PacketConn
Conn returns the underlying net.PacketConn
func (*W3GSPacketConn) NextPacket ¶
NextPacket waits for the next packet (with given timeout) and returns its deserialized representation Not safe for concurrent invocation
func (*W3GSPacketConn) Run ¶
func (c *W3GSPacketConn) Run(f Emitter, timeout time.Duration) error
Run reads packets (with given max time between packets) from Conn and emits an event for each received packet Not safe for concurrent invocation
func (*W3GSPacketConn) SetConn ¶
func (c *W3GSPacketConn) SetConn(conn net.PacketConn)
SetConn closes the old connection and starts using the new net.PacketConn
Directories ¶
Path | Synopsis |
---|---|
Package bnet implements a mocked BNCS client that can be used to interact with BNCS servers.
|
Package bnet implements a mocked BNCS client that can be used to interact with BNCS servers. |
Package chat implements the official classic Battle.net chat API.
|
Package chat implements the official classic Battle.net chat API. |
Package dummy implements a mocked Warcraft III game client that can be used to add dummy players to lobbies.
|
Package dummy implements a mocked Warcraft III game client that can be used to add dummy players to lobbies. |
Package lan implements a mocked Warcraft III LAN client that can be used to discover local games.
|
Package lan implements a mocked Warcraft III LAN client that can be used to discover local games. |
Package peer implements a mocked Warcraft III client that can be used to manage peer connections in lobbies.
|
Package peer implements a mocked Warcraft III client that can be used to manage peer connections in lobbies. |