network

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BroadcastPeer added in v0.5.0

type BroadcastPeer struct {
	*peer.SafePeer
	// contains filtered or unexported fields
}

func NewBroadcastPeer added in v0.5.0

func NewBroadcastPeer(gs rua.GameServer) *BroadcastPeer

Create a new BroadcastPeer. By default, the broadcast peer will broadcast message in parallel to all other peers except it self. You can use `WithSelector` to select broadcast targets. The BroadcastPeer will never write message to itself to avoid recursive call.

func (*BroadcastPeer) WithSelector added in v0.5.0

func (bp *BroadcastPeer) WithSelector(f func(p rua.Peer) bool) *BroadcastPeer

If the selector returns true, the target peer will be notified.

func (*BroadcastPeer) WithSyncWrite added in v0.5.0

func (bp *BroadcastPeer) WithSyncWrite(sync bool) *BroadcastPeer

type NetPeer

type NetPeer struct {
	*peer.BufferPeer
	// contains filtered or unexported fields
}

func NewNetPeer

func NewNetPeer(conn net.Conn, gs rua.GameServer) *NetPeer

Create a peer with a connection of `net.Conn`. If `timeout` == 0 (in ms), there is no timeout.

func (*NetPeer) WithBufSize

func (np *NetPeer) WithBufSize(n int) *NetPeer

func (*NetPeer) WithReadTimeout

func (np *NetPeer) WithReadTimeout(ms int) *NetPeer

func (*NetPeer) WithTimeout

func (np *NetPeer) WithTimeout(ms int) *NetPeer

Set the readTimeout and writeTimeout to the specified ms.

func (*NetPeer) WithWriteTimeout

func (np *NetPeer) WithWriteTimeout(ms int) *NetPeer

Jump to

Keyboard shortcuts

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