Documentation
¶
Index ¶
- type Kind
- type Session
- func (s *Session) AddConn(conn network.Conn)
- func (s *Session) Bind(cid, uid int64) error
- func (s *Session) Broadcast(kind Kind, disconnect bool, buf buffer.Buffer) (int64, error)
- func (s *Session) Close(kind Kind, target int64, force ...bool) error
- func (s *Session) Has(kind Kind, target int64) (ok bool, err error)
- func (s *Session) LocalAddr(kind Kind, target int64) (net.Addr, error)
- func (s *Session) LocalIP(kind Kind, target int64) (string, error)
- func (s *Session) Multicast(kind Kind, targets []int64, disconnect bool, buf buffer.Buffer) (int64, error)
- func (s *Session) Publish(channel string, disconnect bool, buf buffer.Buffer) (int64, error)
- func (s *Session) Push(kind Kind, target int64, disconnect bool, buf buffer.Buffer) error
- func (s *Session) RemConn(conn network.Conn) bool
- func (s *Session) RemoteAddr(kind Kind, target int64) (net.Addr, error)
- func (s *Session) RemoteIP(kind Kind, target int64) (string, error)
- func (s *Session) Stat(kind Kind) (int64, error)
- func (s *Session) Subscribe(kind Kind, targets []int64, channel string) (err error)
- func (s *Session) Unbind(uid int64) (int64, error)
- func (s *Session) Unsubscribe(kind Kind, targets []int64, channel string) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func (*Session) Bind ¶
Bind 绑定用户ID @param cid int64 连接ID @param uid int64 用户ID @return @1 error 错误信息
func (*Session) Broadcast ¶
Broadcast 推送广播消息(异步) @param kind Kind 会话类型 @param disconnect bool 推送后是否断开连接 @param buf buffer.Buffer 消息内容 @return @1 int64 成功推送的数量 @return @2 error 错误信息
func (*Session) Close ¶
Close 关闭会话 @param kind Kind 会话类型 @param target int64 会话目标(连接ID或用户ID) @param force ...bool 是否强制关闭 @return @1 error 错误信息
func (*Session) Has ¶
Has 判断会话是否存在 @param kind Kind 会话类型 @param target int64 会话目标(连接ID或用户ID) @return @1 bool 是否存在 @return @2 error 错误信息
func (*Session) LocalAddr ¶
LocalAddr 获取本地地址 @param kind Kind 会话类型 @param target int64 会话目标(连接ID或用户ID) @return @1 net.Addr 本地地址 @return @2 error 错误信息
func (*Session) LocalIP ¶
LocalIP 获取本地IP @param kind Kind 会话类型 @param target int64 会话目标(连接ID或用户ID) @return @1 string 本地IP地址 @return @2 error 错误信息
func (*Session) Multicast ¶
func (s *Session) Multicast(kind Kind, targets []int64, disconnect bool, buf buffer.Buffer) (int64, error)
Multicast 推送组播消息(异步) @param kind Kind 会话类型 @param targets []int64 会话目标列表(连接ID或用户ID) @param disconnect bool 推送后是否断开连接 @param buf buffer.Buffer 消息内容 @return @1 int64 成功推送的数量 @return @2 error 错误信息
func (*Session) Publish ¶ added in v2.3.0
Publish 发布频道消息(异步) @param channel string 频道名称 @param disconnect bool 推送后是否断开连接 @param buf buffer.Buffer 消息内容 @return @1 int64 成功推送的数量 @return @2 error 错误信息
func (*Session) Push ¶
Push 推送消息(异步) @param kind Kind 会话类型 @param target int64 会话目标(连接ID或用户ID) @param disconnect bool 推送后是否断开连接 @param buf buffer.Buffer 消息内容 @return @1 error 错误信息
func (*Session) RemConn ¶
RemConn 移除连接 在同一把写锁内完成存在性检查与移除,调用方无需先Has再RemConn两次查找; 并发重复移除时仅首个调用返回true,可防止重复移除导致的计数失衡 @param conn network.Conn 连接对象 @return @1 bool 连接是否已登记并被移除
func (*Session) RemoteAddr ¶
RemoteAddr 获取远端地址 @param kind Kind 会话类型 @param target int64 会话目标(连接ID或用户ID) @return @1 net.Addr 远端地址 @return @2 error 错误信息
func (*Session) RemoteIP ¶
RemoteIP 获取远端IP @param kind Kind 会话类型 @param target int64 会话目标(连接ID或用户ID) @return @1 string 远端IP地址 @return @2 error 错误信息
func (*Session) Stat ¶
Stat 统计会话总数 @param kind Kind 会话类型 @return @1 int64 会话数量 @return @2 error 错误信息
func (*Session) Subscribe ¶ added in v2.3.0
Subscribe 订阅频道 @param kind Kind 会话类型 @param targets []int64 会话目标列表(连接ID或用户ID) @param channel string 频道名称 @return @1 error 错误信息