session

package
v0.0.0-...-273cdd3 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2020 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewID

func NewID() uint64

Types

type Conn

type Conn interface {
	Addr() string
	Deadline(time.Time) error
	Read() ([]byte, error)
	Write([]byte) error
	Close() error
	Data() *sync.Map
}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) Count

func (mgr *Manager) Count() int64

func (*Manager) Insert

func (mgr *Manager) Insert(session *Session)

func (*Manager) Load

func (mgr *Manager) Load(id uint64) *Session

func (*Manager) Range

func (mgr *Manager) Range(handler func(*Session) bool)

func (*Manager) Remove

func (mgr *Manager) Remove(session *Session)

type Option

type Option struct {
	Queue   int
	Cipher  cipher.Maker
	Encoder encoder.Maker
	Invoker event.Invoker
	Timeout time.Duration
}

会话配置信息

func (*Option) Parse

func (opt *Option) Parse()

type Session

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

func New

func New(conn Conn, option *Option, logger log.Logger) *Session

func (*Session) Addr

func (ses *Session) Addr() string

func (*Session) Close

func (ses *Session) Close() error

func (*Session) Data

func (ses *Session) Data() *sync.Map

func (*Session) ID

func (ses *Session) ID() uint64

func (*Session) Invoke

func (ses *Session) Invoke(event *event.Event)

事件派发

func (*Session) Run

func (ses *Session) Run(callback func(*Session))

启动会话

func (*Session) Send

func (ses *Session) Send(msg interface{}) error

func (*Session) SendRaw

func (ses *Session) SendRaw(raw []byte) error

Jump to

Keyboard shortcuts

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