Documentation
¶
Index ¶
- Constants
- Variables
- func KeepAliveTCPConn(conn net.Conn, d time.Duration)
- func ListenAndServeTCP(addrStr string, handler func(net.Conn), async bool, certs ...tls.Certificate) error
- func ListenAndServeUDP(addrStr string, handler func(*net.UDPConn), async bool) error
- func ListenAndServeWebsocket(addrStr, path string, handler func(net.Conn), async bool) error
- type BytesPacket
- type Packet
- type PacketHandler
- type PacketReader
- type RWSession
- type Session
- type TCPKeepAliveListener
- type WSession
Constants ¶
View Source
const ( LengthNeedSize = 4 MaxPacketLength = 4 * 1024 * 1024 // 4M )
Variables ¶
View Source
var NullSession = nullSession{}
Functions ¶
func ListenAndServeTCP ¶
func ListenAndServeUDP ¶
Types ¶
type BytesPacket ¶
type BytesPacket []byte
func (BytesPacket) Bytes ¶
func (p BytesPacket) Bytes() []byte
func (BytesPacket) Len ¶
func (p BytesPacket) Len() int
type PacketHandler ¶
type PacketHandler func(b []byte)
type PacketReader ¶
type PacketReader interface { Conn() net.Conn ReadPacket() (n int, err error) SetTimeout(d time.Duration) }
PacketReader reads a network packet
func NewPacketReader ¶
func NewPacketReader(conn net.Conn, packetHandler PacketHandler) PacketReader
NewPacketReader creates a PacketReader with net.Conn and PacketHandler
type RWSession ¶
type RWSession struct { *WSession // contains filtered or unexported fields }
Readable and Writable Session
func NewRWSession ¶
func NewRWSession( id string, conWriteSize int, packetReader PacketReader, ) *RWSession
type TCPKeepAliveListener ¶
type TCPKeepAliveListener struct { *net.TCPListener // contains filtered or unexported fields }
func NewTCPKeepAliveListener ¶
func NewTCPKeepAliveListener(ln *net.TCPListener, d time.Duration) *TCPKeepAliveListener
Click to show internal directories.
Click to hide internal directories.