Fetch the repository succeeded.
package main
import (
"time"
"github.com/xiaonanln/goTimer"
"github.com/xiaonanln/goworld"
"github.com/xiaonanln/goworld/engine/gwlog"
"github.com/xiaonanln/goworld/ext/pubsub"
)
var (
_SERVICE_NAMES = []string{
"OnlineService",
"SpaceService",
"MailService",
pubsub.ServiceName,
}
)
func init() {
}
func main() {
goworld.RegisterSpace(&MySpace{}) // Register the space type
// Register each entity types
goworld.RegisterEntity("Account", &Account{})
goworld.RegisterService("OnlineService", &OnlineService{})
goworld.RegisterService("SpaceService", &SpaceService{})
goworld.RegisterService("MailService", &MailService{})
pubsub.RegisterService()
// Register Monster type and define attributes
goworld.RegisterEntity("Monster", &Monster{})
// Register Avatar type and define attributes
goworld.RegisterEntity("Avatar", &Avatar{})
// Run the game server
goworld.Run()
}
func checkServerStarted() {
ok := isAllServicesReady()
gwlog.Infof("checkServerStarted: %v", ok)
if ok {
onAllServicesReady()
} else {
timer.AddCallback(time.Millisecond*1000, checkServerStarted)
}
}
func isAllServicesReady() bool {
for _, serviceName := range _SERVICE_NAMES {
if goworld.GetServiceEntityID(serviceName).IsNil() {
gwlog.Infof("%s is not ready ...", serviceName)
return false
}
}
return true
}
func onAllServicesReady() {
gwlog.Infof("ALL SERVICES ARE READY!!!")
goworld.CallNilSpaces("TestCallNilSpaces", 1, "abc", true, 2.3)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。