Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from crossoverJie:master #8

Open
wants to merge 142 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
95d306e
refactor-metastore stage1
crossoverJie Dec 26, 2018
a108170
Merge pull request #140 from crossoverJie/refator-metastore
crossoverJie Aug 29, 2024
8d9478d
Create maven.yml
crossoverJie Aug 30, 2024
5b57671
fix-unit-test
crossoverJie Aug 30, 2024
089a666
remove update dependency graph
crossoverJie Aug 30, 2024
c7d16b6
support jacoco
crossoverJie Aug 30, 2024
8155fd7
Merge pull request #142 from crossoverJie/fix-unit-test
crossoverJie Aug 30, 2024
3a3f91c
:arrow_up: Bump org.apache.zookeeper:zookeeper from 3.8.1 to 3.8.4
dependabot[bot] Aug 30, 2024
bb9532e
fix client unit test
crossoverJie Aug 30, 2024
3f1ccf0
fix client unit test
crossoverJie Aug 30, 2024
cc83c74
Merge pull request #143 from crossoverJie/fix-client-unit-test
crossoverJie Aug 30, 2024
9fd8519
support integration test
crossoverJie Aug 31, 2024
dac5cc0
support integration test
crossoverJie Sep 1, 2024
e8060a2
:recycle: Refactoring code.
crossoverJie Sep 1, 2024
d488835
remove code
crossoverJie Sep 1, 2024
16ebfd7
remove code
crossoverJie Sep 1, 2024
85ee0fb
remove plugin
crossoverJie Sep 1, 2024
a13b664
readme
crossoverJie Sep 1, 2024
5896837
Merge pull request #144 from crossoverJie/support-integration-test
crossoverJie Sep 1, 2024
8bee51e
Merge pull request #141 from crossoverJie/dependabot/maven/org.apache…
crossoverJie Sep 1, 2024
ebd6190
route & server support test
crossoverJie Sep 6, 2024
ab5f7a8
Merge pull request #145 from crossoverJie/route-test
crossoverJie Sep 6, 2024
fa23bbf
client-sdk stage1
crossoverJie Sep 7, 2024
d5d4719
refactor-proxy-manager
crossoverJie Sep 7, 2024
43130a9
refactor-proxy-manager
crossoverJie Sep 7, 2024
7c499ae
remove test
crossoverJie Sep 7, 2024
a166bc5
add Rpc proxy test
crossoverJie Sep 8, 2024
2d6f901
add Rpc proxy test
crossoverJie Sep 8, 2024
88bdea9
comment unless code
crossoverJie Sep 8, 2024
2dffa42
comment unless code
crossoverJie Sep 8, 2024
e951ade
comment unless code
crossoverJie Sep 8, 2024
7db4b55
Merge pull request #146 from crossoverJie/refactor-proxy-manager
crossoverJie Sep 8, 2024
0a36c73
Merge branch 'master' into feature/client-sdk
crossoverJie Sep 11, 2024
bc373f9
Modify the consistent hash
baiyina Sep 12, 2024
990d4c5
refactor client sdk
crossoverJie Sep 12, 2024
81ac022
fix sdk test
crossoverJie Sep 12, 2024
153cb9e
fix reconnect
crossoverJie Sep 12, 2024
847d118
remove some unless code
crossoverJie Sep 12, 2024
4056f00
Group chat test
crossoverJie Sep 12, 2024
758cfeb
Modify the consistent hash
baiyina Sep 12, 2024
8703c9c
Merge pull request #147 from baiyina/Modify-the-consistent-hash
crossoverJie Sep 12, 2024
fc53794
Merge branch 'master' into feature/client-sdk
crossoverJie Sep 12, 2024
b0b9809
client sdk support reconnect
crossoverJie Sep 13, 2024
1470095
release resource
crossoverJie Sep 13, 2024
c331038
comment
crossoverJie Sep 13, 2024
761fc19
support online user
crossoverJie Sep 14, 2024
4d24929
support p2p user
crossoverJie Sep 14, 2024
c98d904
remove unless code
crossoverJie Sep 14, 2024
05ffa2d
use cim-client-sdk implement client
crossoverJie Sep 14, 2024
0d39aae
use cim-client-sdk implement client
crossoverJie Sep 14, 2024
025d616
Add close state
crossoverJie Sep 14, 2024
4c149f8
Add close state
crossoverJie Sep 14, 2024
3c4f917
Merge pull request #148 from crossoverJie/feature/client-sdk
crossoverJie Sep 16, 2024
d3c81d9
feature:support offline atomic command by lua
cmgyqjj Sep 18, 2024
d39475e
Support dynamic url
crossoverJie Sep 19, 2024
24f1717
Parse code
crossoverJie Sep 19, 2024
0f0d718
add test
crossoverJie Sep 19, 2024
581fbeb
Merge pull request #151 from crossoverJie/proxy-dynamic
crossoverJie Sep 19, 2024
4408544
feature:support offline atomic command by lua
cmgyqjj Sep 19, 2024
e75bfa2
feature:support offline atomic command by lua
cmgyqjj Sep 19, 2024
2a0fdc1
Merge pull request #149 from cmgyqjj/feature_OffLine_Atomic_Command_S…
crossoverJie Sep 19, 2024
ad389a1
Bump com.google.protobuf:protobuf-java from 3.16.3 to 3.25.5
dependabot[bot] Sep 19, 2024
6078fb6
Merge pull request #152 from crossoverJie/dependabot/maven/com.google…
crossoverJie Sep 20, 2024
cde9300
fix:User_Logout_NPE
cmgyqjj Sep 20, 2024
a3be663
Merge branch 'master' into fix_User_Logout_NPE
cmgyqjj Sep 20, 2024
4604eb8
feature:feature_Use_Spring_IOC_to_refactor_RpcProxyManager
cmgyqjj Sep 20, 2024
6186f0d
feature:Support_reconnect_backoff_interface
cmgyqjj Sep 21, 2024
5f3d1b0
feature:Support_reconnect_backoff_interface
cmgyqjj Sep 21, 2024
92f7cb8
feature:Support_reconnect_backoff_interface
cmgyqjj Sep 21, 2024
5d77aac
feature:Support_LRU_User_Info_Cache
cmgyqjj Sep 21, 2024
9198e92
feature:Support_LRU_User_Info_Cache
cmgyqjj Sep 21, 2024
ef869cb
feature:Support_LRU_User_Info_Cache
cmgyqjj Sep 21, 2024
bc09466
translate issue template to english
crossoverJie Sep 21, 2024
508b916
Merge remote-tracking branch 'origin/master'
crossoverJie Sep 21, 2024
211ebf2
feature:Use_Spring_IOC_to_refactor_RpcProxyManager
cmgyqjj Sep 21, 2024
1128d0c
Merge pull request #154 from cmgyqjj/feature_Use_Spring_IOC_to_refact…
crossoverJie Sep 21, 2024
fa415d1
Merge branch 'master' into feature_Support_LRU_User_Info_Cache
cmgyqjj Sep 21, 2024
710c1dc
fix:User_Logout_NPE
cmgyqjj Sep 21, 2024
b2e9258
Merge branch 'master' into fix_User_Logout_NPE
cmgyqjj Sep 21, 2024
8c925a4
fix:User_Logout_NPE
cmgyqjj Sep 21, 2024
d6ee31a
Merge remote-tracking branch 'origin/fix_User_Logout_NPE' into fix_Us…
cmgyqjj Sep 21, 2024
0823d51
feature_Support_LRU_User_Info_Cache
cmgyqjj Sep 21, 2024
54b815b
fix_User_Logout_NPE
cmgyqjj Sep 21, 2024
5bba820
Merge pull request #153 from cmgyqjj/fix_User_Logout_NPE
crossoverJie Sep 21, 2024
f92dfcf
remove unless exception
crossoverJie Sep 22, 2024
218d1d4
remove unless code
crossoverJie Sep 22, 2024
6aed87f
Merge branch 'master' into feature_Support_LRU_User_Info_Cache
cmgyqjj Sep 22, 2024
8eb336d
feature_Support_LRU_User_Info_Cache
cmgyqjj Sep 22, 2024
028ba3f
upgrade-codecov
crossoverJie Sep 22, 2024
e7a6905
upgrade-codecov
crossoverJie Sep 22, 2024
ff06141
Merge pull request #157 from crossoverJie/upgrade-codecov
crossoverJie Sep 22, 2024
36a3a37
Merge branch 'master' into feature_Support_LRU_User_Info_Cache
crossoverJie Sep 22, 2024
7317688
upgrade-codecov
crossoverJie Sep 22, 2024
9e94b66
Merge pull request #158 from crossoverJie/upgrade-codecov
crossoverJie Sep 22, 2024
36d414b
Merge branch 'master' into feature_Support_LRU_User_Info_Cache
crossoverJie Sep 22, 2024
5d9bdbe
upgrade-codecov
crossoverJie Sep 22, 2024
f080cbe
Merge pull request #159 from crossoverJie/upgrade-codecov
crossoverJie Sep 22, 2024
54b9370
Merge branch 'master' into feature_Support_LRU_User_Info_Cache
crossoverJie Sep 22, 2024
20c232c
upgrade-codecov
crossoverJie Sep 22, 2024
a760273
Merge branch 'master' into feature_Support_LRU_User_Info_Cache
crossoverJie Sep 22, 2024
e4e9135
Update cim-forward-route/src/main/java/com/crossoverjie/cim/route/ser…
cmgyqjj Sep 22, 2024
03712e5
Update cim-forward-route/src/main/java/com/crossoverjie/cim/route/con…
cmgyqjj Sep 22, 2024
6b1a1fb
Update cim-forward-route/src/main/java/com/crossoverjie/cim/route/con…
cmgyqjj Sep 22, 2024
65d0c2d
Update cim-forward-route/src/main/java/com/crossoverjie/cim/route/con…
cmgyqjj Sep 22, 2024
3961542
feature_Support_LRU_User_Info_Cache
cmgyqjj Sep 22, 2024
6e08eb7
Update cim-forward-route/src/main/java/com/crossoverjie/cim/route/con…
cmgyqjj Sep 22, 2024
a727b1b
feature_Support_LRU_User_Info_Cache
cmgyqjj Sep 22, 2024
1a11353
upgrade-codecov
crossoverJie Sep 22, 2024
3446b87
Merge branch 'master' into feature_Support_reconnect_backoff_interface
crossoverJie Sep 22, 2024
4ed3e18
feature_Support_LRU_User_Info_Cache
cmgyqjj Sep 22, 2024
72d7be1
Merge branch 'master' into feature_Support_LRU_User_Info_Cache
crossoverJie Sep 22, 2024
5070761
Merge remote-tracking branch 'cr/feature_Support_LRU_User_Info_Cache'…
crossoverJie Sep 22, 2024
106a42e
Update cim-forward-route/src/main/java/com/crossoverjie/cim/route/con…
cmgyqjj Sep 22, 2024
dbde9e8
Update cim-forward-route/src/main/java/com/crossoverjie/cim/route/con…
cmgyqjj Sep 22, 2024
29dcbea
Merge pull request #156 from cmgyqjj/feature_Support_LRU_User_Info_Cache
crossoverJie Sep 22, 2024
50eccb0
feature_Support_reconnect_backoff_interface
cmgyqjj Sep 23, 2024
6fcf621
Merge branch 'master' into feature_Support_reconnect_backoff_interface
cmgyqjj Sep 23, 2024
22429e1
feature_Support_reconnect_backoff_interface
cmgyqjj Sep 25, 2024
fd29769
feature_Support_reconnect_backoff_interface
cmgyqjj Sep 25, 2024
5eabda1
Update cim-client/src/test/resources/application.yaml
cmgyqjj Sep 26, 2024
7197188
Update cim-client-sdk/src/main/java/com/crossoverjie/cim/client/sdk/i…
cmgyqjj Sep 26, 2024
26582a9
Merge pull request #155 from cmgyqjj/feature_Support_reconnect_backof…
crossoverJie Sep 26, 2024
361719b
remove unless package
crossoverJie Sep 26, 2024
9c293c1
remove unless package
crossoverJie Sep 26, 2024
5bfad6c
optimize-client-msg
crossoverJie Sep 30, 2024
77715b9
Merge pull request #161 from crossoverJie/optimize-client-msg
crossoverJie Sep 30, 2024
a5f63a2
update readme
crossoverJie Oct 11, 2024
b2cb341
update readme
crossoverJie Oct 11, 2024
d145c63
update readme
crossoverJie Oct 11, 2024
b0386e2
update readme
crossoverJie Oct 12, 2024
1b03e3a
update readme
crossoverJie Oct 12, 2024
d8933c5
update readme
crossoverJie Oct 14, 2024
5700aee
upgrade protocol2->3
crossoverJie Oct 19, 2024
7928c23
remove unless code
crossoverJie Oct 19, 2024
48adb95
Merge pull request #163 from crossoverJie/upgrade-pb
crossoverJie Oct 19, 2024
537a765
refactor cmd type
crossoverJie Oct 19, 2024
8b52c59
proto-add-properties
crossoverJie Oct 21, 2024
a93e4ec
fix ci
crossoverJie Oct 21, 2024
c72deb2
shorter code
crossoverJie Oct 21, 2024
02a8a38
Merge pull request #164 from crossoverJie/optimization-proto
crossoverJie Oct 21, 2024
d03d1ec
[fix] -
chenqwwq Nov 10, 2024
53dc496
Merge pull request #165 from chenqwwq/master
crossoverJie Nov 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
---
name: Bug report
about: Create a report to help us improve
title: '提交之前请查看是否有相关 issue,谢谢。'
title: 'Please check if there are similar issues before submitting'
labels: ''
assignees: ''

---

**Bug 描述**
**Bug Description**
A clear and concise description of what the bug is.

**复现**
复现步骤:
**Reproduce**
step:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**预期结果**
**Expected results**
A clear and concise description of what you expected to happen.

**截图**
**Screenshot**
If applicable, add screenshots to help explain your problem.


**附加信息**
**Additional Information**
Add any other context about the problem here.
21 changes: 21 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Java CI with Maven

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:
uses: ./.github/workflows/reusable_run_tests.yml
secrets:
codecov_token: ${{ secrets.CODECOV_TOKEN }}
29 changes: 29 additions & 0 deletions .github/workflows/reusable_run_tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: A reusable workflow to build and run the unit test suite

on:
workflow_call:
secrets:
codecov_token:
required: true
workflow_dispatch:

jobs:
build_and_test:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
78 changes: 41 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<img src="https://i.loli.net/2020/02/21/rfOGvKlTcHCmM92.png" />
<br/>

[![codecov](https://codecov.io/gh/crossoverJie/cim/graph/badge.svg?token=oW5Gd1oKmf)](https://codecov.io/gh/crossoverJie/cim)
[![Build Status](https://img.shields.io/badge/cim-cross--im-brightgreen.svg)](https://github.com/crossoverJie/cim)
[![](https://badge.juejin.im/entry/5c2c000e6fb9a049f5713e26/likes.svg?style=flat-square)](https://juejin.im/post/5c2bffdc51882509181395d7)

Expand All @@ -16,27 +17,26 @@

# V2.0
- [x] Upgrade to JDK17 & springboot3.0
- [x] Client SDK
- [ ] Client use [picocli](https://picocli.info/) instead of springboot.
- [ ] Supports binary client(build with golang).
- [ ] Support integration testing.
- [x] Support integration testing.
- [ ] Integrate OpenTelemetry .
- [ ] Support single node startup(Contains no components).
- [ ] Third-party components support replacement(Redis/Zookeeper, etc.).
- [ ] Support web client(websocket).
- [ ] Support docker container.
- [ ] Support kubernetes operation.
- [ ] Supports binary client(build with golang).

## 介绍
## Introduction

`CIM(CROSS-IM)` 一款面向开发者的 `IM(即时通讯)`系统;同时提供了一些组件帮助开发者构建一款属于自己可水平扩展的 `IM` 。
`CIM(CROSS-IM)` is an `IM (instant messaging)` system for developers; it also provides some components to help developers build their own scalable `IM`.
Using `CIM`, you can achieve the following requirements:
- `IM` instant messaging system.
- Message push middleware for `APP`.
- Message middleware for `IOT` massive connection scenarios.

借助 `CIM` 你可以实现以下需求:

- `IM` 即时通讯系统。
- 适用于 `APP` 的消息推送中间件。
- `IOT` 海量连接场景中的消息透传中间件。

> 在使用或开发过程中有任何疑问都可[联系我](#联系作者)。
> If you have any questions during use or development, you can [contact me](#联系作者).

## 视频演示

Expand All @@ -47,6 +47,7 @@
| [群聊](https://youtu.be/_9a4lIkQ5_o) [私聊](https://youtu.be/kfEfQFPLBTQ) | [群聊](https://www.bilibili.com/video/av39405501) [私聊](https://www.bilibili.com/video/av39405821) |
| <img src="https://i.loli.net//2019//05//08//5cd1d9e788004.jpg" height="295px" /> | <img src="https://i.loli.net//2019//05//08//5cd1da2f943c5.jpg" height="295px" />

![demo.gif](pic/demo.gif)

## TODO LIST

Expand All @@ -60,60 +61,63 @@
* [x] 服务端自动剔除离线客户端
* [x] 客户端自动重连
* [x] [延时消息](#延时消息)
* [x] SDK 开发包
* [ ] 分组群聊
* [ ] SDK 开发包
* [ ] 离线消息
* [ ] 协议支持消息加密
* [ ] 消息加密



## 系统架构
## Architecture

![](https://i.loli.net/2019/05/08/5cd1d45a156f1.jpg)
![](pic/architecture.png)

- `CIM` 中的各个组件均采用 `SpringBoot` 构建。
- 采用 `Netty` 构建底层通信。
- `Redis` 存放各个客户端的路由信息、账号信息、在线状态等。
- `Zookeeper` 用于 `IM-server` 服务的注册与发现。
- Each component in `CIM` is built using `SpringBoot`
- Client build with [cim-client-sdk](https://github.com/crossoverJie/cim/tree/master/cim-client-sdk)
- Use `Netty` to build the underlying communication.
- `MetaStore` is used for registration and discovery of `IM-server` services.


### cim-server
IM server is used to receive client connections, message forwarding, message push, etc.
Support cluster deployment.

`IM` 服务端;用于接收 `client` 连接、消息透传、消息推送等功能。

**支持集群部署。**
### cim-route

### cim-forward-route

消息路由服务器;用于处理消息路由、消息转发、用户登录、用户下线以及一些运营工具(获取在线用户数等)。
Route server; used to process message routing, message forwarding, user login, user offline, and some operation tools (get the number of online users, etc.).

### cim-client
IM client terminal, a command can be started and initiated to communicate with others (group chat, private chat).

`IM` 客户端;给用户使用的消息终端,一个命令即可启动并向其他人发起通讯(群聊、私聊)。

## 流程图
## Flow Chart

![](https://i.loli.net/2019/05/08/5cd1d45b982b3.jpg)
![](https://s2.loli.net/2024/10/13/8teMn7BSa5VWuvi.png)

- 客户端向 `route` 发起登录。
- 登录成功从 `Zookeeper` 中选择可用 `IM-server` 返回给客户端,并保存登录、路由信息到 `Redis`。
- 客户端向 `IM-server` 发起长连接,成功后保持心跳。
- 客户端下线时通过 `route` 清除状态信息。
- Server register to `MetaStore`
- Route subscribe `MetaStore`
- Client login to Route
- Route get Server info from `MetaStore`
- Client open connection to Server
- Client1 send message to Route
- Route select Server and forward message to Server
- Server push message to Client2


## 快速启动

首先需要安装 `Zookeeper、Redis` 并保证网络通畅。

```shell
docker run --name zookeeper -d -p 2181:2181 zookeeper
docker run --rm --name redis -d -p 6379:6379 redis
docker run --rm --name zookeeper -d -p 2181:2181 zookeeper:3.9.2
docker run --rm --name redis -d -p 6379:6379 redis:7.4.0
```

```shell
git clone https://github.com/crossoverJie/cim.git
cd cim
mvn -Dmaven.test.skip=true clean package
mvn clean package -DskipTests=true
cd cim-server && cim-client && cim-forward-route
mvn clean package spring-boot:repackage -DskipTests=true
```

### 部署 IM-server(cim-server)
Expand Down Expand Up @@ -272,7 +276,7 @@ java -jar cim-client-1.0.0-SNAPSHOT.jar --server.port=8084 --cim.user.id=上方
:delay delayMsg 10
```

![](https://tva1.sinaimg.cn/large/006y8mN6ly1g7brppmokqg30gn07gafj.gif)
![](pic/delay.gif)

## 联系作者

Expand Down
25 changes: 25 additions & 0 deletions cim-client-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

```java
var auth1 = ClientConfigurationData.Auth.builder()
.userId(id)
.userName(cj)
.build();

Client client1 = Client.builder()
.auth(auth1)
.routeUrl(routeUrl)
.build();

ClientState.State state = client1.getState();
Awaitility.await().atMost(10, TimeUnit.SECONDS)
.untilAsserted(() -> Assertions.assertEquals(ClientState.State.Ready, state));
Optional<CIMServerResVO> serverInfo = client1.getServerInfo();
Assertions.assertTrue(serverInfo.isPresent());

// send msg
String msg = "hello";
client1.sendGroup(msg);

// get oline user
Set<CIMUserInfo> onlineUser = client1.getOnlineUser();
```
51 changes: 51 additions & 0 deletions cim-client-sdk/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.crossoverjie.netty</groupId>
<artifactId>cim</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>cim-client-sdk</artifactId>

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>


<dependencies>
<dependency>
<groupId>com.crossoverjie.netty</groupId>
<artifactId>cim-common</artifactId>
</dependency>

<dependency>
<groupId>com.crossoverjie.netty</groupId>
<artifactId>cim-rout-api</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.crossoverjie.netty</groupId>
<artifactId>cim-integration-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.crossoverjie.cim.client.sdk;

import com.crossoverjie.cim.client.sdk.impl.ClientBuilderImpl;
import com.crossoverjie.cim.client.sdk.impl.ClientConfigurationData;
import com.crossoverjie.cim.common.pojo.CIMUserInfo;
import com.crossoverjie.cim.route.api.vo.req.P2PReqVO;
import com.crossoverjie.cim.route.api.vo.res.CIMServerResVO;
import java.io.Closeable;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletableFuture;

public interface Client extends Closeable {

static ClientBuilder builder() {
return new ClientBuilderImpl();
}

default void sendP2P(P2PReqVO p2PReqVO) throws Exception{
sendP2PAsync(p2PReqVO).get();
};

CompletableFuture<Void> sendP2PAsync(P2PReqVO p2PReqVO);

default void sendGroup(String msg) throws Exception{
sendGroupAsync(msg).get();
};

CompletableFuture<Void> sendGroupAsync(String msg);

ClientState.State getState();

ClientConfigurationData.Auth getAuth();

Set<CIMUserInfo> getOnlineUser() throws Exception;

Optional<CIMServerResVO> getServerInfo();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.crossoverjie.cim.client.sdk;

import com.crossoverjie.cim.client.sdk.impl.ClientConfigurationData;
import com.crossoverjie.cim.client.sdk.io.MessageListener;
import com.crossoverjie.cim.client.sdk.io.ReconnectCheck;
import java.util.concurrent.ThreadPoolExecutor;

import com.crossoverjie.cim.client.sdk.io.backoff.BackoffStrategy;
import okhttp3.OkHttpClient;

/**
* @author crossoverJie
*/
public interface ClientBuilder {

Client build();
ClientBuilder auth(ClientConfigurationData.Auth auth);
ClientBuilder routeUrl(String routeUrl);
ClientBuilder loginRetryCount(int loginRetryCount);
ClientBuilder event(Event event);
ClientBuilder reconnectCheck(ReconnectCheck reconnectCheck);
ClientBuilder okHttpClient(OkHttpClient okHttpClient);
ClientBuilder messageListener(MessageListener messageListener);
ClientBuilder callbackThreadPool(ThreadPoolExecutor callbackThreadPool);
ClientBuilder backoffStrategy(BackoffStrategy backoffStrategy);
}
Loading