cherrySession

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Init = iota
	WaitAck
	Working
	Closed
)

Variables

This section is empty.

Functions

func AddOnCloseListener added in v1.1.6

func AddOnCloseListener(listener ...SessionListener)

func AddOnCreateListener added in v1.1.6

func AddOnCreateListener(listener ...SessionListener)

func Bind added in v1.1.6

func Bind(sid facade.SID, uid facade.UID) error

func CloseAll added in v1.1.6

func CloseAll()

func ForEachSIDSession added in v1.1.6

func ForEachSIDSession(fn func(s *Session))

func ForEachUIDSession added in v1.1.6

func ForEachUIDSession(fn func(s *Session))

func GetSessionCount added in v1.1.6

func GetSessionCount() int

func Import added in v1.1.6

func Import(sid facade.SID, key string, value interface{}) error

func ImportAll added in v1.1.6

func ImportAll(sid facade.SID, settings map[string]interface{}) error

func Kick added in v1.1.6

func Kick(uid facade.UID) error

func KickBySID added in v1.1.6

func KickBySID(sid facade.SID) error

func NextSID added in v1.1.0

func NextSID() facade.SID

func Unbind added in v1.1.6

func Unbind(sid facade.SID)

Types

type Group added in v1.1.0

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

Group represents a session group which used to manage a number of sessions, data send to the group will send to all session in it.

func NewGroup added in v1.1.0

func NewGroup(n string) *Group

NewGroup returns a new group instance

func (*Group) Add added in v1.1.0

func (c *Group) Add(session *Session) error

Add add session to group

func (*Group) Broadcast added in v1.1.0

func (c *Group) Broadcast(route string, v interface{}) error

Broadcast push the message(s) to all members

func (*Group) Close added in v1.1.0

func (c *Group) Close() error

Close destroy group, which will release all resource in the group

func (*Group) Contains added in v1.1.0

func (c *Group) Contains(uid int64) bool

Contains check whether a UID is contained in current group or not

func (*Group) Count added in v1.1.0

func (c *Group) Count() int

Count get current member amount in the group

func (*Group) Leave added in v1.1.0

func (c *Group) Leave(s *Session) error

Leave remove specified UID related session from group

func (*Group) LeaveAll added in v1.1.0

func (c *Group) LeaveAll() error

LeaveAll clear all sessions in the group

func (*Group) Member added in v1.1.0

func (c *Group) Member(uid int64) (*Session, error)

Member returns specified UID's session

func (*Group) Members added in v1.1.0

func (c *Group) Members() []int64

Members returns all member's UID in current group

func (*Group) Multicast added in v1.1.0

func (c *Group) Multicast(route string, v interface{}, filter SessionFilter) error

Multicast push the message to the filtered clients

type Session

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

func Create added in v1.1.6

func Create(sid facade.SID, frontendId facade.FrontendId, network facade.INetwork) *Session

func GetBySID added in v1.1.6

func GetBySID(sid facade.SID) (*Session, bool)

func GetByUID added in v1.1.6

func GetByUID(uid facade.UID) (*Session, bool)

func NewSession

func NewSession(sid facade.SID, frontendId facade.FrontendId, network facade.INetwork) *Session

func (*Session) Clear added in v1.1.0

func (s *Session) Clear()

Clear releases all settings related to current sc

func (*Session) Close added in v1.1.0

func (s *Session) Close()

func (*Session) Contains added in v1.1.0

func (s *Session) Contains(key string) bool

func (*Session) Data added in v1.1.0

func (s *Session) Data() map[string]interface{}

func (*Session) Debug added in v1.1.0

func (s *Session) Debug(args ...interface{})

func (*Session) Debugf added in v1.1.0

func (s *Session) Debugf(template string, args ...interface{})

func (*Session) Error added in v1.1.0

func (s *Session) Error(args ...interface{})

func (*Session) Errorf added in v1.1.0

func (s *Session) Errorf(template string, args ...interface{})

func (*Session) FrontendId

func (s *Session) FrontendId() facade.FrontendId

func (*Session) GetFloat32 added in v1.1.0

func (s *Session) GetFloat32(key string) float32

GetFloat32 returns the value associated with the key as a float32.

func (*Session) GetFloat64 added in v1.1.0

func (s *Session) GetFloat64(key string) float64

GetFloat64 returns the value associated with the key as a float64.

func (*Session) GetInt added in v1.1.0

func (s *Session) GetInt(key string) int

func (*Session) GetInt16 added in v1.1.0

func (s *Session) GetInt16(key string) int16

GetInt16 returns the value associated with the key as a int16.

func (*Session) GetInt32 added in v1.1.0

func (s *Session) GetInt32(key string) int32

GetInt32 returns the value associated with the key as a int32.

func (*Session) GetInt64 added in v1.1.0

func (s *Session) GetInt64(key string) int64

GetInt64 returns the value associated with the key as a int64.

func (*Session) GetInt8 added in v1.1.0

func (s *Session) GetInt8(key string) int8

GetInt8 returns the value associated with the key as a int8.

func (*Session) GetString added in v1.1.0

func (s *Session) GetString(key string) string

GetString returns the value associated with the key as a string.

func (*Session) GetUint added in v1.1.0

func (s *Session) GetUint(key string) uint

GetUint returns the value associated with the key as a uint.

func (*Session) GetUint16 added in v1.1.0

func (s *Session) GetUint16(key string) uint16

GetUint16 returns the value associated with the key as a uint16.

func (*Session) GetUint32 added in v1.1.0

func (s *Session) GetUint32(key string) uint32

GetUint32 returns the value associated with the key as a uint32.

func (*Session) GetUint64 added in v1.1.0

func (s *Session) GetUint64(key string) uint64

GetUint64 returns the value associated with the key as a uint64.

func (*Session) GetUint8 added in v1.1.0

func (s *Session) GetUint8(key string) uint8

GetUint8 returns the value associated with the key as a uint8.

func (*Session) GetValue added in v1.1.0

func (s *Session) GetValue(key string) interface{}

GetValue returns the value associated with the key as a interface{}.

func (*Session) Info added in v1.1.0

func (s *Session) Info(args ...interface{})

func (*Session) Infof added in v1.1.0

func (s *Session) Infof(template string, args ...interface{})

func (*Session) IsBind added in v1.1.0

func (s *Session) IsBind() bool

func (*Session) Kick added in v1.1.0

func (s *Session) Kick(reason interface{}, close bool)

func (*Session) OnCloseProcess added in v1.1.0

func (s *Session) OnCloseProcess()

func (*Session) Push added in v1.1.0

func (s *Session) Push(route string, v interface{}) error

Push message to client

func (*Session) RPC added in v1.1.0

func (s *Session) RPC(route string, v interface{}) error

RPC sends message to remote server

func (*Session) RemoteAddress added in v1.1.0

func (s *Session) RemoteAddress() string

func (*Session) Remove added in v1.1.0

func (s *Session) Remove(key string)

func (*Session) Response added in v1.1.0

func (s *Session) Response(mid uint, v interface{}, isError ...bool) error

Response responses message to client, mid is request message ID

func (*Session) Restore added in v1.1.0

func (s *Session) Restore(data map[string]interface{})

func (*Session) SID

func (s *Session) SID() facade.SID

func (*Session) SendRaw added in v1.1.0

func (s *Session) SendRaw(bytes []byte) error

func (*Session) Set added in v1.1.0

func (s *Session) Set(key string, value interface{})

func (*Session) SetState added in v1.1.5

func (s *Session) SetState(state int32)

func (*Session) State added in v1.1.5

func (s *Session) State() int32

func (*Session) String

func (s *Session) String() string

func (*Session) UID

func (s *Session) UID() facade.UID

func (*Session) Warn added in v1.1.0

func (s *Session) Warn(args ...interface{})

func (*Session) Warnf added in v1.1.0

func (s *Session) Warnf(template string, args ...interface{})

type SessionFilter added in v1.1.0

type SessionFilter func(*Session) bool

SessionFilter represents a filter which was used to filter session when Multicast, the session will receive the message while filter returns true.

type SessionListener added in v1.1.0

type SessionListener func(session *Session) (next bool)

Jump to

Keyboard shortcuts

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