代码拉取完成,页面将自动刷新
package cherry
import (
cfacade "github.com/cherry-game/cherry/facade"
ccluster "github.com/cherry-game/cherry/net/cluster"
cdiscovery "github.com/cherry-game/cherry/net/discovery"
)
type (
AppBuilder struct {
*Application
components []cfacade.IComponent
}
)
func Configure(profileFilePath, nodeId string, isFrontend bool, mode NodeMode) *AppBuilder {
appBuilder := &AppBuilder{
Application: NewApp(profileFilePath, nodeId, isFrontend, mode),
components: make([]cfacade.IComponent, 0),
}
return appBuilder
}
func ConfigureNode(node cfacade.INode, isFrontend bool, mode NodeMode) *AppBuilder {
appBuilder := &AppBuilder{
Application: NewAppNode(node, isFrontend, mode),
components: make([]cfacade.IComponent, 0),
}
return appBuilder
}
func (p *AppBuilder) Startup() {
app := p.Application
if app.NodeMode() == Cluster {
cluster := ccluster.New()
app.SetCluster(cluster)
app.Register(cluster)
discovery := cdiscovery.New()
app.SetDiscovery(discovery)
app.Register(discovery)
}
// Register custom components
app.Register(p.components...)
// startup
app.Startup()
}
func (p *AppBuilder) Register(component ...cfacade.IComponent) {
p.components = append(p.components, component...)
}
func (p *AppBuilder) AddActors(actors ...cfacade.IActorHandler) {
p.actorSystem.Add(actors...)
}
func (p *AppBuilder) NetParser() cfacade.INetParser {
return p.netParser
}
func (p *AppBuilder) SetNetParser(parser cfacade.INetParser) {
p.netParser = parser
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。