Documentation
¶
Index ¶
- func KeepAliveTCPConn(conn net.Conn, d time.Duration)
- func ListenAndServeTCP(addrStr string, handler func(net.Conn), async bool) error
- func ListenAndServeUDP(addrStr string, handler func(*net.UDPConn), async bool) error
- func ListenAndServeWebsocket(addrStr, path string, handler func(net.Conn), async bool) error
- func ListenSignal(handler func(sig os.Signal) (ret bool), signals ...os.Signal)
- func NewTCPKeepAliveListener(ln *net.TCPListener, d time.Duration) net.Listener
- type CrypterFunc
- type DecryptFunc
- type PacketHander
- type RWSession
- type ReadStream
- func (r *ReadStream) Conn() net.Conn
- func (r *ReadStream) Read() (int, error)
- func (r *ReadStream) SetByteNumForLength(n int)
- func (r *ReadStream) SetDecodeLengthFunc(decodeLengthFunc func([]byte) int)
- func (r *ReadStream) SetDecrypter(decrypter DecryptFunc)
- func (r *ReadStream) SetTimeout(d time.Duration)
- type Session
- type StreamReader
- type UDPConn
- func (conn *UDPConn) Close() error
- func (conn *UDPConn) LocalAddr() net.Addr
- func (conn *UDPConn) Read(b []byte) (int, error)
- func (conn *UDPConn) RemoteAddr() net.Addr
- func (conn *UDPConn) SetDeadline(t time.Time) error
- func (conn *UDPConn) SetReadDeadline(t time.Time) error
- func (conn *UDPConn) SetWriteDeadline(t time.Time) error
- func (conn *UDPConn) Write(b []byte) (int, error)
- type UDPReadStream
- type WSession
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServeTCP ¶
func ListenAndServeUDP ¶
func ListenAndServeWebsocket ¶
func NewTCPKeepAliveListener ¶
Types ¶
type CrypterFunc ¶
type CrypterFunc func(dst, src []byte)
type DecryptFunc ¶
type DecryptFunc func(dst, src []byte)
type PacketHander ¶
type PacketHander func(packet []byte)
type RWSession ¶
type RWSession struct { *WSession // contains filtered or unexported fields }
可读可写的Session
func NewRWSession ¶
func (*RWSession) SetDecrypter ¶
func (s *RWSession) SetDecrypter(decrypter CrypterFunc)
type ReadStream ¶
type ReadStream struct {
// contains filtered or unexported fields
}
func NewReadStream ¶
func NewReadStream(conn net.Conn, onRecvPacket PacketHander) *ReadStream
通用的流读取
func (*ReadStream) Conn ¶
func (r *ReadStream) Conn() net.Conn
func (*ReadStream) Read ¶
func (r *ReadStream) Read() (int, error)
func (*ReadStream) SetByteNumForLength ¶
func (r *ReadStream) SetByteNumForLength(n int)
func (*ReadStream) SetDecodeLengthFunc ¶
func (r *ReadStream) SetDecodeLengthFunc(decodeLengthFunc func([]byte) int)
func (*ReadStream) SetDecrypter ¶
func (r *ReadStream) SetDecrypter(decrypter DecryptFunc)
func (*ReadStream) SetTimeout ¶
func (r *ReadStream) SetTimeout(d time.Duration)
type Session ¶
type Session interface { Id() string Send(*buffer.Buffer) Run(onNewSession, onQuitSession func()) Quit() SetEncrypter(encrypter CrypterFunc) SetDecrypter(decrypter CrypterFunc) }
type StreamReader ¶
type StreamReader interface { Conn() net.Conn Read() (n int, err error) SetDecrypter(decrypter DecryptFunc) SetTimeout(d time.Duration) }
序列化后的数据流的读取
type UDPConn ¶
type UDPConn struct {
// contains filtered or unexported fields
}
用于只写的UDP连接,实现 net.Conn 接口
func (*UDPConn) RemoteAddr ¶
type UDPReadStream ¶
type UDPReadStream struct {
// contains filtered or unexported fields
}
UDP 包读取
func NewUDPReadStream ¶
func NewUDPReadStream(conn *net.UDPConn, onRecvPacket PacketHander) *UDPReadStream
func (*UDPReadStream) Conn ¶
func (r *UDPReadStream) Conn() net.Conn
func (*UDPReadStream) Read ¶
func (r *UDPReadStream) Read(CrypterFunc) (int, error)
func (*UDPReadStream) SetDecrypter ¶
func (r *UDPReadStream) SetDecrypter(CrypterFunc)
func (*UDPReadStream) SetTimeout ¶
func (r *UDPReadStream) SetTimeout(d time.Duration)
type WSession ¶
type WSession struct {
// contains filtered or unexported fields
}
只写的Session
func (*WSession) SetEncrypter ¶
func (ws *WSession) SetEncrypter(encrypter CrypterFunc)
Click to show internal directories.
Click to hide internal directories.