Documentation
¶
Overview ¶
mocks_enet.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventType ¶
type EventType int
EventType describes the type of a networking event.
Possible values: - EventPacketReceived: A packet was received from a peer. - EventConnected: A peer connected. - EventDisconnected: A peer disconnected.
type NetEvent ¶
type NetEvent struct { Type EventType PeerID uint32 Opcode uint16 // Only valid for EventPacketReceived Payload []byte // Only valid for EventPacketReceived }
NetEvent is the internal event representation used by PulseNet. It is delivered to the NetEventHandler you register.
type NetEventHandler ¶
type NetEventHandler interface {
HandleEvent(NetEvent)
}
NetEventHandler is implemented by any object that wants to receive networking events. This is the only integration point for receiving packets or connection events.
type NetworkLoop ¶
type NetworkLoop interface { Tick() int SendTo(peerID uint32, channelID uint8, flags PacketFlag, data []byte) Broadcast(channelID uint8, flags PacketFlag, data []byte) RegisterEventHandler(handler NetEventHandler) Destroy() }
NetworkLoop defines the high-level interface for PulseNet's networking system. It provides methods to send messages, receive events, and manage the lifecycle of the networking loop.
Users should call Tick() periodically (e.g. every frame or tick) to process events and flush messages. Always call Destroy() before shutdown to clean up internal resources.
func NewNetworkLoop ¶
func NewNetworkLoop(addr string, port uint16, maxPeers uint64) (NetworkLoop, error)
NewNetworkLoop initializes ENet, creates a host, and returns a running network loop.
addr: Address to bind to (e.g. "0.0.0.0"). port: Port to bind to. maxPeers: Maximum number of simultaneous connections.
The returned loop must have Destroy() called on it to clean up the host and ENet state.
Returns an error if the host cannot be created.
type PacketFlag ¶
type PacketFlag uint32
PacketFlag wraps ENet's packet flags and allows the user to specify reliability, sequencing, and other behavior when sending messages.
const ( FlagReliable PacketFlag = PacketFlag(enet.PacketFlagReliable) FlagUnsequenced PacketFlag = PacketFlag(enet.PacketFlagUnsequenced) FlagNoAllocate PacketFlag = PacketFlag(enet.PacketFlagNoAllocate) FlagUnreliableFragment PacketFlag = PacketFlag(enet.PacketFlagUnreliableFragment) FlagSent PacketFlag = PacketFlag(enet.PacketFlagSent) )
Source Files
¶
- enet_abstractions.go
- enet_mocks.go
- enet_wrappers.go
- eventloop.go
- events.go
- handlers.go
- netloop.go
- packets.go
- send.go
- tick.go