session

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2022 License: Apache-2.0 Imports: 11 Imported by: 3 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSessionNotFound = errors.New("session not found")
)

Functions

func NewSessionPool

func NewSessionPool(config *config.Config) *sessionPoolImpl

Types

type Session

type Session struct {
	OnCloseCallbacks []func(id int64) // close callback
	// contains filtered or unexported fields
}

func (*Session) Close

func (sess *Session) Close()

func (*Session) GetConnInfo

func (sess *Session) GetConnInfo() *acceptor.ConnInfo

func (*Session) GetData

func (sess *Session) GetData() SessionData

func (*Session) GetLastTimeOnline

func (sess *Session) GetLastTimeOnline() int64

func (*Session) GetLatency

func (sess *Session) GetLatency() int64

func (*Session) GetOnCloseCallbacks

func (sess *Session) GetOnCloseCallbacks() []func(id int64)

func (*Session) ID

func (sess *Session) ID() int64

func (*Session) IsLogin

func (sess *Session) IsLogin() bool

func (*Session) OnClose

func (sess *Session) OnClose(c func(id int64)) error

func (*Session) SendData added in v0.1.1

func (sess *Session) SendData(data []byte)

func (*Session) SendMessage

func (sess *Session) SendMessage(in interface{}, name ...string) error

func (*Session) SendPacket added in v0.1.6

func (sess *Session) SendPacket(data *packet.Packet)

func (*Session) SetOnCloseCallback added in v0.1.5

func (sess *Session) SetOnCloseCallback(c func(id int64))

func (*Session) SetOnCloseCallbacks

func (sess *Session) SetOnCloseCallbacks(callbacks []func(id int64))

func (*Session) SetUID

func (sess *Session) SetUID(uid string)

func (*Session) UID

func (sess *Session) UID() string

type SessionData

type SessionData interface {
	GetData() map[string]interface{}
	Set(key string, value interface{})
	Get(key string) (interface{}, bool)
	GetString(key, def string) string
	Delete(key string)
}

type SessionFilter

type SessionFilter struct {
	ConnType  string
	ConnName  string
	ConnGroup string
}

SessionFilter can filter the session from session list one user maybe has many session, so we can filter the session

type SessionMemeory

type SessionMemeory struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSessionMemeory

func NewSessionMemeory() *SessionMemeory

func (*SessionMemeory) Delete

func (sess *SessionMemeory) Delete(key string)

func (*SessionMemeory) Get

func (sess *SessionMemeory) Get(key string) (interface{}, bool)

func (*SessionMemeory) GetData

func (sess *SessionMemeory) GetData() map[string]interface{}

GetData gets the data

func (*SessionMemeory) GetString

func (sess *SessionMemeory) GetString(key, def string) string

func (*SessionMemeory) Set

func (sess *SessionMemeory) Set(key string, value interface{})

Set associates value with the key in session storage

type SessionPool

type SessionPool interface {
	CreateSession(agent networkentity.NetworkEntity) *Session  // create session
	DeleteSession(id int64)                                    // delete session by id
	GetSessionCount() int64                                    // get current session count
	GetSessionTotalCount() int64                               // get total session count
	GetSessionByID(int64) (*Session, error)                    // get session by id
	GetSessionByUID(string, *SessionFilter) ([]int64, []int64) // get session by uid with filter
	ListSessions() []*Session                                  // list all session
	CloseAll()                                                 // close all session
}

Jump to

Keyboard shortcuts

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