cherrySession

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 13 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 AddOnDataListener added in v1.1.24

func AddOnDataListener(listener ...SessionListener)

func Bind added in v1.1.6

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

func CloseAll added in v1.1.6

func CloseAll(cb func(session *Session))

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 Kick added in v1.1.6

func Kick(uid cfacade.UID) error

func KickBySID added in v1.1.6

func KickBySID(sid cfacade.SID) error

func NextSID added in v1.1.0

func NextSID() cfacade.SID

func Unbind added in v1.1.6

func Unbind(sid cfacade.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 cfacade.SID, frontendId cfacade.FrontendId, network cfacade.INetwork) *Session

func FakeSession added in v1.1.20

func FakeSession(request *cproto.Request, network cfacade.INetwork) *Session

func GetBySID added in v1.1.6

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

func GetByUID added in v1.1.6

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

func NewSession

func NewSession(sid cfacade.SID, frontendId cfacade.FrontendId, network cfacade.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]string

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() cfacade.FrontendId

func (*Session) GetInt added in v1.1.0

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

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) 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) ImportAll added in v1.1.17

func (s *Session) ImportAll(settings map[string]string)

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) LogEnable added in v1.1.29

func (s *Session) LogEnable(level zapcore.Level) bool

func (*Session) OnCloseListener added in v1.1.24

func (s *Session) OnCloseListener()

func (*Session) OnDataListener added in v1.1.24

func (s *Session) OnDataListener() bool

func (*Session) Push added in v1.1.0

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

Push message to client

func (*Session) RPC added in v1.1.0

func (s *Session) RPC(nodeId string, route string, req proto.Message, rsp proto.Message) int32

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(ctx context.Context, v interface{}, isError ...bool)

func (*Session) ResponseMID added in v1.1.17

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

ResponseMID responses message to client, mid is request message ID

func (*Session) Restore added in v1.1.0

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

func (*Session) SID

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

func (*Session) SendRaw added in v1.1.0

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

func (*Session) Set added in v1.1.0

func (s *Session) Set(key string, value string)

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() cfacade.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