4 Star 20 Fork 10

NightTC/Gobige

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Simple_ILoop.go 1.61 KB
一键复制 编辑 原始数据 按行查看 历史
package entity
import (
"gitee.com/night-tc/gobige/logger"
. "gitee.com/night-tc/gobige/msghandler"
)
///////////////////////////////////////////////////////////////
/* 生命周期函数,子类可重载 */
/*
在创建对象的时候调用
eid:实例的唯一ID
etype:实例对象类型
dbid:实例持久化的唯一ID,如果没有持久化可以使用eid一样,也可以为0
realPtr:最外面的实例对象引用
spacePtr:最外面的实例所在空间的引用
fly:是否需要在redis中注册路由信息
*/
func (this *SimpleEntity) OnCreated(etype string, eid, dbid uint64, realPtr IEntity, spacePtr IEntities, fly bool, param ...interface{}) error {
this.EntityBase.OnCreated(etype, eid, dbid, spacePtr, param...)
this.EntityTime.OnCreated(spacePtr.GetNowTime())
this.EntityRun.OnCreated(realPtr)
this.MsgHandler = NewMsgHandler()
// 如果实现了 IMsgOwner 就注册上去
if v, ok := realPtr.(IMsgOwner); ok {
realPtr.RegMsgOwner(v)
}
return nil
}
// 初始化
func (this *SimpleEntity) Init() error {
if this.GetIsFailLoad() {
return nil
}
//初始化完成后进入loop状态
this.SetEntityState(Entity_State_Loop)
return nil
}
// 循环调用
func (this *SimpleEntity) Loop() {
this.DoMsg()
}
// 循环调用中
func (this *SimpleEntity) Looping() {
}
// 循环调用后
func (this *SimpleEntity) Looped() {
}
// 销毁
func (this *SimpleEntity) Destroy() {
//用于关协程
this.SetEntityState(Entity_State_Invalid)
logger.Debugf(logger.LogKey_Entity, "Destroy:%d", this.entityID)
if this.thgo != nil {
this.thgo.Cal()
}
}
// 恢复到Loop状态
func (this *SimpleEntity) ReLoop() {
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/night-tc/gobige.git
git@gitee.com:night-tc/gobige.git
night-tc
gobige
Gobige
b60e4b7f96df

搜索帮助