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

session

package
v2.2.8 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 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, msg []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, msg []byte) (n int64, err error)

Multicast 推送组播消息(异步)

func (*Session) Push

func (s *Session) Push(kind Kind, target int64, msg []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, msg []byte) error

Send 发送消息(同步)

func (*Session) Stat

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

Stat 统计会话总数

func (*Session) Unbind

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

Unbind 解绑用户ID

Jump to

Keyboard shortcuts

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