session

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 4 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 added in v0.0.22

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

AddConn 添加连接

func (*Session) Bind

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

Bind 绑定用户ID

func (*Session) Broadcast added in v0.0.22

func (s *Session) Broadcast(kind Kind, msg []byte, msgType ...int) (n int64, err error)

Broadcast 推送广播消息(异步)

func (*Session) Close added in v0.0.3

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

Close 关闭会话

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 added in v0.0.22

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 added in v0.0.22

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

Send 发送消息(同步)

func (*Session) Unbind added in v0.0.4

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