Documentation ¶
Index ¶
- Variables
- func Discard(client IClient) (err error)
- func GetLocalAddrs() (result []*net.IPNet)
- func GetTCPAddr(addr net.Addr) (tcpAddr *net.TCPAddr)
- func GetUDPAddr(addr net.Addr) (udpAddr *net.UDPAddr)
- func NewTCPAddr(host string, port uint16) *net.TCPAddr
- func NewUnixAddr(filename string) (addr *net.UnixAddr)
- func RandomGUID() string
- func Reconnect(client IClient, force bool, retries int) (n int, err error)
- func SendData(client IClient, data []byte) (err error)
- func TrySendData(client IClient, data []byte, retries int) (n int, err error)
- type CloseFunc
- type Conn
- func (c *Conn) Close() error
- func (c *Conn) GetKind() string
- func (c *Conn) GetLocalAddr() net.Addr
- func (c *Conn) GetRawConn() IPckConn
- func (c *Conn) GetReader() *bufio.Reader
- func (c *Conn) GetRemoteAddr() net.Addr
- func (c *Conn) GetSessId() string
- func (c *Conn) Peek(n int) ([]byte, error)
- func (c *Conn) QuickSend(data []byte) error
- type DialPlan
- func (dp *DialPlan) Dial(kind string) (net.Conn, error)
- func (dp *DialPlan) DialTCP() (*net.TCPConn, error)
- func (dp *DialPlan) DialUDP() (*net.UDPConn, error)
- func (dp *DialPlan) DialUnix() (*net.UnixConn, error)
- func (dp *DialPlan) SetPortRemote(host string, port uint16)
- func (dp *DialPlan) SetUnixRemote(filename string)
- type EachFunc
- type Events
- type IClient
- type IPckConn
- type KeepAlive
- type LocalAddrRing
- type MapData
- type Options
- type ProcessFunc
- type Registry
- type SafeMapData
- type Server
- type Session
- type SessionData
- type TCPOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultTCPOptions = TCPOptions{ NoDelay: true, Linger: -1, }
Functions ¶
Types ¶
type Conn ¶
type Conn struct { Session *Session // 下发指令专用,回复请直接调用Write Output chan []byte ReadOnly bool IsActive bool LastError error // contains filtered or unexported fields }
func NewTCPConn ¶
func NewUDPConn ¶
func NewUnixConn ¶
func (*Conn) GetLocalAddr ¶
func (*Conn) GetRawConn ¶
返回原始的网络连接 注意:调用过Peek()操作后,原始连接不能再用于读(会丢失前n个字节)
func (*Conn) GetRemoteAddr ¶
type Events ¶
type Events struct { Tick func(t time.Time) Serving func(s *Server) Opened func(s *Server, c *Conn) error Closed func(s *Server, c *Conn, err error) Process ProcessFunc Prepare func(c *Conn, input chan<- []byte) error Receive func(c *Conn, data []byte, saved bool) string Send func(c *Conn, data []byte) }
事件集
type KeepAlive ¶
type KeepAlive struct {
Idle, Count, Interval int
}
检测TCP连接是否断开 Idle: 没有数据往来(上行、下行都没有)多少秒后,发第一个检测包 Count: 最大检测次数 Interval: 相邻两个检测之间的时间间隔,单位:秒
type LocalAddrRing ¶
type LocalAddrRing struct { LocalAddrs []*net.IPNet TCPAddrs []*net.TCPAddr // contains filtered or unexported fields }
局域网IP的循环列表
func NewLocalAddrRing ¶
func NewLocalAddrRing() *LocalAddrRing
func (*LocalAddrRing) GetTCPAddrs ¶
func (r *LocalAddrRing) GetTCPAddrs() []*net.TCPAddr
func (*LocalAddrRing) NextAddr ¶
func (r *LocalAddrRing) NextAddr() (addr *net.IPNet)
func (*LocalAddrRing) NextTCPAddr ¶
func (r *LocalAddrRing) NextTCPAddr() (addr *net.TCPAddr)
func (*LocalAddrRing) Translate ¶
func (r *LocalAddrRing) Translate(i, stop int)
type MapData ¶
type MapData struct {
// contains filtered or unexported fields
}
会话数据,只使用string作为key
type ProcessFunc ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
网络连接集合
func (*Registry) IsOverride ¶
同一个设备,旧连接将被新连接覆盖(会话ID不一样)
type SafeMapData ¶
跨进程安全会话数据
func (*SafeMapData) Get ¶
func (d *SafeMapData) Get(key string) (interface{}, bool)
func (*SafeMapData) Init ¶
func (d *SafeMapData) Init() error
func (*SafeMapData) Put ¶
func (d *SafeMapData) Put(key string, value interface{})
func (*SafeMapData) Reset ¶
func (d *SafeMapData) Reset() error
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
会话,拥有唯一的sid
func NewSession ¶
type SessionData ¶
Click to show internal directories.
Click to hide internal directories.