session

package
v0.0.0-...-9c04300 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2020 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EmptySession

type EmptySession struct {
	sync.Map
}

func (*EmptySession) Addr

func (ses *EmptySession) Addr() string

func (*EmptySession) Close

func (ses *EmptySession) Close()

func (*EmptySession) ID

func (ses *EmptySession) ID() ID

func (*EmptySession) Send

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

func (*EmptySession) SendRaw

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

type ID

type ID uint64

func Increment

func Increment() ID

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) Count

func (mgr *Manager) Count() int64

当前的session数量

func (*Manager) Insert

func (mgr *Manager) Insert(ses Session)

插入一个session

func (*Manager) Load

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

获取一个session

func (*Manager) Range

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

遍历所有的session

func (*Manager) Remove

func (mgr *Manager) Remove(ses Session)

删除一个session

type Session

type Session interface {
	ID() ID
	Addr() string
	Send(msg interface{}) error
	SendRaw(raw []byte) error
	Close()
	Load(key interface{}) (value interface{}, ok bool)
	Store(key interface{}, value interface{})
}

Jump to

Keyboard shortcuts

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