session

package
v0.0.43 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFoundSession    = errors.New("not found session")
	ErrInvalidSessionKind = errors.New("invalid session kind")
)

Functions

This section is empty.

Types

type Kind

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

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, msgType ...int) (n int64, err error)

Broadcast 推送广播消息(异步)

func (*Session) Close

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

Close 关闭会话

func (*Session) Conn added in v0.0.23

func (s *Session) Conn(kind Kind, target int64) (network.Conn, error)

func (*Session) Has added in v0.0.23

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

Has 是否存在会话

func (*Session) ID added in v0.0.23

func (s *Session) ID(kind Kind, target int64) (id int64, err error)

ID 获取conn的ID

func (*Session) IdsStat added in v0.0.23

func (s *Session) IdsStat(kind Kind) ([]string, error)

IdsStat 获取所有ID

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, msgType ...int) (n int64, err error)

Multicast 推送组播消息(异步)

func (*Session) Push

func (s *Session) Push(kind Kind, target int64, msg []byte, msgType ...int) error

Push 推送消息(异步)

func (*Session) RemConn

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

RemConn 移除连接

func (*Session) RemConnByCid added in v0.0.23

func (s *Session) RemConnByCid(cid int64)

RemConnByCid 移除连接

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, msgType ...int) error

Send 发送消息(同步)

func (*Session) Stat added in v0.0.23

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