内容简介:smart-socket是一款国产开源的Java AIO框架,追求代码量、性能、稳定性、接口设计各方面都达到极致。如果smart-socket对您有一丝帮助,请Star一下我们的项目并持续关注;如果您对smart-socket并不满意,那请多一些...
smart-socket是一款国产开源的Java AIO框架,追求代码量、性能、稳定性、接口设计各方面都达到极致。如果smart-socket对您有一丝帮助,请Star一下我们的项目并持续关注;如果您对smart-socket并不满意,那请多一些耐心,smart-socket一直在努力变得更好。
更新内容:
1、优化客户端Session的使用体验
此前我们的客户端服务想获得AioSession对象进行数据输出很不方便,需要依赖NEW_SESSION状态机,并在消息处理器中开放getSessioni以供外部使用。
public class IntegerClient {
public static void main(String[] args) throws Exception {
IntegerClientProcessor processor = new IntegerClientProcessor();
AioQuickClient<Integer> aioQuickClient = new AioQuickClient<Integer>("localhost", 8888, new IntegerProtocol(), processor);
aioQuickClient.start();
processor.getSession().write(1);
Thread.sleep(1000);
aioQuickClient.shutdown();
}
}
public class IntegerClientProcessor implements MessageProcessor<Integer> {
private AioSession<Integer> session;
@Override
public void process(AioSession<Integer> session, Integer msg) {
System.out.println("receive data from server:" + msg);
}
@Override
public void stateEvent(AioSession<Integer> session, StateMachineEnum stateMachineEnum, Throwable throwable) {
switch (stateMachineEnum) {
case NEW_SESSION:
this.session = session;
break;
default:
System.out.println("other state:" + stateMachineEnum);
}
}
public AioSession<Integer> getSession() {
return session;
}
}新版本中调用AioQuickClient.start后便可获取到AioSession对象,使用更方便,代码更简洁。
public class IntegerClient {
public static void main(String[] args) throws Exception {
IntegerClientProcessor processor = new IntegerClientProcessor();
AioQuickClient<Integer> aioQuickClient = new AioQuickClient<Integer>("localhost", 8888, new IntegerProtocol(), processor);
AioSession<Integer> session = aioQuickClient.start();
session.write(1);
Thread.sleep(1000);
aioQuickClient.shutdown();
}
}
public class IntegerClientProcessor implements MessageProcessor<Integer> {
@Override
public void process(AioSession<Integer> session, Integer msg) {
System.out.println("receive data from server:" + msg);
}
@Override
public void stateEvent(AioSession<Integer> session, StateMachineEnum stateMachineEnum, Throwable throwable) {
System.out.println(" state:" + stateMachineEnum);
}
}项目地址:https://gitee.com/smartboot/smart-socket/tree/v1.3.23/
后续smart-socket 1.3.X的版本都在分支上发布,欢迎大家关注。
【声明】文章转载自:开源中国社区 [http://www.oschina.net]
以上所述就是小编给大家介绍的《smart-socket v1.3.23 发布:优化升级通信框架》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- YuebonCore 快速开发框架升级优化
- TPCMF v4.2.4 升级说明,内容管理框架
- WSTMart 商城系统框架升级到 ThinkPHP 5.1.32
- YuebonCore net5.0 开发框架更新升级,元旦快乐
- EB 级系统空中换引擎:阿里调度执行框架如何全面升级?
- smart-socket v1.3.23 发布:优化升级通信框架
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
About Face 3 交互设计精髓
Alan Cooper、Robert Reimann、David Cronin / 刘松涛 / 电子工业出版社 / 2008-11 / 72.00元
本书是一本数字产品和系统的交互设计指南,全面系统地讲述了交互设计过程、原理和方法,涉及的产品和系统有个人电脑上的个人和商务软件、Web应用、手持设备、信息亭、数字医疗系统、数字工业系统等。运用本书的交互设计过程和方法,有助于了解使用者和产品之间的交互行为,进而更好地设计出更具吸引力和更具市场竞争力的产品。 全书分成3篇:第1篇描述了“目标导向设计”,详细讨论了用户和设计的过程及思想;第2篇讲......一起来看看 《About Face 3 交互设计精髓》 这本书的介绍吧!