session

package
v0.0.0-...-cdb5d28 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NONE          = iota
	EBREAK        // 客户端断开连接
	ELOGIN        // 客户端登录
	EROLEINFO     // 角色列表
	ECREATE       // 创建角色
	ECREATED      // 创建完成
	ECHOOSE       // 选择角色
	ECHOOSED      // 选择角色成功
	EDELETE       // 删除角色
	EDELETED      // 删除成功
	ESTORED       // 存档完成
	EONLINE       // 进入场景
	EFREGION      // 查找场景
	ESWREGION     // 切换场景
	EREMAINTIME   // 更新离线存活时间
	EREGIONREMOVE // 场景已经删除玩家
)
View Source
const (
	SIDLE    = "idle"
	SLOGGED  = "logged"
	SCREATE  = "create"
	SCHOOSE  = "choose"
	SDELETE  = "delete"
	SONLINE  = "online"
	SOFFLINE = "offline"
	SLEAVING = "leaving"
)

Variables

This section is empty.

Functions

func CreateToken

func CreateToken(account string, minutes uint16, starttime uint64) string

token [ 0 ... 7 ] [ 8 ... 9 ] [ 10 ... 13 ] [ 14 ... 21 ]

start time  life time	  random         verify code

func NewProxy

func NewProxy(ctx *SessionModule) *proxy

Types

type Account

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

func NewAccount

func NewAccount(ctx *SessionModule) *Account

func (*Account) ChooseRole

func (a *Account) ChooseRole(session *Session, args c2s.ChooseRole) error

func (*Account) CreateRole

func (a *Account) CreateRole(session *Session, args c2s.CreateRole) error

func (*Account) DeleteRole

func (a *Account) DeleteRole(session *Session, args c2s.DeleteRole) error

func (*Account) EnterRegion

func (p *Account) EnterRegion(s *Session, r rpc.Mailbox) error

func (*Account) FindRegion

func (a *Account) FindRegion(session *Session, id int64, fx, fy, fz float64) error

func (*Account) LeaveRegion

func (p *Account) LeaveRegion(s *Session) error

func (*Account) Logged

func (a *Account) Logged(sender, _ rpc.Mailbox, msg *protocol.Message) (errcode int32, reply *protocol.Message)

login服务调用

func (*Account) OnChooseRole

func (a *Account) OnChooseRole(p interface{}, err *rpc.Error, ar *utils.LoadArchive)

func (*Account) OnCreateRole

func (a *Account) OnCreateRole(p interface{}, e *rpc.Error, ar *utils.LoadArchive)

func (*Account) OnDeleteRole

func (a *Account) OnDeleteRole(p interface{}, e *rpc.Error, ar *utils.LoadArchive)

func (*Account) OnEnterRegion

func (p *Account) OnEnterRegion(param interface{}, replyerr *rpc.Error, ar *utils.LoadArchive)

func (*Account) OnFindRegion

func (a *Account) OnFindRegion(param interface{}, replyerr *rpc.Error, ar *utils.LoadArchive)

func (*Account) OnLeaveRegion

func (p *Account) OnLeaveRegion(param interface{}, replyerr *rpc.Error, ar *utils.LoadArchive)

func (*Account) OnRemovePlayer

func (p *Account) OnRemovePlayer(param interface{}, replyerr *rpc.Error, ar *utils.LoadArchive)

func (*Account) OnRoleInfo

func (a *Account) OnRoleInfo(p interface{}, e *rpc.Error, ar *utils.LoadArchive)

收到玩家信息

func (*Account) OnSaveRole

func (a *Account) OnSaveRole(param interface{}, replyerr *rpc.Error, ar *utils.LoadArchive)

func (*Account) RegisterCallback

func (a *Account) RegisterCallback(s rpc.Servicer)

func (*Account) RemovePlayer

func (p *Account) RemovePlayer(s *Session) error

func (*Account) SaveRole

func (a *Account) SaveRole(session *Session, stype int) error

type ChooseRole

type ChooseRole struct {
	fsm.Default

	Idle int32
	// contains filtered or unexported fields
}

func (*ChooseRole) Init

func (s *ChooseRole) Init(r fsm.StateRegister)

func (*ChooseRole) OnBreak

func (s *ChooseRole) OnBreak(event int, param interface{}) string

func (*ChooseRole) OnChoose

func (s *ChooseRole) OnChoose(event int, param interface{}) string

func (*ChooseRole) OnHandle

func (s *ChooseRole) OnHandle(event int, param interface{}) string

func (*ChooseRole) OnTimer

func (s *ChooseRole) OnTimer() string

type CreateRole

type CreateRole struct {
	fsm.Default

	Idle int32
	// contains filtered or unexported fields
}

func (*CreateRole) Init

func (s *CreateRole) Init(r fsm.StateRegister)

func (*CreateRole) OnBreak

func (s *CreateRole) OnBreak(event int, param interface{}) string

func (*CreateRole) OnCreated

func (s *CreateRole) OnCreated(event int, param interface{}) string

func (*CreateRole) OnHandle

func (s *CreateRole) OnHandle(event int, param interface{}) string

func (*CreateRole) OnTimer

func (s *CreateRole) OnTimer() string

type Deleting

type Deleting struct {
	fsm.Default

	Idle int32
	// contains filtered or unexported fields
}

func (*Deleting) Init

func (s *Deleting) Init(r fsm.StateRegister)

func (*Deleting) OnBreak

func (s *Deleting) OnBreak(event int, param interface{}) string

func (*Deleting) OnDeleting

func (s *Deleting) OnDeleting(event int, param interface{}) string

func (*Deleting) OnHandle

func (s *Deleting) OnHandle(event int, param interface{}) string

func (*Deleting) OnTimer

func (s *Deleting) OnTimer() string

type Idle

type Idle struct {
	fsm.Default

	Idle int32
	// contains filtered or unexported fields
}

func (*Idle) Init

func (s *Idle) Init(r fsm.StateRegister)

func (*Idle) OnBreak

func (s *Idle) OnBreak(event int, param interface{}) string

func (*Idle) OnHandle

func (s *Idle) OnHandle(event int, param interface{}) string

func (*Idle) OnLogin

func (s *Idle) OnLogin(event int, param interface{}) string

func (*Idle) OnTimer

func (s *Idle) OnTimer() string

type LandInfo

type LandInfo interface {
	SetLandScene(landscene int64)
	SetLandPosXYZOrient(x float64, y float64, z float64, orient float64)
	LandScene() int64
	LandPosXYZOrient() (x float64, y float64, z float64, orient float64)
}

type Leaving

type Leaving struct {
	fsm.Default

	Idle int32
	// contains filtered or unexported fields
}

func (*Leaving) Enter

func (s *Leaving) Enter()

func (*Leaving) Init

func (s *Leaving) Init(r fsm.StateRegister)

func (*Leaving) OnHandle

func (s *Leaving) OnHandle(event int, param interface{}) string

func (*Leaving) OnRegionRemove

func (s *Leaving) OnRegionRemove(event int, param interface{}) string

func (*Leaving) OnStored

func (s *Leaving) OnStored(event int, param interface{}) string

func (*Leaving) OnTimer

func (s *Leaving) OnTimer() string

type Logged

type Logged struct {
	fsm.Default

	Idle int32
	// contains filtered or unexported fields
}

func (*Logged) Init

func (s *Logged) Init(r fsm.StateRegister)

func (*Logged) OnBreak

func (s *Logged) OnBreak(event int, param interface{}) string

func (*Logged) OnChoose

func (s *Logged) OnChoose(event int, param interface{}) string

func (*Logged) OnCreate

func (s *Logged) OnCreate(event int, param interface{}) string

func (*Logged) OnDelete

func (s *Logged) OnDelete(event int, param interface{}) string

func (*Logged) OnHandle

func (s *Logged) OnHandle(event int, param interface{}) string

func (*Logged) OnRoleInfo

func (s *Logged) OnRoleInfo(event int, param interface{}) string

func (*Logged) OnTimer

func (s *Logged) OnTimer() string

type Offline

type Offline struct {
	fsm.Default

	Idle int32
	// contains filtered or unexported fields
}

func (*Offline) Enter

func (s *Offline) Enter()

func (*Offline) Init

func (s *Offline) Init(r fsm.StateRegister)

func (*Offline) OnHandle

func (s *Offline) OnHandle(event int, param interface{}) string

func (*Offline) OnRemainTime

func (s *Offline) OnRemainTime(event int, param interface{}) string

func (*Offline) OnTimer

func (s *Offline) OnTimer() string

type Online

type Online struct {
	fsm.Default

	Idle int32
	// contains filtered or unexported fields
}

func (*Online) Enter

func (s *Online) Enter()

func (*Online) Exit

func (s *Online) Exit()

func (*Online) Init

func (s *Online) Init(r fsm.StateRegister)

func (*Online) OnBreak

func (s *Online) OnBreak(event int, param interface{}) string

func (*Online) OnFindRegion

func (s *Online) OnFindRegion(event int, param interface{}) string

func (*Online) OnHandle

func (s *Online) OnHandle(event int, param interface{}) string

func (*Online) OnTimer

func (s *Online) OnTimer() string

func (*Online) Online

func (s *Online) Online(event int, param interface{}) string

type RoleRegion

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

func NewRoleRegion

func NewRoleRegion(m *SessionModule) *RoleRegion

func (*RoleRegion) Prototype

func (s *RoleRegion) Prototype(src rpc.Mailbox, dest rpc.Mailbox, msg *protocol.Message) (int32, *protocol.Message)

func (*RoleRegion) RegisterCallback

func (s *RoleRegion) RegisterCallback(srv rpc.Servicer)

type Session

type Session struct {
	*fsm.FSM

	Account string
	Mailbox *rpc.Mailbox
	// contains filtered or unexported fields
}

session保存当前连接和角色的相关信息

func NewSession

func NewSession(id uint64, ctx *SessionModule) *Session

func (*Session) Break

func (s *Session) Break()

断开客户端的连接

func (*Session) ChooseRole

func (s *Session) ChooseRole(info c2s.ChooseRole) error

ChooseRole 选择角色

func (*Session) CreateRole

func (s *Session) CreateRole(info c2s.CreateRole) error

CreateRole 创建角色

func (*Session) DeleteRole

func (s *Session) DeleteRole(info c2s.DeleteRole) error

DeleteRole 删除角色

func (*Session) DestroySelf

func (s *Session) DestroySelf()

删除自己

func (*Session) EnterRegion

func (s *Session) EnterRegion(r rpc.Mailbox) error

func (*Session) Error

func (s *Session) Error(errcode int32)

func (*Session) FindRegion

func (s *Session) FindRegion() error

func (*Session) GameObject

func (s *Session) GameObject() gameobject.GameObject

func (*Session) LevelRegion

func (s *Session) LevelRegion() error

func (*Session) QueryRoleInfo

func (s *Session) QueryRoleInfo() bool

查询玩家信息

func (*Session) RegionRemove

func (s *Session) RegionRemove() error

func (*Session) SaveRole

func (s *Session) SaveRole(stype int) error

SaveRole 保存角色数据

func (*Session) SendRoleInfo

func (s *Session) SendRoleInfo(role []*inner.Role)

发送角色信息

func (*Session) SetGameObject

func (s *Session) SetGameObject(g gameobject.GameObject)

func (*Session) SetLandInfo

func (s *Session) SetLandInfo(scene int64, x, y, z, o float64)

func (*Session) SyncData

func (s *Session) SyncData(data []byte) error

func (*Session) ValidToken

func (s *Session) ValidToken(token string) bool

验证token

type SessionDB

type SessionDB map[uint64]*Session

type SessionModule

type SessionModule struct {
	service.Module
	// contains filtered or unexported fields
}

登录Session模块 登录信息存储在这里 模块提供功能:

proxy:网关功能,对应的客户端消息在这里进行中转处理
session:登录管理,角色管理
存储客户端对应的entity数据

func New

func New() *SessionModule

func (*SessionModule) FindSession

func (s *SessionModule) FindSession(id uint64) *Session

查找session

func (*SessionModule) Init

func (s *SessionModule) Init() bool

func (*SessionModule) Name

func (s *SessionModule) Name() string

func (*SessionModule) OnConnected

func (s *SessionModule) OnConnected(evt string, args ...interface{})

新客户端连接

func (*SessionModule) OnDisconnected

func (s *SessionModule) OnDisconnected(evt string, args ...interface{})

客户端断线

func (*SessionModule) OnUpdate

func (s *SessionModule) OnUpdate(t *service.Time)

func (*SessionModule) PerSecondCheck

func (s *SessionModule) PerSecondCheck(d time.Duration)

PerSecondCheck 每分钟检查

func (*SessionModule) Shut

func (s *SessionModule) Shut()

Shut 模块关闭

Jump to

Keyboard shortcuts

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