即时通讯框架T-IO学习

t-io学习笔记

常见应用场景

  • IM(官方提供了im例子,含web端)
  • 实时监控
  • 推送服务(已内置API)
  • RPC
  • 游戏
  • 物联网(已有很多案例)
  • 其它实时通讯类型的场景,不一一列举

用t-io做的web im

maven坐标

1
2
3
4
5
<dependency>
<groupId>org.t-io</groupId>
<artifactId>tio-core</artifactId>
<version>1.7.2.v20170705-RELEASE</version>
</dependency>

对开发人员极体贴的内置功能

  • 内置心跳检测
  • 内置心跳发送
  • 各种便捷的绑定API
  • 各种便捷的发送API
  • 一行代码拥有自动重连功能
  • 各项消息统计等功能,全部一键内置搞定,省却各种烦恼

各种传送门

了解代码目录结构

所有工程都是maven工程,后续目录有可能稍有变动,不定期更新

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
├─bin----------------脚本目录(方便快速操作)
│ clean.bat----------------清空所有工程的target目录
│ clean.sh
│ deploy.bat----------------作者用来发布到maven中心仓库的脚本,放出来主要是供大家参考
│ deploy.sh
│ dist-examples.bat----------------把所有的例子打包到dist目录,方便用户直接执行
│ dist-examples.sh
│ install.bat----------------安装工程到本地仓库
│ install.sh
| start-http-server.bat----------------启动tio-httpserver
│ start-helloworld-client.bat----------------启动helloworld的客户端
│ start-helloworld-client.sh
│ start-helloworld-server.bat----------------启动helloworld的服务端
│ start-helloworld-server.sh
│ start-im-client.bat----------------启动im的客户端
│ start-im-client.sh
│ start-im-server.bat----------------启动im的服务端
│ start-im-server.sh
│ start-showcase-client.bat----------------启动showcase的客户端
│ start-showcase-client.sh
│ start-showcase-server.bat----------------启动showcase的服务端
│ start-showcase-server.sh
├─docs
│ │
│ ├─blog----------------本人博客草稿(大部分博客是在线编辑,所以此处就没有了)
│ │
│ ├─performance----------------一些性能测试截图(随着版本的增多,有些截图已经过时,但仍保留)
│ │
│ ├─release----------------新版本发布时的log

├─dist----------------成品
│ └─examples----------------用t-io写的例子成品
│ ├─helloworld
│ │ ├─client----------------helloworld的客户端
│ │ └─server----------------helloworld的服务端
│ ├─im
│ │ ├─client----------------im的客户端
│ │ └─server----------------im的服务端
│ └─showcase
│ ├─client----------------showcase的客户端
│ └─server----------------showcase的服务端
└─src
├─core----------------t-io的核心代码
├─zoo----------------t-io的生态圈
│ ├─http----------------用t-io实现的http服务器
│ ├─websocket----------------用t-io实现的websocket服务器
├─example----------------用t-io写的例子的源代码
│ ├─parent----------------例子的maven parent
│ ├─helloworld----------------helloworld的源代码
│ │ ├─client
│ │ ├─common
│ │ └─server
│ ├─im----------------im的源代码
│ │ ├─client
│ │ ├─common
│ │ └─server
│ └─showcase----------------showcase的源代码,这个例子是为了帮助用户学习t-io专门写的
│ ├─client
│ ├─common
│ └─server
└─parent----------------maven工程的parent

学习万能的helloworld例子

花30分钟看一下t-io官方提供的helloworld,了解一下TCP编程的大概流程,文档传送门: t-io的hello world

学习用于进阶的showcase例子

showcase一词是从springside借来的,放这很应景,天蓬元帅就是这样学习的,可以和他交流,他后面会出详细的教程。

InAction

  • 执行测试用例失败: mvn -Dmaven.test.skip=false -Dtest=DemoTest -DfailIfNoTests=false test

HuTool

提供常用的工具,设计哲学:

  • 方法优于对象,使用静态方法,无需创建对象
  • 自动识别优于用户定义
  • 适配器模式: 最大范围的做到兼容
  • 可选依赖: jar都是optional的,使用者需要自己添加依赖

常用工具推荐

  • WatchMonitor:跟踪一个文件,监听其变化
  • 配置文件加载工具:ClassPathResource

列一下推荐的国产开源软件

  1. https://www.oschina.net/p/weixin-java-tools-new (使用一年)
  2. http://layim.layui.com(2017年5月11号开始使用)
  3. https://www.oschina.net/p/ztree (使用五年以上吧)
  4. https://www.oschina.net/p/echarts (使用两年以上吧)
  5. http://git.oschina.net/tywo45/talent-validate (使用十年了,开源出来有五年以上吧,原来是博客开源,现在移到开源中国了)
  6. https://www.oschina.net/p/hutool(懒 人必备,强烈推荐,使用两个月)
  7. https://www.oschina.net/p/t-io(使用五年了,开源出来半年)
  8. https://www.oschina.net/p/druid(使用三年以上吧)
  9. https://www.oschina.net/p/dubbo(使用两年)
  10. https://git.oschina.net/jfinal/jfinal-weixin(使用一年左右)
  11. https://www.oschina.net/p/fastjson(使用三年以上)