nodegateway

package
v0.0.0-...-96491ad Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gateway

type Gateway struct {
	*nodecommon.Node
	// contains filtered or unexported fields
}

Gateway : 网关节点

func NewGateway

func NewGateway(ctx *common.Context) *Gateway

NewGateway : 网关节点实现类的构造函数

func (*Gateway) Close

func (gw *Gateway) Close()

Close : 关闭

func (*Gateway) GetSendToAllClient

func (gw *Gateway) GetSendToAllClient() context.FuncTypeSendToAllClient

GetSendToAllClient : 可自定义客户端交互协议

func (*Gateway) GetSendToClient

func (gw *Gateway) GetSendToClient() context.FuncTypeSendToClient

GetSendToClient : 可自定义客户端交互协议

func (*Gateway) OnRecvFromClient

func (gw *Gateway) OnRecvFromClient(account string, cmd uint32, data []byte, flag uint8) (done bool)

OnRecvFromClient : 可自定义客户端交互协议。data 格式需转化为框架层可理解的格式。done 为 true ,表示框架层接管处理该消息

func (*Gateway) RegisterDecodeFunc

func (gw *Gateway) RegisterDecodeFunc(f context.FuncTypeDecode)

RegisterDecodeFunc : 可自定义加解密算法

func (*Gateway) RegisterEncodeFunc

func (gw *Gateway) RegisterEncodeFunc(f context.FuncTypeEncode)

RegisterEncodeFunc : 可自定义加解密算法

func (*Gateway) RegisterSendToAllClient

func (gw *Gateway) RegisterSendToAllClient(f context.FuncTypeSendToAllClient)

RegisterSendToAllClient : 可自定义客户端交互协议

func (*Gateway) RegisterSendToClient

func (gw *Gateway) RegisterSendToClient(f context.FuncTypeSendToClient)

RegisterSendToClient : 可自定义客户端交互协议

func (*Gateway) Start

func (gw *Gateway) Start() bool

Start : 启动

func (*Gateway) VerifyToken

func (gw *Gateway) VerifyToken(account, token string, clientSession context.IClientSesion) uint32

VerifyToken : 令牌验证。返回值: 0 成功;1 令牌错误; 2 系统错误

type Session

type Session struct {
	*nodecommon.SessionBase
	// contains filtered or unexported fields
}

Session : 网络会话类

func (*Session) DoClose

func (sess *Session) DoClose(sessbase *nodecommon.SessionBase)

DoClose : 节点关闭时处理

func (*Session) DoLose

func (sess *Session) DoLose(msg *protocol.MSG_MGR_LOSE_SERVER)

DoLose : 节点丢失时处理

func (*Session) DoRecv

func (sess *Session) DoRecv(cmd uint64, data []byte, flag byte) (done bool)

DoRecv : 节点收到消息处理

func (*Session) DoRegister

func (sess *Session) DoRegister(msg *protocol.MSG_MGR_REGISTER_SERVER)

DoRegister : 某节点注册时处理

func (*Session) DoVerify

func (sess *Session) DoVerify(msg *protocol.MSG_MGR_REGISTER_SERVER)

DoVerify : 验证时保存自己的注册消息

func (*Session) Init

func (sess *Session) Init(root gocontext.Context, conn net.Conn, derived gotcp.ISession, userdata interface{})

Init : 初始化网络会话节点

type User

type User struct {
	Account         string
	Servers         map[uint32]context.NodeID
	ActiveTimestamp int64
	ClientSession   context.IClientSesion
}

User : 表示 1 个客户端对象

func NewUser

func NewUser(ctx *common.Context, account string, clientSession context.IClientSesion) *User

NewUser : 客户端对象构造函数

type UserMgr

type UserMgr struct {
	ServerRedisCli go_redis_orm.IClient
	// contains filtered or unexported fields
}

UserMgr : 客户端对象管理类

func NewUserMgr

func NewUserMgr(ctx *common.Context, myGateway *Gateway) *UserMgr

NewUserMgr : 客户端对象管理类构造函数

func (*UserMgr) AddUser

func (userMgr *UserMgr) AddUser(account string, servers map[uint32]*protocol.SERVER_ID, clientSession context.IClientSesion) error

AddUser : 加入一个玩家

func (*UserMgr) Close

func (userMgr *UserMgr) Close()

Close : 结束

func (*UserMgr) GetServerAndActive

func (userMgr *UserMgr) GetServerAndActive(account string, nodeType config.NodeType) (*context.NodeID, error)

GetServerAndActive : 获取玩家对应服务器类型的服务器资源信息

func (*UserMgr) Start

func (userMgr *UserMgr) Start()

Start : 开始

Jump to

Keyboard shortcuts

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