session

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseSession

type BaseSession struct {
	*core.TcpHandle
}

func GetBaseSession

func GetBaseSession(h *core.TcpHandle) *BaseSession

func (*BaseSession) GetSid

func (b *BaseSession) GetSid() uint64

func (*BaseSession) HandleRoute

func (b *BaseSession) HandleRoute(r *router.Router, m *deal.Msg) error

func (*BaseSession) Notice

func (b *BaseSession) Notice(route string, input interface{}) error

func (*BaseSession) Push

func (b *BaseSession) Push(route string, input interface{}) error

func (*BaseSession) PushTo

func (b *BaseSession) PushTo(sid uint64, route string, input interface{}) error

func (*BaseSession) Response

func (b *BaseSession) Response(route string, input interface{}) error

func (*BaseSession) Rpc

func (b *BaseSession) Rpc(route string, input, output interface{}) error

func (*BaseSession) RpcResponse

func (b *BaseSession) RpcResponse(route string, input interface{}) error

func (*BaseSession) SendTo

func (b *BaseSession) SendTo(addr string, msg *deal.Msg) error

func (*BaseSession) SetSid

func (b *BaseSession) SetSid(sid uint64)

type MasterSession

type MasterSession struct {
	*BaseSession
}

func GetMasterSession

func GetMasterSession(h *core.TcpHandle) *MasterSession

func (*MasterSession) HandleRoute

func (s *MasterSession) HandleRoute(r *router.Router, m *deal.Msg) error

type Member

type Member struct {
	sync.RWMutex
	// session集合
	Sessions map[uint64]*MemberSession
	// 当前SID
	SID uint64
}

用于管理member的session

func GetMember

func GetMember() *Member

func (*Member) SessionClose

func (m *Member) SessionClose(s *MemberSession)

session close

func (*Member) SessionCount

func (m *Member) SessionCount() int

获取当前连接总数

func (*Member) SessionFindByID

func (m *Member) SessionFindByID(sid uint64) *MemberSession

session find

func (*Member) SesssionInit

func (m *Member) SesssionInit(s *MemberSession) error

session init

type MemberSession

type MemberSession struct {
	*BaseSession
}

member session

func GetMemberSession

func GetMemberSession(h *core.TcpHandle) *MemberSession

func (*MemberSession) HandleRoute

func (s *MemberSession) HandleRoute(r *router.Router, m *deal.Msg) error

func (*MemberSession) Notice

func (s *MemberSession) Notice(route string, input interface{}) error

notice 请求

func (*MemberSession) RpcRequest

func (s *MemberSession) RpcRequest(ss *BaseSession, msg *deal.Msg) error

rpc 请求

type ServerSession

type ServerSession struct {
	*BaseSession
}

func GetServerSession

func GetServerSession(h *core.TcpHandle) *ServerSession

func (*ServerSession) HandleRoute

func (s *ServerSession) HandleRoute(r *router.Router, m *deal.Msg) error

func (*ServerSession) Notice

func (s *ServerSession) Notice(route string, input interface{}) error

func (*ServerSession) Push

func (s *ServerSession) Push(route string, input interface{}) error

func (*ServerSession) PushTo

func (s *ServerSession) PushTo(sid uint64, route string, input interface{}) error

func (*ServerSession) Response

func (s *ServerSession) Response(route string, input interface{}) error

func (*ServerSession) Rpc

func (s *ServerSession) Rpc(route string, input, output interface{}) error

func (*ServerSession) RpcResponse

func (s *ServerSession) RpcResponse(route string, input interface{}) error

type Session

type Session interface {
	// 获取客户端地址
	GetAddr() string

	// 获取mid
	GetMid() uint64

	// cache
	Set(k string, v interface{})
	Get(k string) interface{}
	Del(k string)
	GetInt(k string) int
	GetUInt(k string) uint
	GetInt32(k string) int32
	GetUInt32(k string) uint32
	GetInt64(k string) int64
	GetUInt64(k string) uint64
	GetFloat(k string) float64
	GetBool(k string) bool
	GetString(k string) string

	// session id
	SetSid(sid uint64)
	GetSid() uint64

	// 远程调用
	Rpc(route string, input, output interface{}) error
	Notice(route string, input interface{}) error
	Response(route string, input interface{}) error
	RpcResponse(route string, input interface{}) error
	Push(route string, input interface{}) error
	PushTo(sid uint64, route string, input interface{}) error
	SendTo(addr string, msg *deal.Msg) error
	HandleRoute(r *router.Router, m *deal.Msg) error
}

Jump to

Keyboard shortcuts

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