Comments (2)
自定义 FlowContext
开发者可以自定义 FlowContext 方便做一些方法上的扩展,这些定制可以更好的服务于开发者的项目;业务框架新增 FlowContextFactory 业务框架 flow 上下文工厂,用于创建自定义的 FlowContext。通常使用自定义的 FlowContext,一般用于为 FlowContext 添加上一些方法;
框架默认提供的 FlowContext 已经将 invokeXXX 系列方法给标记为 Deprecated ,因为这是前期的一个 API 错误设计,invokeXXX 系列方法严格来说不算是 FlowContext 的职责;但在实际的业务开发中,开发者自定义的 FlowContext 是可以这么做的;
对于更详细的描述与具体使用,可以参考 https://www.yuque.com/iohao/game/zz8xiz#sLySn 在线文档
from iogame.
使用示例
在业务框架中,添加自定义的 FlowContextFactory 生产工厂
@UtilityClass
public class MyBarSkeletonConfig {
public BarSkeleton createBarSkeleton() {
BarSkeletonBuilderParamConfig config = new BarSkeletonBuilderParamConfig();
BarSkeletonBuilder builder = config.createBuilder()
// 设置一个自定义的 flow 上下文生产工厂
.setFlowContextFactory(MyFlowContext::new);
return builder.build();
}
}
MyFlowContext 是 FlowContext 子类,我们在 MyFlowContext 中添加了一个自定义的方法 (hello)。
public class MyFlowContext extends FlowContext {
public String hello() {
return "MyFlowContext hello";
}
}
在 action 中的使用
自定义的 FlowContext (MyFlowContext)与框架默认提供的 FlowContext 使用方式是一样的
@ActionController(SchoolCmdModule.cmd)
public class SchoolAction {
/**
* 请求、响应
*
* @param logicRequestPb logicRequestPb
* @return LogicRequestPb
*/
@ActionMethod(SchoolCmdModule.here)
public LogicRequestPb here(LogicRequestPb logicRequestPb, MyFlowContext myFlowContext) {
log.info("my flowContext : {}", myFlowContext.getClass());
myFlowContext.hello();
LogicRequestPb newLogicRequestPb = new LogicRequestPb();
newLogicRequestPb.name = "MyFlowContext, I'm here ";
return newLogicRequestPb;
}
}
from iogame.
Related Issues (20)
- 新增实验性特性-脉冲通讯方式 HOT 5
- 网关服k8s部署问题 HOT 8
- 分布式下启动多个逻辑服,运行一段时间自动停止 HOT 8
- 动态匹配逻辑服如何获取所有参与匹配userid HOT 1
- 客户端消息发送,逻辑服消费先后顺序 HOT 7
- qdox 在 win环境下 会很慢。。 HOT 1
- 协议类添加检测
- 新版本游戏对外服 HOT 1
- 支持玩家与多个游戏逻辑服的动态绑定 HOT 2
- 游戏对外服增加路由是否存在检测 HOT 1
- 解决协议碎片的问题 HOT 2
- 网关服集群方式开启问题 HOT 8
- 逻辑服之前相互通讯问题 HOT 3
- 抖音小游戏客户端发送数据处理 HOT 1
- unity使用json传参,有示例吗,我用unity传过去,action都进不去 HOT 2
- 网关停止后对外服log中输出的网关数量不对 HOT 4
- 架构部署多样性-同进程亲和性的部署方式 HOT 2
- ioGame21 功能收集 HOT 14
- 元信息-附加信息 HOT 30
- 接口文档没有生成 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iogame.