entity

package
v0.0.0-...-e59333c Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//Ntt类型 Player
	Entity_Type_Player = "Player"
)

Variables

View Source
var (
	//eid 已存在
	ErrNtt_EID_Exist = common.NewError(-1, "entity eid:%d exist.")
	// eid 不存在
	ErrNtt_EID_Not_Exist = common.NewError(-1, "entity eid:%d not exist.")
	//对象不在指定服务器上
	ErrNtt_Stype_Not_Exist = common.NewError(-1, "entity eid:%d stype:%d not exist.")
	// 对象已存在
	ErrNtt_Stype_Exist = common.NewError(-1, "entity eid:%d stype:%d exist.")
	//这个对像是Fly
	ErrNtt_Fly = common.NewError(-1, "entity eid:%d is fly.")
	// 对象不是IEntityProp
	ErrNtt_Struct_Not_Props = common.NewError(-1, "Entity type %T not is IEntityProp")
)

Functions

func PackEntityMsgRet

func PackEntityMsgRet(nttmd IBase, msg msgdef.IMsg) (result *protomsg.EntityMsgRet)

打包成发给客户端的消息

func RetMsg

func RetMsg(user IPost, msg msgdef.IMsg, err error)

回复消息 user 回复对象 retmsgid 回复消息号 err 错误信息

func ReturnLLoginNtf

func ReturnLLoginNtf(user IPost, err error)

让客户端返回登录消息

Types

type CallDelayF

type CallDelayF = func()

回调函数

type DelayCallHost

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

用于回调函数的结构

func (*DelayCallHost) CallDelay

func (this *DelayCallHost) CallDelay(f CallDelayF)

func (*DelayCallHost) CallDelayWait

func (this *DelayCallHost) CallDelayWait(f CallDelayF)

加上等待

func (*DelayCallHost) Exec

func (this *DelayCallHost) Exec()

调用函数

type Entities

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

对象管理器

func NewEntities

func NewEntities(isMutilThread bool, real IEntities, thgo *threads.ThreadGo) *Entities

func (*Entities) AddChan

func (this *Entities) AddChan(eid uint64, v ITime)

添加子对象loop信号量

func (*Entities) CreateEntity

func (this *Entities) CreateEntity(etype string, eid, dbid uint64, fly bool, param ...interface{}) (result IEntity, err error)

创建子对象 etype:实例对象类型 eid:实例的唯一ID dbid:实例持久化的唯一ID,如果没有持久化可以使用eid一样 fly:是否为自由对象,不是自由对象时,需要redis里注册路由

func (*Entities) Destroy

func (this *Entities) Destroy()

销毁 会等所有子协程结束

func (*Entities) DestroyEntity

func (this *Entities) DestroyEntity(eid uint64) error

销毁子对象

func (*Entities) DestroyEntityByStype

func (this *Entities) DestroyEntityByStype(eid uint64, stype global.ServerTypeEnum, callbackf global.RouteCallBackF) error

删除指定服务器上的子对象; 删除后,会调用callbackf

func (*Entities) GetEntity

func (this *Entities) GetEntity(eid uint64) IEntity

获取子对象

func (*Entities) GetEntityByDBID

func (this *Entities) GetEntityByDBID(dbid uint64, etype string) IEntity

获取子对象使用DBID

func (*Entities) GetEntityID

func (this *Entities) GetEntityID() uint64

本空间的ID 默认为0,表示自己是service层的管理器,如果是space,对应的space会重载这个接口

func (*Entities) GetThreadGo

func (this *Entities) GetThreadGo() *threads.ThreadGo

操作子协程的管理器

func (*Entities) Init

func (this *Entities) Init() error

初始化

func (*Entities) Loop

func (this *Entities) Loop()

循环调用

func (*Entities) Range

func (this *Entities) Range(f func(k, v interface{}) bool)

遍历所有成员

func (*Entities) RangeByGroup

func (this *Entities) RangeByGroup(gp string, f func(k, v any) bool)

按分组遍历组内所有成员

func (*Entities) RangeByType

func (this *Entities) RangeByType(etype string, f func(k, v any) bool)

按类型遍历组内所有成员

func (*Entities) ReChan

func (this *Entities) ReChan(eid uint64, v ITime)

移除子对象loop信号量

func (*Entities) String

func (this *Entities) String() string

字符串化信息

type EntitiesMsgProc

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

func (*EntitiesMsgProc) MsgPorc_DestroyEntityRetSrv

func (this *EntitiesMsgProc) MsgPorc_DestroyEntityRetSrv(msg *protomsg.DestroyEntityRetSrv)

func (*EntitiesMsgProc) MsgProc_CreateEntityReqSrv

func (this *EntitiesMsgProc) MsgProc_CreateEntityReqSrv(msg *protomsg.CreateEntityReqSrv)

func (*EntitiesMsgProc) MsgProc_CreateEntityRetSrv

func (this *EntitiesMsgProc) MsgProc_CreateEntityRetSrv(msg *protomsg.CreateEntityRetSrv)

func (*EntitiesMsgProc) MsgProc_DestroyEntityReqSrv

func (this *EntitiesMsgProc) MsgProc_DestroyEntityReqSrv(msg *protomsg.DestroyEntityReqSrv)

func (*EntitiesMsgProc) Srv_CreateEntityReqSrv

func (this *EntitiesMsgProc) Srv_CreateEntityReqSrv(req *protomsg.RouteMsgSrvReq, msg *protomsg.CreateEntityReqSrv) error

func (*EntitiesMsgProc) Srv_DestroyEntityReqSrv

func (this *EntitiesMsgProc) Srv_DestroyEntityReqSrv(req *protomsg.RouteMsgSrvReq, msg *protomsg.DestroyEntityReqSrv) error

type Entity

type Entity struct {
	/* 组合 */
	// 基础通信路由有关
	EntitySess
	// ITime实现
	EntityTime
	// 支持独立协程启动
	EntityRun
	//属性同步器(有可能为空)
	*PropsSyncContainer
	// contains filtered or unexported fields
}

支持路由通信、属性同步、时间同步 完整Entity对象

func (*Entity) Destroy

func (this *Entity) Destroy()

销毁

func (*Entity) Init

func (this *Entity) Init() (err error)

初始化

func (*Entity) Loop

func (this *Entity) Loop()

循环调用

func (*Entity) Looped

func (this *Entity) Looped()

循环调用后

func (*Entity) Looping

func (this *Entity) Looping()

循环调用中

func (*Entity) OnCreated

func (this *Entity) OnCreated(etype string, eid, dbid uint64, realPtr IEntity, spacePtr IEntities, fly bool, param ...interface{}) error

在创建对象的时候调用 eid:实例的唯一ID etype:实例对象类型 dbid:实例持久化的唯一ID,如果没有持久化可以使用eid一样,也可以为0 realPtr:最外面的实例对象引用 spacePtr:最外面的实例所在空间的引用 fly:是否为自由对象,不是自由对象时,需要redis里注册路由

func (*Entity) OnPanic

func (this *Entity) OnPanic(err error)

发生Panic的时候,做的处理

func (*Entity) ReLoop

func (e *Entity) ReLoop()

恢复到Loop状态

func (*Entity) SyncDirtyProps

func (this *Entity) SyncDirtyProps()

同步脏属性给别的服务器和客户端

func (*Entity) SyncSrvPropsAll

func (this *Entity) SyncSrvPropsAll(stype global.ServerTypeEnum)

同步本服务器管理属性给对象目标服务器

type EntityBase

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

EntityBase 实体基础结构,实现IEntityBase接口 字段说明:

  • entityType: 实体类型标识
  • entityID: 系统内唯一实体标识
  • dbid: 数据库持久化ID
  • spaceID: 所属空间标识
  • groups: 并发安全的分组集合(使用sync.Map实现)
  • state: 原子操作维护的实体状态
  • spacePtr: 指向所属实体集合的接口引用

func (*EntityBase) AddGroup

func (e *EntityBase) AddGroup(g string)

AddGroup 添加实体到指定分组 参数:

  • g: 分组名称

func (*EntityBase) DelGroup

func (e *EntityBase) DelGroup(g string)

DelGroup 从指定分组移除实体 参数:

  • g: 分组名称

func (*EntityBase) GetDBID

func (e *EntityBase) GetDBID() uint64

GetDBID 获取数据库持久化ID

func (*EntityBase) GetEntities

func (e *EntityBase) GetEntities() IEntities

GetEntities 获取实体所属集合接口 返回:

  • IEntities: 指向包含该实体的集合对象

func (*EntityBase) GetEntityID

func (e *EntityBase) GetEntityID() uint64

GetEntityID 获取系统内唯一实体ID

func (*EntityBase) GetEntityState

func (e *EntityBase) GetEntityState() EntityStateEnum

GetEntityState 获取当前实体状态 返回:

  • EntityStateEnum: 使用原子操作读取的状态值

func (*EntityBase) GetGroup

func (e *EntityBase) GetGroup(g string) bool

GetGroup 检查是否属于指定分组 参数:

  • g: 分组名称

返回:

  • bool: true表示属于该分组

func (*EntityBase) GetGroups

func (e *EntityBase) GetGroups() *sync.Map

GetGroups 获取实体所属全部分组 返回:

  • *sync.Map: 并发安全的分组集合指针(使用Load/Store方法操作)

func (*EntityBase) GetSpaceID

func (e *EntityBase) GetSpaceID() uint64

GetSpaceID 获取实体所属空间ID

func (*EntityBase) GetType

func (e *EntityBase) GetType() string

GetType 获取实体类型标识

func (*EntityBase) OnCreated

func (this *EntityBase) OnCreated(etype string, eid, dbid uint64, spacePtr IEntities, param ...interface{})

func (*EntityBase) SetEntityState

func (e *EntityBase) SetEntityState(st EntityStateEnum)

SetEntityState 设置实体状态 参数:

  • st: 要设置的状态枚举值

func (*EntityBase) String

func (this *EntityBase) String() string

String 生成实体描述字符串 返回格式:[Type:{类型} EntityID:{实体ID} DBID:{存储ID} SpaceID:{空间ID}]

type EntityRun

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

func (*EntityRun) EnterDestroy

func (this *EntityRun) EnterDestroy()

进入对象销毁程序

func (*EntityRun) GetIsFailLoad

func (this *EntityRun) GetIsFailLoad() bool

是否加载失败,如果失败,后面的逻辑就不继续下去了

func (*EntityRun) GoRun

func (this *EntityRun) GoRun(ctx context.Context)

自运行协程的函数

func (*EntityRun) IsDestroyed

func (this *EntityRun) IsDestroyed() bool

是否已销毁

func (*EntityRun) OnCreated

func (this *EntityRun) OnCreated(real IEntity)

func (*EntityRun) SetLoadFail

func (this *EntityRun) SetLoadFail()

是否加载失败,如果失败,后面的逻辑就不继续下去了

type EntitySess

type EntitySess struct {
	EntityBase
	*msghandler.MsgHandler

	//对象身上所有需要垮协程的数量读写的时候,用到的锁
	Mux sync.RWMutex

	// 直连模式, ServerTypeClient类型不经过转发
	IsDirectMode atomic.Bool
	// contains filtered or unexported fields
}

带链接的Entity的组件

func (*EntitySess) CloseClientSess

func (this *EntitySess) CloseClientSess()

关闭连接

func (*EntitySess) CreateEntityByStype

func (this *EntitySess) CreateEntityByStype(stye global.ServerTypeEnum, spid, sid uint64, callbackf global.RouteCallBackF) error

去指定服务器上创建副本

func (*EntitySess) DelayPost

func (this *EntitySess) DelayPost(stye global.ServerTypeEnum, msg msgdef.IMsg)

DelayPost 延迟发送消息, 在帧尾发送

func (*EntitySess) DestroyEntityByStype

func (this *EntitySess) DestroyEntityByStype(stye global.ServerTypeEnum, callbackf global.RouteCallBackF) error

删除目标服务器上的本对象副本

func (*EntitySess) GetClientSess

func (this *EntitySess) GetClientSess() sess.INetSess

获取连接

func (*EntitySess) GetSrvByStype

func (this *EntitySess) GetSrvByStype(styp uint32) (*EntitySrvInfo, error)

获取服务器信息

func (*EntitySess) GetSrvInfoAll

func (e *EntitySess) GetSrvInfoAll() []*EntitySrvInfo

获取服务器路由信息

func (*EntitySess) IsExistSID

func (this *EntitySess) IsExistSID(srvid uint64) bool

本对象有没有连接指点的服务器

func (*EntitySess) OnCreated

func (this *EntitySess) OnCreated(fly bool, real IEntity,
	etype string, eid, dbid uint64, spacePtr IEntities, param ...interface{})

OnCreated 实体创建时调用

func (*EntitySess) Post

func (this *EntitySess) Post(stye global.ServerTypeEnum, msg msgdef.IMsg) error

func (*EntitySess) PostBuf

func (this *EntitySess) PostBuf(data []byte) error

发消息给客户端的二进制消息

func (*EntitySess) RefreshSrvIDS

func (this *EntitySess) RefreshSrvIDS()

刷新对象路由信息

func (*EntitySess) RegEntity

func (this *EntitySess) RegEntity() (err error)

注册本实体到redis中

func (*EntitySess) SetClientSess

func (this *EntitySess) SetClientSess(v sess.INetSess)

设置链接

func (*EntitySess) SetSrvInfo

func (e *EntitySess) SetSrvInfo(v []*EntitySrvInfo)

设置服务器路由信息

func (*EntitySess) UnRegEntity

func (this *EntitySess) UnRegEntity()

注销本实体

type EntitySrvInfo

type EntitySrvInfo struct {
	SrvID   uint64
	SpaceID uint64
	Stype   global.ServerTypeEnum
}

type EntityStateEnum

type EntityStateEnum = uint32
const (
	//初始化
	Entity_State_Init EntityStateEnum = iota
	//Tick状态
	Entity_State_Loop
	//开始Destroy
	Entity_State_Destroy
	//Destroy结束后的状态
	Entity_State_InValid
	//暂停状态
	Entity_State_Suspend
	//恢复状态
	Entity_State_Prepare
)

type EntityTime

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

func (*EntityTime) GetNowTime

func (this *EntityTime) GetNowTime() time.Time

Loop时的时间

func (*EntityTime) GetTicker

func (this *EntityTime) GetTicker() <-chan time.Time

获取TICK器

func (*EntityTime) OnCreated

func (this *EntityTime) OnCreated(now time.Time)

func (*EntityTime) SetNowTime

func (this *EntityTime) SetNowTime(n time.Time)

设置Loop时的时间

func (*EntityTime) SetTickerNow

func (this *EntityTime) SetTickerNow(n time.Time)

设置TICK的时间 只有系统协程可以对子协程做

type Entity_Proc

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

对象消息

func (*Entity_Proc) MsgProc_EntityRegNtf

func (this *Entity_Proc) MsgProc_EntityRegNtf(msg *protomsg.EntityRegNtf)

func (*Entity_Proc) MsgProc_SyncEntityProps

func (this *Entity_Proc) MsgProc_SyncEntityProps(msg *protomsg.SyncEntityProps)

type IBase

type IBase interface {
	//字符串化信息
	String() string

	/*
		GetDBID 获取当前实体关联的数据库唯一标识符
		返回值: 数据库ID(uint64类型)
	*/
	GetDBID() uint64

	/*
		GetEntityID 获取当前实体的唯一标识符
		返回值: 实体ID(uint64类型)
	*/
	GetEntityID() uint64

	/*
		GetType 获取实体类型标识符
		返回值: 实体类型描述字符串
	*/
	GetType() string

	/*
		GetSpaceID 获取实体所属空间的标识符
		返回值: 空间ID(uint64类型)
	*/
	GetSpaceID() uint64

	/*
		AddGroup 将实体添加到指定组
		参数g: 要添加的组名称(string类型)
	*/
	AddGroup(g string)

	/*
		DelGroup 将实体从指定组移除
		参数g: 要移除的组名称(string类型)
	*/
	DelGroup(g string)

	/*
		GetGroups 获取实体所属的所有组集合
		返回值: 线程安全的组集合指针(sync.Map类型),存储格式为[组名:struct{}]
	*/
	GetGroups() *sync.Map

	/*
		GetGroup 检查实体是否属于指定组
		参数g: 要检查的组名称(string类型)
		返回值: 存在返回true,否则false
	*/
	GetGroup(g string) bool

	/*
		GetEntityState 获取当前实体状态
		返回值: 实体状态枚举值(EntityStateEnum类型)
	*/
	GetEntityState() EntityStateEnum

	/*
		SetEntityState 设置实体状态
		参数st: 要设置的状态枚举值(EntityStateEnum类型)
	*/
	SetEntityState(st EntityStateEnum)

	/*
		GetEntities 获取关联的实体集合接口
		返回值: 实体集合接口(IEntities类型),用于批量操作关联实体
	*/
	GetEntities() IEntities
}

IBase 定义实体基础接口,包含实体核心属性和行为管理 方法列表:

  • String: 获取实体字符串化信息
  • 属性访问:DBID/实体ID/类型/空间ID
  • 分组管理:添加/删除/查询分组
  • 状态管理:获取/设置实体状态
  • 空间关系:获取所属实体集合

type IClientSess

type IClientSess interface {
	IBase
	msghandler.IMsgHandler
	//获取连接
	GetClientSess() sess.INetSess
	// 设置链接
	SetClientSess(v sess.INetSess)
	// 关闭连接
	CloseClientSess()
	// 发消息给客户端的二进制消息
	PostBuf(data []byte) error
	//发消息出去
	Post(stye global.ServerTypeEnum, msg msgdef.IMsg) error
	// DelayPost 延迟发送消息, 在帧尾发送
	DelayPost(stye global.ServerTypeEnum, msg msgdef.IMsg)

	//获取服务器信息
	GetSrvByStype(styp uint32) (*EntitySrvInfo, error)
	// 刷新对象路由信息
	RefreshSrvIDS()
	// 本对象有没有连接指点的服务器
	IsExistSID(srvid uint64) bool

	// 删除目标服务器上的本对象副本
	DestroyEntityByStype(stye global.ServerTypeEnum, callbackf global.RouteCallBackF) error
}

带链接的Entity的组件

type IDelayCall

type IDelayCall interface {
	//在帧尾回调这个函数,当前立即返回
	CallDelay(f CallDelayF)
	//在帧尾回调这个函数,当前协程会卡住
	CallDelayWait(f CallDelayF)
	//调用存储的函数
	Exec()
}

支持回调的接口

type IEntities

type IEntities interface {
	//这个需要子类实现
	IMsgHandler
	//这个需要子类实现
	IDelayCall
	//Loop时的时间
	GetNowTime() time.Time

	//初始化
	Init() error
	//循环调用
	Loop()

	//销毁
	Destroy()

	//获取子对象
	GetEntity(eid uint64) IEntity
	// 获取子对象使用DBID
	GetEntityByDBID(dbid uint64, etype string) IEntity
	//创建子对象
	CreateEntity(etype string, eid, dbid uint64, fly bool, param ...interface{}) (result IEntity, err error)
	//销毁子对象
	DestroyEntity(eid uint64) error
	// 删除指定服务器上的子对象; 删除后,会调用callbackf
	DestroyEntityByStype(eid uint64, stype global.ServerTypeEnum, callbackf global.RouteCallBackF) error
	//遍历所有成员
	Range(f func(k, v interface{}) bool)
	//按分组遍历组内所有成员
	RangeByGroup(gp string, f func(k, v any) bool)
	//按类型遍历组内所有成员
	RangeByType(etype string, f func(k, v any) bool)
	// 添加子对象loop信号量
	AddChan(uint64, ITime)
	// 移除子对象loop信号量
	ReChan(uint64, ITime)

	//字符串化信息
	String() string

	//本空间的ID
	GetEntityID() uint64
	//操作子协程的管理器
	GetThreadGo() *threads.ThreadGo
}

type IEntity

type IEntity interface {
	IBase
	ITime
	IMsgHandler
	IRun
	ILoop
}

被管理的Entity对象需要实现的最小接口

1.实现IEntityBase接口
2.实现IMsgHandler接口
3.实现ITime接口
4.需要实现自运行和对象生命周期的方法
5.实现IRun接口

type IEntityReal

type IEntityReal interface {
	IEntity
	IPost
}

后代Entity接口

type ILoop

type ILoop interface {

	/*
		在创建对象的时候调用
		eid:实例的唯一ID
		etype:实例对象类型
		dbid:实例持久化的唯一ID,如果没有持久化可以使用eid一样
		realPtr:最外面的实例对象引用
		spacePtr:最外面的实例所在空间的引用
		fly:是否为自由对象,不是自由对象时,需要redis里注册路由
	*/
	OnCreated(etype string, eid, dbid uint64, realPtr IEntity, spacePtr IEntities, fly bool, param ...interface{}) error

	//初始化
	Init() error

	//循环调用
	Loop()
	//循环调用中间
	Looping()
	//循环调用结尾
	Looped()

	//销毁
	Destroy()
	//恢复到Loop状态
	ReLoop()

	//发生异常的时候
	OnPanic(err error)
	// contains filtered or unexported methods
}

type IPost

type IPost interface {
	props.IProps
	IClientSess

	// 同步脏属性给别的服务器和客户端
	SyncDirtyProps()
	// 同步本服务器管理属性给对象目标服务器
	SyncSrvPropsAll(stype global.ServerTypeEnum)
}

Entity对象通讯有关的接口

type IRun

type IRun interface {

	//进入对象销毁程序(不能重载)
	EnterDestroy()
	//是否已销毁
	IsDestroyed() bool
	//自运行协程的函数(不能重写)
	GoRun(ctx context.Context)

	// 是否加载失败,如果失败,后面的逻辑就不继续下去了
	GetIsFailLoad() bool
	// 是否加载失败,如果失败,后面的逻辑就不继续下去了
	SetLoadFail()
	// contains filtered or unexported methods
}

type ITime

type ITime interface {
	//Loop时的时间
	GetNowTime() time.Time
	//设置Loop时的时间
	SetNowTime(n time.Time)
	//设置TICK的时间 只有系统协程可以对子协程做
	SetTickerNow(n time.Time)
	//获取TICK器
	GetTicker() <-chan time.Time
}

type RedisUtilEntity

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

对象的redis操作集合

func NewRedisUtilEntity

func NewRedisUtilEntity(eid uint64) (result *RedisUtilEntity)

对象的redis操作集合

func (*RedisUtilEntity) Expire

func (this *RedisUtilEntity) Expire()

包活会话

func (*RedisUtilEntity) GetSrvInfoByStype

func (util *RedisUtilEntity) GetSrvInfoByStype(styp global.ServerTypeEnum) (srvid, spid uint64, err error)

获取指定服务类型信息

func (*RedisUtilEntity) GetSrvInfos

func (util *RedisUtilEntity) GetSrvInfos() (result []*EntitySrvInfo, err error)

获取对象在所有服务器上的路由信息

func (*RedisUtilEntity) RegEntity

func (util *RedisUtilEntity) RegEntity(etyp string, dbid uint64) (err error)

注册这个对象信息 一般是有链接的服务器会使用这个

func (*RedisUtilEntity) RegSrvID

func (util *RedisUtilEntity) RegSrvID(stype global.ServerTypeEnum, srvid, spid uint64) error

注册服务器

func (*RedisUtilEntity) UnRegSrvID

func (util *RedisUtilEntity) UnRegSrvID(srvType global.ServerTypeEnum, srvID uint64, spaceID uint64) (result error)

UnRegSrvID 删除注册信息

func (*RedisUtilEntity) UnregEntity

func (util *RedisUtilEntity) UnregEntity() error

注销对象信息 一般是有链接的服务器会使用这个

type SimpleEntity

type SimpleEntity struct {
	/* 组合 */
	// 属性
	EntityBase
	// ITime实现
	EntityTime
	// 支持独立协程启动
	EntityRun
	//消息路由
	*MsgHandler
}

无属性的entity对象

func (*SimpleEntity) Destroy

func (this *SimpleEntity) Destroy()

销毁

func (*SimpleEntity) Init

func (this *SimpleEntity) Init() error

初始化

func (*SimpleEntity) Loop

func (this *SimpleEntity) Loop()

循环调用

func (*SimpleEntity) Looped

func (this *SimpleEntity) Looped()

循环调用后

func (*SimpleEntity) Looping

func (this *SimpleEntity) Looping()

循环调用中

func (*SimpleEntity) OnCreated

func (this *SimpleEntity) OnCreated(etype string, eid, dbid uint64, realPtr IEntity, spacePtr IEntities, fly bool, param ...interface{}) error

在创建对象的时候调用 eid:实例的唯一ID etype:实例对象类型 dbid:实例持久化的唯一ID,如果没有持久化可以使用eid一样,也可以为0 realPtr:最外面的实例对象引用 spacePtr:最外面的实例所在空间的引用 fly:是否需要在redis中注册路由信息

func (*SimpleEntity) ReLoop

func (this *SimpleEntity) ReLoop()

恢复到Loop状态

type TypeMgr

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

func GetTypeMgr

func GetTypeMgr() *TypeMgr

获取对象类型管理器

func (*TypeMgr) GetDefByName

func (mgr *TypeMgr) GetDefByName(name string) *Def

获取对象配置

func (*TypeMgr) LoadDefs

func (mgr *TypeMgr) LoadDefs(dirpath string) (err error)

加载entity的配置表 协程不安全 建议在server初始化的时候,调用

func (*TypeMgr) NewEntity

func (mgr *TypeMgr) NewEntity(name string) (result IEntity)

New对象出来

func (*TypeMgr) RegEntityType

func (mgr *TypeMgr) RegEntityType(name string, v IEntity)

注册对象类型

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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