Help us shape the future of Go! Take the 2026 Go Developer Survey

session

package
v2.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Kind

type Kind int
const (
	Conn Kind = iota + 1 // 连接SESSION
	User                 // 用户SESSION
)

func (Kind) String

func (k Kind) String() string

type Session

type Session struct {
	// contains filtered or unexported fields
}

func NewSession

func NewSession() *Session

func (*Session) AddConn

func (s *Session) AddConn(conn network.Conn)

AddConn 添加连接

func (*Session) Bind

func (s *Session) Bind(cid, uid int64) error

Bind 绑定用户ID

func (*Session) Broadcast

func (s *Session) Broadcast(kind Kind, message []byte) (n int64, err error)

Broadcast 推送广播消息(异步)

func (*Session) Close

func (s *Session) Close(kind Kind, target int64, force ...bool) error

Close 关闭会话

func (*Session) Has

func (s *Session) Has(kind Kind, target int64) (ok bool, err error)

Has 是否存在会话

func (*Session) LocalAddr

func (s *Session) LocalAddr(kind Kind, target int64) (net.Addr, error)

LocalAddr 获取本地地址

func (*Session) LocalIP

func (s *Session) LocalIP(kind Kind, target int64) (string, error)

LocalIP 获取本地IP

func (*Session) Multicast

func (s *Session) Multicast(kind Kind, targets []int64, message []byte) (n int64, err error)

Multicast 推送组播消息(异步)

func (*Session) Publish added in v2.3.1

func (s *Session) Publish(channel string, message []byte) (n int64)

Publish 发布频道消息(异步)

func (*Session) Push

func (s *Session) Push(kind Kind, target int64, message []byte) error

Push 推送消息(异步)

func (*Session) RemConn

func (s *Session) RemConn(conn network.Conn)

RemConn 移除连接

func (*Session) RemoteAddr

func (s *Session) RemoteAddr(kind Kind, target int64) (net.Addr, error)

RemoteAddr 获取远端地址

func (*Session) RemoteIP

func (s *Session) RemoteIP(kind Kind, target int64) (string, error)

RemoteIP 获取远端IP

func (*Session) Send

func (s *Session) Send(kind Kind, target int64, message []byte) error

Send 发送消息(同步)

func (*Session) Stat

func (s *Session) Stat(kind Kind) (int64, error)

Stat 统计会话总数

func (*Session) Subscribe added in v2.3.1

func (s *Session) Subscribe(kind Kind, targets []int64, channel string) (err error)

Subscribe 订阅频道

func (*Session) Unbind

func (s *Session) Unbind(uid int64) (int64, error)

Unbind 解绑用户ID

func (*Session) Unsubscribe added in v2.3.1

func (s *Session) Unsubscribe(kind Kind, targets []int64, channel string) (err error)

Unsubscribe 取消订阅频道

Jump to

Keyboard shortcuts

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