Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06fed7de52 | ||
|
|
da2428a9f9 | ||
|
|
83b6ae5229 | ||
|
|
4b7804cdfd | ||
|
|
d075b5212f | ||
|
|
636c8ce219 | ||
|
|
091d7fa3ec | ||
|
|
59356e5b52 | ||
|
|
882bf29e63 | ||
|
|
f3eef4dd6b | ||
|
|
898983c6e5 | ||
|
|
dae5d032fa | ||
|
|
ff76622796 | ||
|
|
a6fd11a243 | ||
|
|
cf983be44c | ||
|
|
1a72de0e85 | ||
|
|
bf70a1e80e | ||
|
|
512d797d4d | ||
|
|
4a46dd1dde | ||
|
|
7494cdc071 | ||
|
|
608184ef9e | ||
|
|
eb4d8a9b68 | ||
|
|
6b92ae383c | ||
|
|
5fee857c4a | ||
|
|
53b7139c30 | ||
|
|
83e864d667 | ||
|
|
b88297e6de | ||
|
|
4aa2f46011 | ||
|
|
1fb3c757e2 | ||
|
|
3f640b6c14 | ||
|
|
49eb57af00 | ||
|
|
6bd6a80e71 | ||
|
|
38b84f0fa5 | ||
|
|
1f46debd0c | ||
|
|
37998e76d1 | ||
|
|
80b5508533 | ||
|
|
a646cc8227 | ||
|
|
92692adf52 | ||
|
|
b2cfc2b99b | ||
|
|
86e08f6151 | ||
|
|
8d852eb2d1 | ||
|
|
8bef018911 | ||
|
|
5e13419c28 | ||
|
|
503a7ae18f | ||
|
|
dfb9638a38 | ||
|
|
8452b0675b | ||
|
|
930643706a | ||
|
|
a2eac1f721 | ||
|
|
6e994cd694 | ||
|
|
c82869c631 | ||
|
|
f5a94868c4 | ||
|
|
c5628d613b | ||
|
|
9509b1ffa8 | ||
|
|
c1dac8a21e | ||
|
|
950846df45 | ||
|
|
31d96e2dc6 | ||
|
|
031e96075e | ||
|
|
bf2caeac6c | ||
|
|
12e523b37e | ||
|
|
576c985d8f | ||
|
|
9365807f47 | ||
|
|
25ce10fa61 | ||
|
|
09c333501f | ||
|
|
c51b09ee3a | ||
|
|
4d82eace86 | ||
|
|
385b03a163 | ||
|
|
4b438afa69 | ||
|
|
66961b94da | ||
|
|
39b62e5942 | ||
|
|
5bb8ab3d95 | ||
|
|
8dfc23b61d | ||
|
|
c8769808b5 | ||
|
|
2fc106aa26 | ||
|
|
da0b725ff8 | ||
|
|
15703d66fb | ||
|
|
c68beeaa51 | ||
|
|
5ef8868916 | ||
|
|
24488cc985 | ||
|
|
1c9faaa1e6 | ||
|
|
ac32875b14 | ||
|
|
07c1dd29e0 | ||
|
|
bd93233c34 | ||
|
|
20aec2fbcf | ||
|
|
a149139143 | ||
|
|
c857d1abb7 | ||
|
|
dde9da7006 | ||
|
|
d18a1970e5 | ||
|
|
66b9aeec17 | ||
|
|
ea301a3923 | ||
|
|
ced272a783 | ||
|
|
c9f320da31 | ||
|
|
025873e66b | ||
|
|
ecddc40aa5 | ||
|
|
cb13a02b75 | ||
|
|
5714a9a1d3 | ||
|
|
d0671c1682 | ||
|
|
88b3ac42bb | ||
|
|
4ecf3dec76 | ||
|
|
b4b70ca7e5 | ||
|
|
d3aa68df05 | ||
|
|
36aa0518ed | ||
|
|
b1c5692322 | ||
|
|
db24edf7d5 | ||
|
|
798a576d0b | ||
|
|
b49225fbf7 | ||
|
|
439cf82fcc | ||
|
|
7527bf4761 |
@@ -49,5 +49,10 @@ maven-metadata.xml
|
||||
/bin/
|
||||
broker/config/git.properties
|
||||
distribution/src/main/resources/git.properties
|
||||
license/target
|
||||
server/target
|
||||
broker/h2db
|
||||
broker/media
|
||||
common/target
|
||||
server/target
|
||||
sdk/target
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## 野火IM解决方案
|
||||
|
||||
野火IM是一套跨平台、全开源的即时通讯解决方案,主要包含以下内容。
|
||||
野火IM是一套跨平台、核心功能开源的即时通讯解决方案,主要包含以下内容。
|
||||
|
||||
| 仓库 | 说明 | 备注 |
|
||||
| ------------------------------------------------------------ | ------------------------------------------------------- | ---------------------------------------------- |
|
||||
@@ -20,14 +20,26 @@
|
||||
|
||||
开发一套IM系统真的很艰辛,请路过的朋友们给点个star,支持我们坚持下去🙏🙏🙏🙏🙏
|
||||
|
||||
|
||||
### 联系我们
|
||||
问题讨论请加群:822762829
|
||||
|
||||
微信公众号:
|
||||
> 商务合作请优先采用邮箱和我们联系。技术问题请到[野火IM论坛](http://bbs.wildfirechat.cn/)发帖交流
|
||||
|
||||
1. heavyrain.lee 邮箱: heavyrain.lee@wildfirechat.cn 微信:wildfirechat
|
||||
2. imndx 邮箱: imndx@wildfirechat.cn 微信:wfchat
|
||||
|
||||
### 问题交流
|
||||
1. 微信交流群(请先加我们好友,我们再邀请您进群)
|
||||
|
||||
 
|
||||
|
||||
2. 如果大家发现bug,请在GitHub提issue
|
||||
3. 其他问题,请到[野火IM论坛](http://bbs.wildfirechat.cn/)进行交流学习
|
||||
4. 微信公众号
|
||||
|
||||
<img src="http://static.wildfirechat.cn/wx_wfc_qrcode.jpg" width = 50% height = 50% />
|
||||
|
||||
> 强烈建议关注我们的公众号。我们有新版本发布或者有重大更新会通过公众号通知大家,另外我们也会不定期的发布一些关于野火IM的技术介绍。
|
||||
|
||||
#### 体验Demo
|
||||
我们提供了体验demo,请使用微信扫码下载安装体验
|
||||
|
||||
@@ -59,6 +71,12 @@
|
||||
## 编译
|
||||
在安装JDK1.8以上及maven的前提下,在命令行中执行```mvn clean compile package```,生成的目标文件在```./distribution/target/distribution-xxxx-bundle-tar.tar.gz```
|
||||
|
||||
## 捐赠者名单
|
||||
|
||||
| 捐赠者 | 商标 | 金额 | 简介 |
|
||||
| ----- | ---- | -------- | --- |
|
||||
| [SAMOS](http://samos.io) |  | 保密 | 一站式区块链解决方案服务商(http://samos.io) |
|
||||
|
||||
## 特别感谢
|
||||
1. [moquette](https://github.com/moquette-io/moquette) 本项目是基于此项目二次开发而来,处理MQTT相关业务。
|
||||
2. [loServer](https://github.com/looly/loServer) 本项目使用loServer处理HTTP相关业务。
|
||||
|
||||
@@ -26,8 +26,8 @@ host 0.0.0.0
|
||||
##本地绑定端口
|
||||
local_port 80
|
||||
|
||||
##是否使用内置DB。0使用mysql;1使用h2db
|
||||
embed.db 1
|
||||
##是否使用内置DB。0使用mysql;1使用h2db;2使用mysql+mongodb。社区版只支持0和1,专业版支持2
|
||||
embed.db 0
|
||||
|
||||
##服务器管理接口密钥
|
||||
http.admin.secret_key 123456
|
||||
@@ -42,6 +42,12 @@ client.proto.secret_key 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x78,0x79,0x7A,0
|
||||
##用来生产im token的私钥,只在服务器使用,客户端不用。正式使用时为了安全一定要修改这个值,切记切记
|
||||
token.key testim
|
||||
|
||||
##首次登录,是否接收之前的历史消息。0 不接收;1接收。
|
||||
message.roaming 0
|
||||
|
||||
##是否开启拉取远程历史消息
|
||||
message.remote_history_message 0
|
||||
|
||||
#*********************************************************************
|
||||
# hazelcase configuration
|
||||
#*********************************************************************
|
||||
@@ -95,10 +101,20 @@ push.android.server.address http://localhost:8085/android/push
|
||||
push.ios.server.address http://localhost:8085/ios/push
|
||||
|
||||
|
||||
#*********************************************************************
|
||||
# MongoDB configuration
|
||||
#*********************************************************************
|
||||
#专业版支持,社区版请忽略
|
||||
#mongodb.client_uri mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
|
||||
#mongodb.client_uri mongodb://host1:27017,host2:27017,host3:27017/wfchat?replicaSet=myReplicaSet
|
||||
mongodb.client_uri mongodb://wfc:123456@localhost:27017/wfchat
|
||||
mongodb.database wfchat
|
||||
mongodb.data_expire_days 1096
|
||||
|
||||
#*********************************************************************
|
||||
# Sensitive configuration
|
||||
#*********************************************************************
|
||||
##文本敏感词过滤处理方法,0 发送失败;1 发送成功但消息被服务器直接丢弃;2 命中的敏感词被替换成***
|
||||
##文本敏感词过滤处理方法,0 发送失败;1 发送成功但消息被服务器直接丢弃;2 命中的敏感词被替换成***;3 记录并继续发送
|
||||
sensitive.filter.type 0
|
||||
|
||||
#*********************************************************************
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
|
||||
insert into t_user (`_uid`,`_name`,`_display_name`,`_type`,`_dt`) values ('admin','admin','系统管理员',3,1);
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
ALTER TABLE t_user_session MODIFY _token VARCHAR(240) DEFAULT NULL;
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table `t_group` add column `_mute` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_join_type` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_private_chat` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_searchable` tinyint NOT NULL DEFAULT 0;
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_settings`;
|
||||
CREATE TABLE `t_settings` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY,
|
||||
`value` varchar(64) NOT NULL,
|
||||
`desc` varchar(128) NOT NULL
|
||||
);
|
||||
|
||||
|
||||
insert into t_settings(`id`, `value`,`desc`) values (1, '3000', '最大群成员数量');
|
||||
@@ -0,0 +1 @@
|
||||
alter table `t_sensitiveword` add column `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table t_user add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
alter table t_group add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
@@ -0,0 +1 @@
|
||||
alter table `t_messages` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_sensitive_messages`;
|
||||
CREATE TABLE `t_sensitive_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_mid` bigint(20) NOT NULL,
|
||||
`_from` varchar(64) NOT NULL,
|
||||
`_type` tinyint NOT NULL DEFAULT 0,
|
||||
`_target` varchar(64) NOT NULL,
|
||||
`_line` int(11) NOT NULL DEFAULT 0,
|
||||
`_data` BLOB NOT NULL,
|
||||
`_searchable_key` TEXT DEFAULT NULL,
|
||||
`_dt` DATETIME NOT NULL DEFAULT NOW(),
|
||||
`_content_type` int(11) NOT NULL DEFAULT 0,
|
||||
UNIQUE INDEX `sensitive_message_uid_index` (`_mid` ASC)
|
||||
);
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
|
||||
insert into t_user (`_uid`,`_name`,`_display_name`,`_type`,`_dt`) values ('admin','admin','系统管理员',3,1);
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
ALTER TABLE t_user_session MODIFY _token VARCHAR(240) DEFAULT NULL;
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table `t_group` add column `_mute` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_join_type` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_private_chat` tinyint NOT NULL DEFAULT 0;
|
||||
alter table `t_group` add column `_searchable` tinyint NOT NULL DEFAULT 0;
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_session`;
|
||||
CREATE TABLE `t_session` (
|
||||
`row_id` varchar(50) not null primary key,
|
||||
`del_flag` tinyint(1) default 0 null,
|
||||
`create_time` timestamp null,
|
||||
`update_time` timestamp null,
|
||||
`expire_time` timestamp null,
|
||||
`user_id` int null,
|
||||
constraint `t_session_pk_2` unique (`user_id`, `expire_time`)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table t_user MODIFY column `_createTime` DATETIME NOT NULL DEFAULT NOW();
|
||||
alter table t_group MODIFY column `_createTime` DATETIME NOT NULL DEFAULT NOW();
|
||||
@@ -0,0 +1,4 @@
|
||||
alter table t_session MODIFY column `create_time` DATETIME NOT NULL DEFAULT NOW();
|
||||
alter table t_session MODIFY column `update_time` DATETIME NOT NULL DEFAULT NOW();
|
||||
alter table t_session MODIFY column `expire_time` DATETIME NOT NULL DEFAULT NOW();
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
update t_messages_0 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_1 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_2 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_3 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_4 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_5 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_6 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_7 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_8 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_9 set _dt = date_add(_dt, interval 8 hour);
|
||||
|
||||
update t_messages_10 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_11 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_12 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_13 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_14 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_15 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_16 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_17 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_18 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_19 set _dt = date_add(_dt, interval 8 hour);
|
||||
|
||||
update t_messages_20 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_21 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_22 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_23 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_24 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_25 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_26 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_27 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_28 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_29 set _dt = date_add(_dt, interval 8 hour);
|
||||
|
||||
|
||||
update t_messages_30 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_31 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_32 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_33 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_34 set _dt = date_add(_dt, interval 8 hour);
|
||||
update t_messages_35 set _dt = date_add(_dt, interval 8 hour);
|
||||
+4038
File diff suppressed because it is too large
Load Diff
+13
@@ -0,0 +1,13 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_settings`;
|
||||
CREATE TABLE `t_settings` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY,
|
||||
`value` varchar(64) NOT NULL,
|
||||
`desc` varchar(128) NOT NULL default ""
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
|
||||
|
||||
insert into t_settings(`id`, `value`,`desc`) values (1, "3000", "最大群成员数量");
|
||||
@@ -0,0 +1 @@
|
||||
alter table `t_sensitiveword` add column `id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT;
|
||||
@@ -0,0 +1,2 @@
|
||||
alter table t_user add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
alter table t_group add column `_createTime` TIMESTAMP default CURRENT_TIMESTAMP;
|
||||
@@ -0,0 +1,36 @@
|
||||
alter table `t_messages_0` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_1` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_2` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_3` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_4` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_5` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_6` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_7` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_8` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_9` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_10` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_11` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_12` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_13` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_14` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_15` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_16` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_17` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_18` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_19` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_20` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_21` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_22` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_23` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_24` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_25` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_26` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_27` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_28` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_29` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_30` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_31` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_32` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_33` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_34` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
alter table `t_messages_35` add column `_content_type` int(11) NOT NULL DEFAULT '0';
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
|
||||
DROP TABLE IF EXISTS `t_sensitive_messages`;
|
||||
CREATE TABLE `t_sensitive_messages` (
|
||||
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
`_mid` bigint(20) NOT NULL,
|
||||
`_from` varchar(64) NOT NULL,
|
||||
`_type` tinyint NOT NULL DEFAULT 0,
|
||||
`_target` varchar(64) NOT NULL,
|
||||
`_line` int(11) NOT NULL DEFAULT 0,
|
||||
`_data` BLOB NOT NULL,
|
||||
`_searchable_key` TEXT DEFAULT NULL,
|
||||
`_dt` DATETIME NOT NULL,
|
||||
`_content_type` int(11) NOT NULL DEFAULT '0',
|
||||
INDEX `message_uid_index` (`_mid` DESC)
|
||||
)
|
||||
ENGINE = InnoDB
|
||||
DEFAULT CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_unicode_ci;
|
||||
+8
-26
@@ -5,7 +5,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.21</version>
|
||||
<version>0.26</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>moquette-broker</artifactId>
|
||||
@@ -110,34 +110,11 @@
|
||||
<artifactId>netty-transport-native-epoll</artifactId>
|
||||
<version>${netty.version}</version>
|
||||
<classifier>linux-x86_64</classifier>
|
||||
<!--
|
||||
<!--
|
||||
<classifier>${os.detected.name}-${os.detected.arch}</classifier>
|
||||
-->
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.dropwizard.metrics</groupId>
|
||||
<artifactId>metrics-core</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.dropwizard.metrics</groupId>
|
||||
<artifactId>metrics-jvm</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.librato.metrics</groupId>
|
||||
<artifactId>metrics-librato</artifactId>
|
||||
<version>5.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.bugsnag</groupId>
|
||||
<artifactId>bugsnag</artifactId>
|
||||
<version>[3.0,4.0)</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
@@ -170,7 +147,7 @@
|
||||
<dependency>
|
||||
<groupId>com.mchange</groupId>
|
||||
<artifactId>c3p0</artifactId>
|
||||
<version>[0.9.5.3,)</version>
|
||||
<version>0.9.5.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- needs extra dependencies: objenesis & hamcrest -->
|
||||
@@ -256,6 +233,11 @@
|
||||
<version>5.2.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>3.4.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
/**
|
||||
@@ -84,7 +86,7 @@ abstract public class Action {
|
||||
if (request instanceof FullHttpRequest) {
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest) request;
|
||||
byte[] bytes = Utils.readBytesAndRewind(fullHttpRequest.content());
|
||||
String content = new String(bytes);
|
||||
String content = new String(bytes, StandardCharsets.UTF_8);//contribute by JiaRG from github
|
||||
Gson gson = new Gson();
|
||||
T t = gson.fromJson(content, cls);
|
||||
return t;
|
||||
|
||||
@@ -35,12 +35,15 @@ import java.util.concurrent.Executor;
|
||||
@HttpMethod("POST")
|
||||
public class RouteAction extends Action {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(RouteAction.class);
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
|
||||
response.setContentType("application/octet-stream");
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest)request.getNettyRequest();
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
FullHttpRequest fullHttpRequest = (FullHttpRequest) request.getNettyRequest();
|
||||
boolean b = false;
|
||||
if ("web".equalsIgnoreCase(fullHttpRequest.headers().get("p"))) {
|
||||
b = true;
|
||||
@@ -144,10 +147,14 @@ public class RouteAction extends Action {
|
||||
|
||||
private void sendResponse(Response response, ErrorCode errorCode, byte[] contents, boolean base64Response) {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
if(contents == null) {
|
||||
if (contents == null) {
|
||||
ByteBuf ackPayload = Unpooled.buffer();
|
||||
ackPayload.ensureWritable(1).writeByte(errorCode.getCode());
|
||||
response.setContent(ackPayload);
|
||||
contents = ackPayload.array();
|
||||
}
|
||||
if (base64Response) {
|
||||
byte[] base64Data = Base64.getEncoder().encode(contents);
|
||||
response.setContent(base64Data);
|
||||
} else {
|
||||
response.setContent(contents);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import cn.wildfirechat.pojos.OutputLoginData;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.GitRepositoryState;
|
||||
import win.liyufan.im.Utility;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@@ -32,7 +33,8 @@ public class VersionAction extends Action {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
|
||||
try {
|
||||
response.setContent(new Gson().toJson(GitRepositoryState.getGitRepositoryState()));
|
||||
|
||||
response.setContent(Utility.formatJson(new Gson().toJson(GitRepositoryState.getGitRepositoryState())));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
response.setContent("{\"version\":\"unknown\"}");
|
||||
|
||||
@@ -45,7 +45,7 @@ public class BlockUserAction extends AdminAction {
|
||||
result = RestResult.resultOf(errorCode);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
|
||||
if (inputUserBlock.getStatus() != 0) {
|
||||
if (inputUserBlock.getStatus() == 2) {
|
||||
RPCCenter.getInstance().sendRequest(null, null, RPCCenter.KICKOFF_USER_REQUEST, inputUserBlock.getUserId().getBytes(), inputUserBlock.getUserId(), TargetEntry.Type.TARGET_TYPE_USER, null, true);
|
||||
}
|
||||
|
||||
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.BroadMessageData;
|
||||
import cn.wildfirechat.pojos.BroadMessageResult;
|
||||
import cn.wildfirechat.pojos.SendMessageData;
|
||||
import cn.wildfirechat.pojos.SendMessageResult;
|
||||
import com.google.gson.Gson;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Msg_Broadcast)
|
||||
@HttpMethod("POST")
|
||||
public class BroadcastMessageAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
BroadMessageData sendMessageData = getRequestBody(request.getNettyRequest(), BroadMessageData.class);
|
||||
if (BroadMessageData.isValide(sendMessageData) && !StringUtil.isNullOrEmpty(sendMessageData.getSender())) {
|
||||
RPCCenter.getInstance().sendRequest(sendMessageData.getSender(), null, IMTopic.BroadcastMessageTopic, sendMessageData.toProtoMessage().toByteArray(), sendMessageData.getSender(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long count = byteBuf.readLong();
|
||||
sendResponse(response, null, new BroadMessageResult(messageId, count));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.*;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import win.liyufan.im.IMTopic;
|
||||
import win.liyufan.im.UUIDGenerator;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Create_Channel)
|
||||
@HttpMethod("POST")
|
||||
public class CreateChannelAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputCreateChannel inputCreateChannel = getRequestBody(request.getNettyRequest(), InputCreateChannel.class);
|
||||
if (inputCreateChannel != null
|
||||
&& !StringUtil.isNullOrEmpty(inputCreateChannel.getName())) {
|
||||
|
||||
|
||||
if(StringUtil.isNullOrEmpty(inputCreateChannel.getTargetId())) {
|
||||
inputCreateChannel.setTargetId(messagesStore.getShortUUID());
|
||||
}
|
||||
|
||||
RPCCenter.getInstance().sendRequest(inputCreateChannel.getOwner(), null, IMTopic.CreateChannelTopic, inputCreateChannel.toProtoChannelInfo().toByteArray(), inputCreateChannel.getOwner(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, new OutputCreateChannel(inputCreateChannel.getTargetId()));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -48,10 +48,6 @@ public class CreateUserAction extends AdminAction {
|
||||
inputCreateUser.setUserId(messagesStore.getShortUUID());
|
||||
}
|
||||
|
||||
if (inputCreateUser.getPortrait() == null || inputCreateUser.getPortrait().length() == 0) {
|
||||
inputCreateUser.setPortrait("https://avatars.io/gravatar/" + inputCreateUser.getUserId());
|
||||
}
|
||||
|
||||
WFCMessage.User.Builder newUserBuilder = WFCMessage.User.newBuilder()
|
||||
.setUid(StringUtil.isNullOrEmpty(inputCreateUser.getUserId()) ? "" : inputCreateUser.getUserId());
|
||||
if (inputCreateUser.getName() != null)
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.SystemSettingPojo;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
@Route(APIPath.Get_System_Setting)
|
||||
@HttpMethod("POST")
|
||||
public class GetSystemSettingAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
SystemSettingPojo inputUserId = getRequestBody(request.getNettyRequest(), SystemSettingPojo.class);
|
||||
if (inputUserId != null) {
|
||||
SystemSettingPojo output = messagesStore.getSystemSetting(inputUserId.id);
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (output == null) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_NOT_EXIST);
|
||||
} else {
|
||||
result = RestResult.ok(output);
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -42,7 +42,7 @@ public class KickoffGroupMemberAction extends AdminAction {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputKickoffGroupMember inputKickoffGroupMember = getRequestBody(request.getNettyRequest(), InputKickoffGroupMember.class);
|
||||
if (inputKickoffGroupMember.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputKickoffGroupMember.getOperator(), null, IMTopic.AddGroupMemberTopic, inputKickoffGroupMember.toProtoGroupRequest().toByteArray(), inputKickoffGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
RPCCenter.getInstance().sendRequest(inputKickoffGroupMember.getOperator(), null, IMTopic.KickoffGroupMemberTopic, inputKickoffGroupMember.toProtoGroupRequest().toByteArray(), inputKickoffGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputAddGroupMember;
|
||||
import cn.wildfirechat.pojos.InputModifyGroupInfo;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Group_Modify_Info)
|
||||
@HttpMethod("POST")
|
||||
public class ModifyGroupInfoAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
InputModifyGroupInfo inputAddGroupMember = getRequestBody(request.getNettyRequest(), InputModifyGroupInfo.class);
|
||||
if (inputAddGroupMember.isValide()) {
|
||||
RPCCenter.getInstance().sendRequest(inputAddGroupMember.getOperator(), null, IMTopic.ModifyGroupInfoTopic, inputAddGroupMember.toProtoGroupRequest().toByteArray(), inputAddGroupMember.getOperator(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
sendResponse(response, null, null);
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.BroadMessageData;
|
||||
import cn.wildfirechat.pojos.BroadMessageResult;
|
||||
import cn.wildfirechat.pojos.MultiMessageResult;
|
||||
import cn.wildfirechat.pojos.MulticastMessageData;
|
||||
import com.google.gson.Gson;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.moquette.persistence.RPCCenter;
|
||||
import io.moquette.persistence.TargetEntry;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
@Route(APIPath.Msg_Multicast)
|
||||
@HttpMethod("POST")
|
||||
public class MulticastMessageAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
MulticastMessageData sendMessageData = getRequestBody(request.getNettyRequest(), MulticastMessageData.class);
|
||||
if (MulticastMessageData.isValide(sendMessageData)) {
|
||||
RPCCenter.getInstance().sendRequest(sendMessageData.getSender(), null, IMTopic.MultiCastMessageTopic, sendMessageData.toProtoMessage().toByteArray(), sendMessageData.getSender(), TargetEntry.Type.TARGET_TYPE_USER, new RPCCenter.Callback() {
|
||||
@Override
|
||||
public void onSuccess(byte[] result) {
|
||||
ByteBuf byteBuf = Unpooled.buffer();
|
||||
byteBuf.writeBytes(result);
|
||||
ErrorCode errorCode = ErrorCode.fromCode(byteBuf.readByte());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
long messageId = byteBuf.readLong();
|
||||
long timestamp = byteBuf.readLong();
|
||||
sendResponse(response, null, new MultiMessageResult(messageId, timestamp));
|
||||
} else {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(ErrorCode errorCode) {
|
||||
sendResponse(response, errorCode, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTimeout() {
|
||||
sendResponse(response, ErrorCode.ERROR_CODE_TIMEOUT, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Executor getResponseExecutor() {
|
||||
return command -> {
|
||||
ctx.executor().execute(command);
|
||||
};
|
||||
}
|
||||
}, true);
|
||||
return false;
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package com.xiaoleilu.loServer.action.admin;
|
||||
|
||||
import cn.wildfirechat.common.APIPath;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.InputGetUserInfo;
|
||||
import cn.wildfirechat.pojos.InputOutputUserInfo;
|
||||
import cn.wildfirechat.pojos.SystemSettingPojo;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.gson.Gson;
|
||||
import com.xiaoleilu.loServer.RestResult;
|
||||
import com.xiaoleilu.loServer.annotation.HttpMethod;
|
||||
import com.xiaoleilu.loServer.annotation.Route;
|
||||
import com.xiaoleilu.loServer.handler.Request;
|
||||
import com.xiaoleilu.loServer.handler.Response;
|
||||
import io.netty.handler.codec.http.FullHttpRequest;
|
||||
import io.netty.handler.codec.http.HttpResponseStatus;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
@Route(APIPath.Put_System_Setting)
|
||||
@HttpMethod("POST")
|
||||
public class PutSystemSettingAction extends AdminAction {
|
||||
|
||||
@Override
|
||||
public boolean isTransactionAction() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean action(Request request, Response response) {
|
||||
if (request.getNettyRequest() instanceof FullHttpRequest) {
|
||||
SystemSettingPojo inputUserId = getRequestBody(request.getNettyRequest(), SystemSettingPojo.class);
|
||||
if (inputUserId != null
|
||||
&& (!StringUtil.isNullOrEmpty(inputUserId.value) || !StringUtil.isNullOrEmpty(inputUserId.desc))) {
|
||||
|
||||
|
||||
boolean success = messagesStore.updateSystemSetting(inputUserId.id, inputUserId.value, inputUserId.desc);
|
||||
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result;
|
||||
if (!success) {
|
||||
result = RestResult.resultOf(ErrorCode.ERROR_CODE_SERVER_ERROR);
|
||||
} else {
|
||||
result = RestResult.ok();
|
||||
}
|
||||
|
||||
response.setContent(new Gson().toJson(result));
|
||||
} else {
|
||||
response.setStatus(HttpResponseStatus.OK);
|
||||
RestResult result = RestResult.resultOf(ErrorCode.INVALID_PARAMETER);
|
||||
response.setContent(new Gson().toJson(result));
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Action处理单元
|
||||
*
|
||||
*
|
||||
* @author Looly
|
||||
*/
|
||||
abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttpRequest> {
|
||||
@@ -45,7 +45,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
try {
|
||||
//do filter
|
||||
boolean isPass = this.doFilter(request, response);
|
||||
|
||||
|
||||
if(isPass){
|
||||
//do action
|
||||
this.doAction(ctx, request, response);
|
||||
@@ -64,10 +64,10 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
ctx.fireExceptionCaught(e);
|
||||
ctx.close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
super.exceptionCaught(ctx, cause);
|
||||
@@ -75,7 +75,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
Channel channel = ctx.channel();
|
||||
if(channel.isActive())ctx.close();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------------------- Private method start
|
||||
/**
|
||||
* 执行过滤
|
||||
@@ -91,7 +91,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//自定义Path过滤器
|
||||
filter = ServerSetting.getFilter(request.getPath());
|
||||
if(null != filter){
|
||||
@@ -99,7 +99,7 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -110,6 +110,10 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
* @param response 响应对象
|
||||
*/
|
||||
private void doAction(ChannelHandlerContext ctx, Request request, Response response){
|
||||
if( "/route".equalsIgnoreCase(request.getPath()) && "OPTIONS".equalsIgnoreCase(request.getMethod())){
|
||||
handleOptions(ctx, request, response);
|
||||
return;
|
||||
}
|
||||
Action action;
|
||||
if (isValidePath(request.getPath())) {
|
||||
action = ServerSetting.getAction(request.getPath(), request.getMethod().toUpperCase());
|
||||
@@ -141,4 +145,11 @@ abstract public class ActionHandler extends SimpleChannelInboundHandler<FullHttp
|
||||
}
|
||||
}
|
||||
//---------------------------------------------------------------------------------------- Private method start
|
||||
|
||||
|
||||
private void handleOptions(ChannelHandlerContext ctx, Request request, Response response){
|
||||
response.setHeader("Access-Control-Allow-Origin", "*");
|
||||
response.setHeader("Access-Control-Allow-Headers", "*");
|
||||
response.send();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,13 +60,6 @@ public final class BrokerConstants {
|
||||
public static final String NETTY_SO_KEEPALIVE_PROPERTY_NAME = "netty.so_keepalive";
|
||||
public static final String NETTY_CHANNEL_TIMEOUT_SECONDS_PROPERTY_NAME = "netty.channel_timeout.seconds";
|
||||
public static final String NETTY_EPOLL_PROPERTY_NAME = "netty.epoll";
|
||||
public static final String METRICS_ENABLE_PROPERTY_NAME = "use_metrics";
|
||||
public static final String METRICS_LIBRATO_EMAIL_PROPERTY_NAME = "metrics.librato.email";
|
||||
public static final String METRICS_LIBRATO_TOKEN_PROPERTY_NAME = "metrics.librato.token";
|
||||
public static final String METRICS_LIBRATO_SOURCE_PROPERTY_NAME = "metrics.librato.source";
|
||||
|
||||
public static final String BUGSNAG_ENABLE_PROPERTY_NAME = "use_bugsnag";
|
||||
public static final String BUGSNAG_TOKEN_PROPERTY_NAME = "bugsnag.token";
|
||||
|
||||
public static final String STORAGE_CLASS_NAME = "storage_class";
|
||||
|
||||
@@ -103,7 +96,7 @@ public final class BrokerConstants {
|
||||
public static final String HTTP_SERVER_API_NO_CHECK_TIME = "http.admin.no_check_time";
|
||||
|
||||
public static final String CLIENT_PROTO_SECRET_KEY = "client.proto.secret_key";
|
||||
public static final String TOKEN_SECRET_KEY = "token.key ";
|
||||
public static final String TOKEN_SECRET_KEY = "token.key";
|
||||
|
||||
public static final String EMBED_DB_PROPERTY_NAME = "embed.db";
|
||||
|
||||
@@ -113,6 +106,12 @@ public final class BrokerConstants {
|
||||
|
||||
public static final String MESSAGE_Forward_Url = "message.forward.url";
|
||||
|
||||
public static final String MONGODB_Client_URI = "mongodb.client_uri";
|
||||
public static final String MONGODB_Database = "mongodb.database";
|
||||
public static final String MONGODB_Data_Expire_Days = "mongodb.data_expire_days";
|
||||
|
||||
public static final String MESSAGE_ROAMING = "message.roaming";
|
||||
public static final String MESSAGE_Remote_History_Message = "message.reomte_history_message";
|
||||
|
||||
|
||||
private BrokerConstants() {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class AddGroupMember extends GroupHandler<WFCMessage.AddGroupMemberReques
|
||||
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.AddGroupMemberRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = m_messagesStore.addGroupMembers(fromUser, request.getGroupId(), request.getAddedMemberList());
|
||||
ErrorCode errorCode = m_messagesStore.addGroupMembers(fromUser, isAdmin, request.getGroupId(), request.getAddedMemberList());
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import io.moquette.BrokerConstants;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.IMTopic;
|
||||
import win.liyufan.im.MessageShardingUtil;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ContentType.Text;
|
||||
|
||||
@Handler(value = IMTopic.BroadcastMessageTopic)
|
||||
public class BroadcastMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.Message message, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
if (message != null) {
|
||||
if (!isAdmin) { //only admin can broadcast message
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
long timestamp = System.currentTimeMillis();
|
||||
long messageId = MessageShardingUtil.generateId();
|
||||
message = message.toBuilder().setFromUser(fromUser).setMessageId(messageId).setServerTimestamp(timestamp).setConversation(WFCMessage.Conversation.newBuilder().setTarget(fromUser).setLine(message.getConversation().getLine()).setType(ProtoConstants.ConversationType.ConversationType_Private).build()).build();
|
||||
|
||||
long count = saveAndBroadcast(fromUser, clientID, message);
|
||||
ackPayload = ackPayload.capacity(20);
|
||||
ackPayload.writeLong(messageId);
|
||||
ackPayload.writeLong(count);
|
||||
} else {
|
||||
errorCode = ErrorCode.ERROR_CODE_INVALID_MESSAGE;
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,10 +14,18 @@ import io.netty.buffer.ByteBuf;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(IMTopic.DeleteFriendTopic)
|
||||
public class DeleteFriendHandler extends IMHandler<WFCMessage.IDBuf> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.IDBuf request, Qos1PublishHandler.IMCallback callback) {
|
||||
return m_messagesStore.deleteFriend(fromUser, request.getId());
|
||||
long[] head = new long[2];
|
||||
ErrorCode errorCode = m_messagesStore.deleteFriend(fromUser, request.getId(), head);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
publisher.publishNotification(IMTopic.NotifyFriendTopic, fromUser, head[0]);
|
||||
publisher.publishNotification(IMTopic.NotifyFriendTopic, request.getId(), head[1]);
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import com.xiaoleilu.loServer.model.FriendData;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
@@ -25,7 +26,11 @@ public class FriendPullHandler extends IMHandler<WFCMessage.Version> {
|
||||
WFCMessage.GetFriendsResult.Builder builder = WFCMessage.GetFriendsResult.newBuilder();
|
||||
for (FriendData data : friendDatas
|
||||
) {
|
||||
builder.addEntry(WFCMessage.Friend.newBuilder().setState(data.getState()).setUid(data.getFriendUid()).setUpdateDt(data.getTimestamp()).setAlias(data.getAlias()).build());
|
||||
WFCMessage.Friend.Builder builder1 = WFCMessage.Friend.newBuilder().setState(data.getState()).setUid(data.getFriendUid()).setUpdateDt(data.getTimestamp());
|
||||
if (!StringUtil.isNullOrEmpty(data.getAlias())) {
|
||||
builder1.setAlias(data.getAlias());
|
||||
}
|
||||
builder.addEntry(builder1.build());
|
||||
}
|
||||
byte[] data = builder.build().toByteArray();
|
||||
ackPayload.ensureWritable(data.length).writeBytes(data);
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import cn.wildfirechat.server.ThreadPoolExecutorWrapper;
|
||||
import com.google.gson.Gson;
|
||||
@@ -31,6 +32,8 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -205,9 +208,7 @@ abstract public class IMHandler<T> {
|
||||
}
|
||||
}
|
||||
|
||||
if(errorCode != ErrorCode.ERROR_CODE_ASYNC_HANDLER) {
|
||||
response(ackPayload, errorCode, callback);
|
||||
}
|
||||
response(ackPayload, errorCode, callback);
|
||||
} else {
|
||||
LOG.error("Handler {} preAction failure", this.getClass().getName());
|
||||
ByteBuf ackPayload = Unpooled.buffer(1);
|
||||
@@ -234,13 +235,37 @@ abstract public class IMHandler<T> {
|
||||
public void afterAction(String clientID, String fromUser, String topic, Qos1PublishHandler.IMCallback callback) {
|
||||
|
||||
}
|
||||
protected long publish(String username, String clientID, WFCMessage.Message message) {
|
||||
Set<String> notifyReceivers = new LinkedHashSet<>();
|
||||
|
||||
WFCMessage.Message.Builder messageBuilder = message.toBuilder();
|
||||
int pullType = m_messagesStore.getNotifyReceivers(username, messageBuilder, notifyReceivers);
|
||||
this.publisher.publish2Receivers(messageBuilder.build(), notifyReceivers, clientID, pullType);
|
||||
return notifyReceivers.size();
|
||||
}
|
||||
|
||||
protected long saveAndPublish(String username, String clientID, WFCMessage.Message message) {
|
||||
Set<String> notifyReceivers = new LinkedHashSet<>();
|
||||
|
||||
message = m_messagesStore.storeMessage(username, clientID, message);
|
||||
int pullType = m_messagesStore.getNotifyReceivers(username, message, notifyReceivers);
|
||||
this.publisher.publish2Receivers(message, notifyReceivers, clientID, pullType);
|
||||
return message.getMessageId();
|
||||
WFCMessage.Message.Builder messageBuilder = message.toBuilder();
|
||||
int pullType = m_messagesStore.getNotifyReceivers(username, messageBuilder, notifyReceivers);
|
||||
this.publisher.publish2Receivers(messageBuilder.build(), notifyReceivers, clientID, pullType);
|
||||
return notifyReceivers.size();
|
||||
}
|
||||
|
||||
protected long saveAndBroadcast(String username, String clientID, WFCMessage.Message message) {
|
||||
Set<String> notifyReceivers = m_messagesStore.getAllEnds();
|
||||
WFCMessage.Message updatedMessage = m_messagesStore.storeMessage(username, clientID, message);
|
||||
mServer.getImBusinessScheduler().execute(() -> publisher.publish2Receivers(updatedMessage, notifyReceivers, clientID, ProtoConstants.PullType.Pull_Normal));
|
||||
return notifyReceivers.size();
|
||||
}
|
||||
|
||||
protected long saveAndMulticast(String username, String clientID, WFCMessage.Message message, Collection<String> targets) {
|
||||
Set<String> notifyReceivers = new HashSet<>();
|
||||
notifyReceivers.addAll(targets);
|
||||
WFCMessage.Message updatedMessage = m_messagesStore.storeMessage(username, clientID, message);
|
||||
mServer.getImBusinessScheduler().execute(() -> publisher.publish2Receivers(updatedMessage, notifyReceivers, clientID, ProtoConstants.PullType.Pull_Normal));
|
||||
return notifyReceivers.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,20 +24,38 @@ public class KickoffGroupMember extends GroupHandler<WFCMessage.RemoveGroupMembe
|
||||
WFCMessage.GroupInfo groupInfo = m_messagesStore.getGroupInfo(request.getGroupId());
|
||||
if (groupInfo == null) {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
|
||||
} else if ((groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted)
|
||||
&& groupInfo.getOwner() != null && groupInfo.getOwner().equals(fromUser)) {
|
||||
|
||||
//send notify message first, then kickoff the member
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, groupInfo.getTargetId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, null, request.getRemovedMemberList()).getKickokfMemberGroupNotifyContent();
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||
}
|
||||
errorCode = m_messagesStore.kickoffGroupMembers(fromUser, request.getGroupId(), request.getRemovedMemberList());
|
||||
} else {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
boolean isAllow = isAdmin;
|
||||
if (!isAllow) {
|
||||
if (groupInfo.getOwner() != null) {
|
||||
if (request.getRemovedMemberList().contains(groupInfo.getOwner())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
if (groupInfo.getOwner() != null && groupInfo.getOwner().equals(fromUser)) {
|
||||
isAllow = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isAllow) {
|
||||
WFCMessage.GroupMember gm = m_messagesStore.getGroupMember(request.getGroupId(), fromUser);
|
||||
if (gm != null && gm.getType() == ProtoConstants.GroupMemberType.GroupMemberType_Manager) {
|
||||
isAllow = true;
|
||||
}
|
||||
}
|
||||
if (!isAllow && (groupInfo.getType() == ProtoConstants.GroupType.GroupType_Normal || groupInfo.getType() == ProtoConstants.GroupType.GroupType_Restricted)) {
|
||||
errorCode = ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
} else {
|
||||
//send notify message first, then kickoff the member
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, groupInfo.getTargetId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, null, request.getRemovedMemberList()).getKickokfMemberGroupNotifyContent();
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||
}
|
||||
errorCode = m_messagesStore.kickoffGroupMembers(fromUser, isAdmin, request.getGroupId(), request.getRemovedMemberList());
|
||||
}
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
@@ -14,16 +14,15 @@ import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.Modify_Group_Name;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.Modify_Group_Portrait;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ModifyGroupInfoType.*;
|
||||
import static win.liyufan.im.IMTopic.ModifyGroupInfoTopic;
|
||||
|
||||
@Handler(value = ModifyGroupInfoTopic)
|
||||
public class ModifyGroupInfoHandler extends GroupHandler<WFCMessage.ModifyGroupInfoRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.ModifyGroupInfoRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode= m_messagesStore.modifyGroupInfo(fromUser, request.getGroupId(), request.getType(), request.getValue());
|
||||
ErrorCode errorCode= m_messagesStore.modifyGroupInfo(fromUser, request.getGroupId(), request.getType(), request.getValue(), isAdmin);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
if(request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||
@@ -33,6 +32,14 @@ public class ModifyGroupInfoHandler extends GroupHandler<WFCMessage.ModifyGroupI
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupNameNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_Portrait) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, null, "").getChangeGroupPortraitNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_Mute) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupMuteNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_JoinType) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupJointypeNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_PrivateChat) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupPrivatechatNotifyContent();
|
||||
} else if(request.getType() == Modify_Group_Searchable) {
|
||||
content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getValue(), "").getChangeGroupSearchableNotifyContent();
|
||||
}
|
||||
|
||||
if (content != null) {
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.hazelcast.util.StringUtil;
|
||||
import io.moquette.BrokerConstants;
|
||||
import io.moquette.server.Server;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.IMTopic;
|
||||
import win.liyufan.im.MessageShardingUtil;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ContentType.Text;
|
||||
import static cn.wildfirechat.proto.ProtoConstants.ConversationType.ConversationType_Private;
|
||||
|
||||
@Handler(value = IMTopic.MultiCastMessageTopic)
|
||||
public class MultiCastMessageHandler extends IMHandler<WFCMessage.MultiCastMessage> {
|
||||
|
||||
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.MultiCastMessage multiCastMessage, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
if (!isAdmin) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
}
|
||||
|
||||
long timestamp = System.currentTimeMillis();
|
||||
long messageId = MessageShardingUtil.generateId();
|
||||
WFCMessage.Message message = WFCMessage.Message.newBuilder()
|
||||
.setContent(multiCastMessage.getContent())
|
||||
.setConversation(WFCMessage.Conversation.newBuilder().setTarget(fromUser).setType(ConversationType_Private).setLine(multiCastMessage.getLine()).build())
|
||||
.setFromUser(fromUser)
|
||||
.setMessageId(messageId)
|
||||
.setServerTimestamp(timestamp)
|
||||
.build();
|
||||
|
||||
saveAndMulticast(fromUser, clientID, message, multiCastMessage.getToList());
|
||||
|
||||
ackPayload = ackPayload.capacity(20);
|
||||
ackPayload.writeLong(messageId);
|
||||
ackPayload.writeLong(timestamp);
|
||||
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,19 +20,14 @@ import static win.liyufan.im.IMTopic.QuitGroupTopic;
|
||||
public class QuitGroupHandler extends GroupHandler<WFCMessage.QuitGroupRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.QuitGroupRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
WFCMessage.GroupInfo groupInfo = m_messagesStore.getGroupInfo(request.getGroupId());
|
||||
if (groupInfo == null) {
|
||||
errorCode = m_messagesStore.quitGroup(fromUser, request.getGroupId());
|
||||
} else {
|
||||
//send notify message first, then quit group
|
||||
ErrorCode errorCode = m_messagesStore.quitGroup(fromUser, request.getGroupId());
|
||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, groupInfo.getTargetId(), request.getToLineList(), request.getNotifyContent());
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, null, "").getQuitGroupNotifyContent();
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||
}
|
||||
errorCode = m_messagesStore.quitGroup(fromUser, request.getGroupId());
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Set;
|
||||
public class RecallMessageHandler extends IMHandler<WFCMessage.INT64Buf> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.INT64Buf int64Buf, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = m_messagesStore.recallMessage(int64Buf.getId(), fromUser);
|
||||
ErrorCode errorCode = m_messagesStore.recallMessage(int64Buf.getId(), fromUser, isAdmin);
|
||||
|
||||
if(errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
return errorCode;
|
||||
@@ -33,7 +33,11 @@ public class RecallMessageHandler extends IMHandler<WFCMessage.INT64Buf> {
|
||||
return ErrorCode.ERROR_CODE_NOT_EXIST;
|
||||
}
|
||||
|
||||
m_messagesStore.getNotifyReceivers(fromUser, message, notifyReceivers);
|
||||
publish(fromUser, clientID, message);
|
||||
|
||||
|
||||
//等待客户端实现根据撤回消息更新内容,之后可以删掉这段代码
|
||||
m_messagesStore.getNotifyReceivers(fromUser, message.toBuilder(), notifyReceivers);
|
||||
this.publisher.publishRecall2Receivers(int64Buf.getId(), fromUser, notifyReceivers, clientID);
|
||||
|
||||
return errorCode;
|
||||
|
||||
@@ -46,6 +46,10 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
ErrorCode errorCode = ErrorCode.ERROR_CODE_SUCCESS;
|
||||
if (message != null) {
|
||||
if (!isAdmin) { //admin do not check the right
|
||||
// 不能在端上直接发送撤回和群通知
|
||||
if (message.getContent().getType() == 80 || (message.getContent().getType() >= 100 && message.getContent().getType() < 200)) {
|
||||
return ErrorCode.INVALID_PARAMETER;
|
||||
}
|
||||
int userStatus = m_messagesStore.getUserStatus(fromUser);
|
||||
if (userStatus == 1 || userStatus == 2) {
|
||||
return ErrorCode.ERROR_CODE_FORBIDDEN_SEND_MSG;
|
||||
@@ -58,14 +62,19 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
}
|
||||
|
||||
|
||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group && !m_messagesStore.isMemberInGroup(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_GROUP;
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group && m_messagesStore.isForbiddenInGroup(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_RIGHT;
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_ChatRoom && !m_messagesStore.checkUserClientInChatroom(fromUser, clientID, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHATROOM;
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel && !m_messagesStore.checkUserInChannel(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||
if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Group ) {
|
||||
errorCode = m_messagesStore.canSendMessageInGroup(fromUser, message.getConversation().getTarget());
|
||||
if (errorCode != ErrorCode.ERROR_CODE_SUCCESS) {
|
||||
return errorCode;
|
||||
}
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_ChatRoom) {
|
||||
if(!m_messagesStore.checkUserClientInChatroom(fromUser, clientID, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHATROOM;
|
||||
}
|
||||
} else if (message.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Channel) {
|
||||
if(!m_messagesStore.checkUserInChannel(fromUser, message.getConversation().getTarget())) {
|
||||
return ErrorCode.ERROR_CODE_NOT_IN_CHANNEL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,17 +90,20 @@ public class SendMessageHandler extends IMHandler<WFCMessage.Message> {
|
||||
if (!isAdmin && message.getContent().getType() == Text) {
|
||||
Set<String> matched = m_messagesStore.handleSensitiveWord(message.getContent().getSearchableContent());
|
||||
if (matched != null && !matched.isEmpty()) {
|
||||
m_messagesStore.storeSensitiveMessage(message);
|
||||
if (mSensitiveType == 0) {
|
||||
errorCode = ErrorCode.ERROR_CODE_SENSITIVE_MATCHED;
|
||||
} else if(mSensitiveType == 1) {
|
||||
ignoreMsg = true;
|
||||
} else {
|
||||
} else if(mSensitiveType == 2) {
|
||||
String text = message.getContent().getSearchableContent();
|
||||
for (String word : matched) {
|
||||
text = text.replace(word, "***");
|
||||
}
|
||||
|
||||
message = message.toBuilder().setContent(message.getContent().toBuilder().setSearchableContent(text).build()).build();
|
||||
} else if(mSensitiveType == 3) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <[email protected]>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package io.moquette.imhandler;
|
||||
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
import cn.wildfirechat.pojos.GroupNotificationBinaryContent;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.moquette.spi.impl.Qos1PublishHandler;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import win.liyufan.im.IMTopic;
|
||||
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
@Handler(IMTopic.SetGroupManagerTopic)
|
||||
public class SetGroupManagerHandler extends GroupHandler<WFCMessage.SetGroupManagerRequest> {
|
||||
@Override
|
||||
public ErrorCode action(ByteBuf ackPayload, String clientID, String fromUser, boolean isAdmin, WFCMessage.SetGroupManagerRequest request, Qos1PublishHandler.IMCallback callback) {
|
||||
ErrorCode errorCode = m_messagesStore.setGroupManager(fromUser, request.getGroupId(), request.getType(), request.getUserIdList(), isAdmin);
|
||||
if (errorCode == ERROR_CODE_SUCCESS) {
|
||||
if (request.hasNotifyContent() && request.getNotifyContent().getType() > 0) {
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), request.getNotifyContent());
|
||||
} else {
|
||||
WFCMessage.MessageContent content = new GroupNotificationBinaryContent(request.getGroupId(), fromUser, request.getType() + "", request.getUserIdList()).getSetGroupManagerNotifyContent();
|
||||
sendGroupNotification(fromUser, request.getGroupId(), request.getToLineList(), content);
|
||||
}
|
||||
}
|
||||
return errorCode;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class UploadDeviceTokenHandler extends IMHandler<WFCMessage.UploadDeviceT
|
||||
session.setAppName(request.getAppName());
|
||||
if (request.getPlatform() == ProtoConstants.Platform.Platform_iOS && request.getPushType() == 2) {
|
||||
session.setVoipDeviceToken(request.getDeviceToken());
|
||||
session.setPushType(0);//如果有voip token,肯定是生产环境的推送
|
||||
// session.setPushType(0);//如果有voip token,肯定是生产环境的推送
|
||||
m_sessionsStore.updateSessionToken(session, true);
|
||||
} else {
|
||||
session.setDeviceToken(request.getDeviceToken());
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
package io.moquette.persistence;
|
||||
|
||||
import cn.wildfirechat.pojos.SystemSettingPojo;
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import cn.wildfirechat.server.ThreadPoolExecutorWrapper;
|
||||
@@ -76,6 +77,79 @@ public class DatabaseStore {
|
||||
return out;
|
||||
}
|
||||
|
||||
boolean updateSystemSetting(int id, String value, String desc) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "insert into t_settings " +
|
||||
" (`id`, `value`, `desc`) values(?, ?, ?)" +
|
||||
" ON DUPLICATE KEY UPDATE " +
|
||||
"`value` = ?," +
|
||||
"`desc` = ?";
|
||||
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
int index = 1;
|
||||
statement.setLong(index++, id);
|
||||
statement.setString(index++, value);
|
||||
statement.setString(index++, desc);
|
||||
statement.setString(index++, value);
|
||||
statement.setString(index++, desc);
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
return true;
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
SystemSettingPojo getSystemSetting(int id) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "select `value`, `desc` from t_settings where `id` = ?";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
int index = 1;
|
||||
statement.setLong(index++, id);
|
||||
|
||||
rs = statement.executeQuery();
|
||||
while (rs.next()) {
|
||||
SystemSettingPojo out = new SystemSettingPojo();
|
||||
index = 1;
|
||||
|
||||
out.id = id;
|
||||
|
||||
String value = rs.getString(index++);
|
||||
value = (value == null ? "" : value);
|
||||
out.value = value;
|
||||
|
||||
value = rs.getString(index++);
|
||||
value = (value == null ? "" : value);
|
||||
out.desc = value;
|
||||
|
||||
return out;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement, rs);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
List<WFCMessage.User> searchUserFromDB(String keyword, boolean buzzy, int page) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
@@ -97,9 +171,9 @@ public class DatabaseStore {
|
||||
", `_extra`" +
|
||||
", `_dt` from t_user";
|
||||
if (buzzy) {
|
||||
sql += " where `_display_name` like ?";
|
||||
sql += " where (`_display_name` like ? or `_name` = ? or `_mobile` = ?) ";
|
||||
} else {
|
||||
sql += " where `_display_name` = ?";
|
||||
sql += " where (`_display_name` = ? or `_name` = ? or `_mobile` = ?) ";
|
||||
}
|
||||
|
||||
sql += " and _type <> 2"; //can search normal user(0) and robot(1), can not search things
|
||||
@@ -118,6 +192,8 @@ public class DatabaseStore {
|
||||
} else {
|
||||
statement.setString(index++, keyword);
|
||||
}
|
||||
statement.setString(index++, keyword);
|
||||
statement.setString(index++, keyword);
|
||||
|
||||
rs = statement.executeQuery();
|
||||
while (rs.next()) {
|
||||
@@ -208,23 +284,27 @@ public class DatabaseStore {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void reloadGroupMemberFromDB(HazelcastInstance hzInstance) {
|
||||
synchronized Collection<WFCMessage.GroupMember> reloadGroupMemberFromDB(HazelcastInstance hzInstance, String groupId) {
|
||||
MultiMap<String, WFCMessage.GroupMember> groupMembers = hzInstance.getMultiMap(MemoryMessagesStore.GROUP_MEMBERS);
|
||||
if (groupMembers.get(groupId).size() > 0) {
|
||||
return groupMembers.get(groupId);
|
||||
}
|
||||
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "select `_gid`" +
|
||||
", `_mid`" +
|
||||
String sql = "select `_mid`" +
|
||||
", `_alias`" +
|
||||
", `_type`" +
|
||||
", `_dt` from t_group_member";
|
||||
", `_dt` from t_group_member where _gid = ?";
|
||||
statement = connection.prepareStatement(sql);
|
||||
|
||||
statement.setString(1, groupId);
|
||||
int index;
|
||||
|
||||
|
||||
rs = statement.executeQuery();
|
||||
while (rs.next()) {
|
||||
WFCMessage.GroupMember.Builder builder = WFCMessage.GroupMember.newBuilder();
|
||||
@@ -232,10 +312,6 @@ public class DatabaseStore {
|
||||
|
||||
String value = rs.getString(index++);
|
||||
value = (value == null ? "" : value);
|
||||
String groupId = value;
|
||||
|
||||
value = rs.getString(index++);
|
||||
value = (value == null ? "" : value);
|
||||
builder.setMemberId(value);
|
||||
|
||||
value = rs.getString(index++);
|
||||
@@ -252,6 +328,7 @@ public class DatabaseStore {
|
||||
WFCMessage.GroupMember member = builder.build();
|
||||
groupMembers.put(groupId, member);
|
||||
}
|
||||
return groupMembers.get(groupId);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -259,6 +336,7 @@ public class DatabaseStore {
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement, rs);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
void reloadFriendsFromDB(HazelcastInstance hzInstance) {
|
||||
@@ -382,11 +460,12 @@ public class DatabaseStore {
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "insert into " + MessageShardingUtil.getMessageTable(message.getMessageId()) +
|
||||
" (`_mid`, `_from`, `_type`, `_target`, `_line`, `_data`, `_searchable_key`, `_dt`) values(?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
" (`_mid`, `_from`, `_type`, `_target`, `_line`, `_data`, `_searchable_key`, `_dt`, `_content_type`) values(?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
" ON DUPLICATE KEY UPDATE " +
|
||||
"`_data` = ?," +
|
||||
"`_searchable_key` = ?," +
|
||||
"`_dt` = ?";
|
||||
"`_dt` = ?," +
|
||||
"`_content_type` = ?";
|
||||
|
||||
String searchableContent = message.getContent().getSearchableContent() == null ? "" : message.getContent().getSearchableContent();
|
||||
|
||||
@@ -402,10 +481,63 @@ public class DatabaseStore {
|
||||
statement.setBlob(index++, blob);
|
||||
statement.setString(index++, searchableContent);
|
||||
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
||||
statement.setInt(index++, message.getContent().getType());
|
||||
|
||||
statement.setBlob(index++, blob);
|
||||
statement.setString(index++, searchableContent);
|
||||
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
||||
statement.setInt(index++, message.getContent().getType());
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void persistSensitiveMessage(final WFCMessage.Message message) {
|
||||
if(message.getContent().getPersistFlag() == Transparent) {
|
||||
return;
|
||||
}
|
||||
|
||||
mScheduler.execute(()-> {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "insert into " + "t_sensitive_messages" +
|
||||
" (`_mid`, `_from`, `_type`, `_target`, `_line`, `_data`, `_searchable_key`, `_dt`, `_content_type`) values(?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
" ON DUPLICATE KEY UPDATE " +
|
||||
"`_data` = ?," +
|
||||
"`_searchable_key` = ?," +
|
||||
"`_dt` = ?," +
|
||||
"`_content_type` = ?";
|
||||
|
||||
String searchableContent = message.getContent().getSearchableContent() == null ? "" : message.getContent().getSearchableContent();
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
int index = 1;
|
||||
statement.setLong(index++, message.getMessageId());
|
||||
statement.setString(index++, message.getFromUser());
|
||||
statement.setInt(index++, message.getConversation().getType());
|
||||
statement.setString(index++, message.getConversation().getTarget());
|
||||
statement.setInt(index++, message.getConversation().getLine());
|
||||
Blob blob = connection.createBlob();
|
||||
blob.setBytes(1, message.getContent().toByteArray());
|
||||
statement.setBlob(index++, blob);
|
||||
statement.setString(index++, searchableContent);
|
||||
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
||||
statement.setInt(index++, message.getContent().getType());
|
||||
|
||||
statement.setBlob(index++, blob);
|
||||
statement.setString(index++, searchableContent);
|
||||
statement.setTimestamp(index++, new Timestamp(message.getServerTimestamp()));
|
||||
statement.setInt(index++, message.getContent().getType());
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
@@ -536,6 +668,25 @@ public class DatabaseStore {
|
||||
return null;
|
||||
}
|
||||
|
||||
void deleteMessage(long messageId) {
|
||||
String sql = "delete from " + MessageShardingUtil.getMessageTable(messageId) + " where _mid = ?";
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.setLong(1, messageId);
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
}
|
||||
|
||||
List<WFCMessage.Message> loadRemoteMessages(String user, WFCMessage.Conversation conversation, long beforeUid, int count) {
|
||||
List<WFCMessage.Message> messages = loadRemoteMessagesFromTable(user, conversation, beforeUid, count, MessageShardingUtil.getMessageTable(beforeUid));
|
||||
if (messages != null && messages.size() < count) {
|
||||
@@ -632,6 +783,43 @@ public class DatabaseStore {
|
||||
});
|
||||
}
|
||||
|
||||
void removeFavGroup(final String groupId, final List<String> memberIds) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
|
||||
StringBuilder sb = new StringBuilder("update t_user_setting set _value = ?, _dt = ? where _uid in (");
|
||||
for (int i = 0; i < memberIds.size(); i++) {
|
||||
sb.append("?");
|
||||
if (i != memberIds.size() - 1) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
sb.append(")");
|
||||
|
||||
sb.append(" and _scope = 6 and _key = ?");
|
||||
|
||||
statement = connection.prepareStatement(sb.toString());
|
||||
int index = 1;
|
||||
statement.setString(index++, "0");
|
||||
statement.setLong(index++, System.currentTimeMillis());
|
||||
for (int i = 0; i < memberIds.size(); i++) {
|
||||
statement.setString(index++, memberIds.get(i));
|
||||
}
|
||||
statement.setString(index++, groupId);
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
}
|
||||
|
||||
void persistUserSetting(final String userId, WFCMessage.UserSettingEntry entry) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
@@ -723,6 +911,41 @@ public class DatabaseStore {
|
||||
}
|
||||
|
||||
|
||||
void removeGroupUserSettings(String groupId, List<String> users) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
|
||||
StringBuilder sb = new StringBuilder("delete from t_user_setting where _scope in (1,3,5,7) and _uid in (");
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
sb.append("?");
|
||||
if (i != users.size() - 1) {
|
||||
sb.append(",");
|
||||
}
|
||||
}
|
||||
sb.append(") and _key like '1-_-");
|
||||
sb.append(groupId);
|
||||
sb.append("'");
|
||||
|
||||
|
||||
statement = connection.prepareStatement(sb.toString());
|
||||
int index = 1;
|
||||
for (String userId:users) {
|
||||
statement.setString(index++, userId);
|
||||
}
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
}
|
||||
|
||||
void persistGroupInfo(final WFCMessage.GroupInfo groupInfo) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
@@ -737,7 +960,11 @@ public class DatabaseStore {
|
||||
", `_extra`" +
|
||||
", `_dt`" +
|
||||
", `_member_count`" +
|
||||
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
", `_mute`" +
|
||||
", `_join_type`" +
|
||||
", `_private_chat`" +
|
||||
", `_searchable`" +
|
||||
", `_member_dt`) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" +
|
||||
" ON DUPLICATE KEY UPDATE " +
|
||||
"`_name` = ?," +
|
||||
"`_portrait` = ?," +
|
||||
@@ -746,6 +973,10 @@ public class DatabaseStore {
|
||||
"`_extra` = ?," +
|
||||
"`_dt` = ?," +
|
||||
"`_member_count` = ?," +
|
||||
"`_mute` = ?" +
|
||||
", `_join_type` = ?" +
|
||||
", `_private_chat` = ?" +
|
||||
", `_searchable` = ?, " +
|
||||
"`_member_dt` = ?";
|
||||
|
||||
|
||||
@@ -760,6 +991,10 @@ public class DatabaseStore {
|
||||
statement.setString(index++, groupInfo.getExtra());
|
||||
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||
statement.setInt(index++, groupInfo.getMemberCount());
|
||||
statement.setInt(index++, groupInfo.getMute());
|
||||
statement.setInt(index++, groupInfo.getJoinType());
|
||||
statement.setInt(index++, groupInfo.getPrivateChat());
|
||||
statement.setInt(index++, groupInfo.getSearchable());
|
||||
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||
|
||||
statement.setString(index++, groupInfo.getName());
|
||||
@@ -769,6 +1004,10 @@ public class DatabaseStore {
|
||||
statement.setString(index++, groupInfo.getExtra());
|
||||
statement.setLong(index++, groupInfo.getUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||
statement.setInt(index++, groupInfo.getMemberCount());
|
||||
statement.setInt(index++, groupInfo.getMute());
|
||||
statement.setInt(index++, groupInfo.getJoinType());
|
||||
statement.setInt(index++, groupInfo.getPrivateChat());
|
||||
statement.setInt(index++, groupInfo.getSearchable());
|
||||
statement.setLong(index++, groupInfo.getMemberUpdateDt() == 0 ? System.currentTimeMillis() : groupInfo.getUpdateDt());
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
@@ -914,7 +1153,7 @@ public class DatabaseStore {
|
||||
statement.setInt(index++, request.getPlatform());
|
||||
}
|
||||
if (session.getPushType() != request.getPushType()) {
|
||||
statement.setInt(index++, request.getPushType());
|
||||
statement.setInt(index++, request.getPushType() >= 32 ? 0 : request.getPushType());
|
||||
}
|
||||
if (!strEqual(session.getDeviceName(), request.getDeviceName())) {
|
||||
statement.setString(index++, request.getDeviceName());
|
||||
@@ -1026,7 +1265,6 @@ public class DatabaseStore {
|
||||
}
|
||||
|
||||
void persistGroupMember(final String groupId, final List<WFCMessage.GroupMember> memberList) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -1082,7 +1320,70 @@ public class DatabaseStore {
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
int removeGroupMember(String groupId, List<String> groupMembers) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
PreparedStatement statement2 = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
connection.setAutoCommit(false);
|
||||
|
||||
StringBuilder sqlBuilder = new StringBuilder("update t_group_member set `_type` = ?, `_dt` = ? where `_mid` in (");
|
||||
for (int i = 0; i < groupMembers.size(); i++) {
|
||||
sqlBuilder.append("?");
|
||||
if (i != groupMembers.size()-1) {
|
||||
sqlBuilder.append(",");
|
||||
}
|
||||
}
|
||||
sqlBuilder.append(")");
|
||||
|
||||
sqlBuilder.append(" and _gid = ?");
|
||||
|
||||
statement = connection.prepareStatement(sqlBuilder.toString());
|
||||
|
||||
int index = 1;
|
||||
long current = System.currentTimeMillis();
|
||||
statement.setInt(index++, ProtoConstants.GroupMemberType.GroupMemberType_Removed);
|
||||
statement.setLong(index++, current);
|
||||
|
||||
for (String memberId:groupMembers) {
|
||||
statement.setString(index++, memberId);
|
||||
}
|
||||
statement.setString(index++, groupId);
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
|
||||
String sql = "update t_group set `_member_count` = `_member_count` - ?, `_member_dt` = ? , `_dt` = ? where `_gid` = ?";
|
||||
|
||||
statement2 = connection.prepareStatement(sql);
|
||||
index = 1;
|
||||
statement2.setInt(index++, count);
|
||||
statement2.setLong(index++, current);
|
||||
statement2.setLong(index++, current);
|
||||
statement2.setString(index++, groupId);
|
||||
statement2.executeUpdate();
|
||||
connection.commit();
|
||||
connection.setAutoCommit(true);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
if (connection != null) {
|
||||
try {
|
||||
connection.commit();
|
||||
connection.setAutoCommit(true);
|
||||
} catch (SQLException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
DBUtil.closeDB(connection, statement2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
WFCMessage.GroupInfo getPersistGroupInfo(String groupId) {
|
||||
@@ -1099,6 +1400,10 @@ public class DatabaseStore {
|
||||
", `_dt`" +
|
||||
", `_member_count`" +
|
||||
", `_member_dt`" +
|
||||
", `_mute`" +
|
||||
", `_join_type`" +
|
||||
", `_private_chat`" +
|
||||
", `_searchable`" +
|
||||
" from t_group where `_gid` = ?";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
@@ -1134,18 +1439,27 @@ public class DatabaseStore {
|
||||
strValue = (strValue == null ? "" : strValue);
|
||||
builder.setExtra(strValue);
|
||||
|
||||
|
||||
|
||||
long longValue = rs.getLong(index++);
|
||||
builder.setUpdateDt(longValue);
|
||||
|
||||
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setMemberCount(intValue);
|
||||
|
||||
longValue = rs.getLong(index++);
|
||||
builder.setMemberUpdateDt(longValue);
|
||||
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setMute(intValue);
|
||||
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setJoinType(intValue);
|
||||
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setPrivateChat(intValue);
|
||||
|
||||
intValue = rs.getInt(index++);
|
||||
builder.setSearchable(intValue);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
@@ -1490,7 +1804,6 @@ public class DatabaseStore {
|
||||
|
||||
void updateUser(final WFCMessage.User user) {
|
||||
LOG.info("Database update user info {} {}", user.getUid(), user.getUpdateDt());
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
LOG.info("Database update user info {}", user.getDisplayName());
|
||||
@@ -1555,6 +1868,26 @@ public class DatabaseStore {
|
||||
statement.setInt(index++, user.getType());
|
||||
statement.setLong(index++, user.getUpdateDt() == 0 ? System.currentTimeMillis() : user.getUpdateDt());
|
||||
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
}
|
||||
|
||||
void deleteUserStatus(String userId) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "delete from t_user_status where _uid = ?";
|
||||
statement = connection.prepareStatement(sql);
|
||||
statement.setString(1, userId);
|
||||
int count = statement.executeUpdate();
|
||||
LOG.info("Update rows {}", count);
|
||||
} catch (SQLException e) {
|
||||
@@ -1774,6 +2107,33 @@ public class DatabaseStore {
|
||||
return null;
|
||||
}
|
||||
|
||||
Set<String> getAllEnds() {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "select distinct(`_uid`) from t_user_session";
|
||||
statement = connection.prepareStatement(sql);
|
||||
|
||||
|
||||
|
||||
rs = statement.executeQuery();
|
||||
Set<String> out = new HashSet<>();
|
||||
while (rs.next()) {
|
||||
String uid = rs.getString(1);
|
||||
out.add(uid);
|
||||
}
|
||||
return out;
|
||||
} catch (SQLException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
Utility.printExecption(LOG, e);
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement, rs);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
List<FriendData> getPersistFriends(String userId) {
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
@@ -1874,7 +2234,6 @@ public class DatabaseStore {
|
||||
}
|
||||
|
||||
void persistFriendRequestUnreadStatus(String userId, long readDt, long updateDt) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -1901,11 +2260,9 @@ public class DatabaseStore {
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
//
|
||||
void persistOrUpdateFriendRequest(final WFCMessage.FriendRequest request) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -1942,11 +2299,9 @@ public class DatabaseStore {
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void persistOrUpdateFriendData(final FriendData request) {
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -1977,7 +2332,6 @@ public class DatabaseStore {
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
boolean removeGroupInfoFromDB(String groupId) {
|
||||
@@ -2025,7 +2379,6 @@ public class DatabaseStore {
|
||||
|
||||
void updateChannelInfo(final WFCMessage.ChannelInfo channelInfo) {
|
||||
LOG.info("Database update channel info {} {}", channelInfo.getTargetId(), channelInfo.getUpdateDt());
|
||||
mScheduler.execute(()->{
|
||||
Connection connection = null;
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@@ -2088,7 +2441,6 @@ public class DatabaseStore {
|
||||
} finally {
|
||||
DBUtil.closeDB(connection, statement);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void removeChannelInfo(final String channelId) {
|
||||
@@ -2414,7 +2766,7 @@ public class DatabaseStore {
|
||||
|
||||
try {
|
||||
connection = DBUtil.getConnection();
|
||||
String sql = "select `_word` from t_sensitiveword";
|
||||
String sql = "select `_word` from t_sensitiveword order by `id` desc";
|
||||
|
||||
statement = connection.prepareStatement(sql);
|
||||
rs = statement.executeQuery();
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,6 +23,7 @@ import io.moquette.spi.ClientSession;
|
||||
import io.moquette.spi.IMessagesStore.StoredMessage;
|
||||
import io.moquette.spi.ISessionsStore;
|
||||
|
||||
import io.netty.handler.codec.mqtt.MqttVersion;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import cn.wildfirechat.common.ErrorCode;
|
||||
@@ -49,6 +50,8 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
|
||||
private volatile int unReceivedMsgs;
|
||||
|
||||
private MqttVersion mqttVersion = MqttVersion.MQTT_3_1_1;
|
||||
|
||||
public long getLastActiveTime() {
|
||||
return lastActiveTime;
|
||||
}
|
||||
@@ -230,7 +233,13 @@ public class MemorySessionStore implements ISessionsStore {
|
||||
}
|
||||
|
||||
|
||||
|
||||
public MqttVersion getMqttVersion() {
|
||||
return mqttVersion;
|
||||
}
|
||||
|
||||
public void setMqttVersion(MqttVersion mqttVersion) {
|
||||
this.mqttVersion = mqttVersion;
|
||||
}
|
||||
}
|
||||
|
||||
private final Map<String, Session> sessions = new ConcurrentHashMap<>();
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RPCCenter {
|
||||
info.future.cancel(true);
|
||||
if (info.callback != null) {
|
||||
info.callback.getResponseExecutor().execute(() -> {
|
||||
if (errorCode == 0) {
|
||||
if (errorCode == 0 || errorCode == ErrorCode.ERROR_CODE_SUCCESS_GZIPED.getCode()) {
|
||||
info.callback.onSuccess(message);
|
||||
} else {
|
||||
info.callback.onError(ErrorCode.fromCode(errorCode));
|
||||
|
||||
@@ -27,7 +27,7 @@ public class UserStatusLoader implements MapStore<String, Integer> {
|
||||
|
||||
@Override
|
||||
public void delete(String s) {
|
||||
getDatabaseStore().deleteUser(s);
|
||||
getDatabaseStore().deleteUserStatus(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2017 The original author or authors
|
||||
* ------------------------------------------------------
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Apache License v2.0 which accompanies this distribution.
|
||||
*
|
||||
* The Eclipse Public License is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* The Apache License v2.0 is available at
|
||||
* http://www.opensource.org/licenses/apache2.0.php
|
||||
*
|
||||
* You may elect to redistribute this code under either of these licenses.
|
||||
*/
|
||||
package io.moquette.server.netty;
|
||||
|
||||
import com.bugsnag.Bugsnag;
|
||||
import io.moquette.server.config.IConfig;
|
||||
import io.netty.channel.ChannelHandler.Sharable;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
|
||||
import static io.moquette.BrokerConstants.BUGSNAG_TOKEN_PROPERTY_NAME;
|
||||
|
||||
@Sharable
|
||||
public class BugSnagErrorsHandler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
private Bugsnag bugsnag;
|
||||
|
||||
public void init(IConfig props) {
|
||||
final String token = props.getProperty(BUGSNAG_TOKEN_PROPERTY_NAME);
|
||||
this.bugsnag = new Bugsnag(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
|
||||
bugsnag.notify(cause);
|
||||
ctx.fireExceptionCaught(cause);
|
||||
}
|
||||
}
|
||||
@@ -139,25 +139,11 @@ public class NettyAcceptor implements ServerAcceptor {
|
||||
|
||||
final NettyMQTTHandler mqttHandler = new NettyMQTTHandler(processor);
|
||||
|
||||
final boolean useFineMetrics = Boolean.parseBoolean(props.getProperty(METRICS_ENABLE_PROPERTY_NAME, "false"));
|
||||
if (useFineMetrics) {
|
||||
DropWizardMetricsHandler metricsHandler = new DropWizardMetricsHandler();
|
||||
metricsHandler.init(props);
|
||||
this.metrics = Optional.of(metricsHandler);
|
||||
} else {
|
||||
this.metrics = Optional.empty();
|
||||
}
|
||||
this.metrics = Optional.empty();
|
||||
|
||||
this.errorsCather = Optional.empty();
|
||||
|
||||
final boolean useBugSnag = Boolean.parseBoolean(props.getProperty(BUGSNAG_ENABLE_PROPERTY_NAME, "false"));
|
||||
if (useBugSnag) {
|
||||
BugSnagErrorsHandler bugSnagHandler = new BugSnagErrorsHandler();
|
||||
bugSnagHandler.init(props);
|
||||
this.errorsCather = Optional.of(bugSnagHandler);
|
||||
} else {
|
||||
this.errorsCather = Optional.empty();
|
||||
}
|
||||
initializePlainTCPTransport(mqttHandler, props);
|
||||
initializeWebSocketTransport(mqttHandler, props);
|
||||
String sslTcpPortProp = props.getProperty(BrokerConstants.SSL_PORT_PROPERTY_NAME);
|
||||
String wssPortProp = props.getProperty(BrokerConstants.WSS_PORT_PROPERTY_NAME);
|
||||
if (sslTcpPortProp != null || wssPortProp != null) {
|
||||
@@ -239,42 +225,6 @@ public class NettyAcceptor implements ServerAcceptor {
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeWebSocketTransport(final NettyMQTTHandler handler, IConfig props) throws IOException {
|
||||
LOG.info("Configuring Websocket MQTT transport");
|
||||
String webSocketPortProp = props.getProperty(WEB_SOCKET_PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
|
||||
if (DISABLED_PORT_BIND.equals(webSocketPortProp)) {
|
||||
// Do nothing no WebSocket configured
|
||||
LOG.info("Property {} has been setted to {}. Websocket MQTT will be disabled",
|
||||
BrokerConstants.WEB_SOCKET_PORT_PROPERTY_NAME, DISABLED_PORT_BIND);
|
||||
return;
|
||||
}
|
||||
int port = Integer.parseInt(webSocketPortProp);
|
||||
|
||||
final MoquetteIdleTimeoutHandler timeoutHandler = new MoquetteIdleTimeoutHandler();
|
||||
|
||||
String host = props.getProperty(BrokerConstants.HOST_PROPERTY_NAME);
|
||||
initFactory(host, port, "Websocket MQTT", new PipelineInitializer() {
|
||||
|
||||
@Override
|
||||
void init(ChannelPipeline pipeline) {
|
||||
pipeline.addLast(new HttpServerCodec());
|
||||
pipeline.addLast("aggregator", new HttpObjectAggregator(65536));
|
||||
pipeline.addLast("webSocketHandler",
|
||||
new WebSocketServerProtocolHandler("/org/fusesource/mqtt", MQTT_SUBPROTOCOL_CSV_LIST));
|
||||
pipeline.addLast("ws2bytebufDecoder", new WebSocketFrameToByteBufDecoder());
|
||||
pipeline.addLast("bytebuf2wsEncoder", new ByteBufToWebSocketFrameEncoder());
|
||||
pipeline.addFirst("idleStateHandler", new IdleStateHandler(nettyChannelTimeoutSeconds, 0, 0));
|
||||
pipeline.addAfter("idleStateHandler", "idleEventHandler", timeoutHandler);
|
||||
pipeline.addFirst("bytemetrics", new BytesMetricsHandler(m_bytesMetricsCollector));
|
||||
pipeline.addLast("decoder", new MqttDecoder());
|
||||
pipeline.addLast("encoder", MqttEncoder.INSTANCE);
|
||||
pipeline.addLast("metrics", new MessageMetricsHandler(m_metricsCollector));
|
||||
pipeline.addLast("messageLogger", new MQTTMessageLogger());
|
||||
pipeline.addLast("handler", handler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initializeSSLTCPTransport(final NettyMQTTHandler handler, IConfig props, final SSLContext sslContext)
|
||||
throws IOException {
|
||||
LOG.info("Configuring SSL MQTT transport");
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package io.moquette.server.netty.metrics;
|
||||
|
||||
import io.moquette.server.netty.NettyUtils;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.channel.ChannelDuplexHandler;
|
||||
@@ -23,10 +24,15 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.util.Attribute;
|
||||
import io.netty.util.AttributeKey;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static io.moquette.server.netty.NettyUtils.ATTR_USERNAME;
|
||||
|
||||
public class BytesMetricsHandler extends ChannelDuplexHandler {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(BytesMetricsHandler.class);
|
||||
private static final AttributeKey<BytesMetrics> ATTR_KEY_METRICS = AttributeKey.valueOf("BytesMetrics");
|
||||
private static final AttributeKey<String> ATTR_KEY_USERNAME = AttributeKey.valueOf(ATTR_USERNAME);
|
||||
|
||||
private BytesMetricsCollector m_collector;
|
||||
|
||||
@@ -59,6 +65,12 @@ public class BytesMetricsHandler extends ChannelDuplexHandler {
|
||||
@Override
|
||||
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
BytesMetrics metrics = ctx.channel().attr(ATTR_KEY_METRICS).get();
|
||||
String userId = ctx.channel().attr(ATTR_KEY_USERNAME).get();
|
||||
if (userId == null) {
|
||||
userId = "";
|
||||
}
|
||||
|
||||
LOG.info("channel<{}> closing after read {} bytes and wrote {} bytes", userId, metrics.readBytes(), metrics.wroteBytes());
|
||||
m_collector.sumReadBytes(metrics.readBytes());
|
||||
m_collector.sumWroteBytes(metrics.wroteBytes());
|
||||
super.close(ctx, promise);
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2012-2017 The original author or authors
|
||||
* ------------------------------------------------------
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* and Apache License v2.0 which accompanies this distribution.
|
||||
*
|
||||
* The Eclipse Public License is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* The Apache License v2.0 is available at
|
||||
* http://www.opensource.org/licenses/apache2.0.php
|
||||
*
|
||||
* You may elect to redistribute this code under either of these licenses.
|
||||
*/
|
||||
package io.moquette.server.netty.metrics;
|
||||
|
||||
import com.codahale.metrics.Counter;
|
||||
import com.codahale.metrics.Meter;
|
||||
import com.codahale.metrics.MetricRegistry;
|
||||
import com.librato.metrics.reporter.Librato;
|
||||
import io.moquette.server.config.IConfig;
|
||||
import io.moquette.server.netty.NettyUtils;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.handler.codec.mqtt.MqttMessage;
|
||||
import io.netty.handler.codec.mqtt.MqttMessageType;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static io.moquette.BrokerConstants.*;
|
||||
import static io.netty.channel.ChannelHandler.Sharable;
|
||||
|
||||
/**
|
||||
* Pipeline handler use to track some MQTT metrics.
|
||||
*/
|
||||
@Sharable
|
||||
public final class DropWizardMetricsHandler extends ChannelInboundHandlerAdapter {
|
||||
private MetricRegistry metrics;
|
||||
private Meter publishesMetrics;
|
||||
private Meter subscribeMetrics;
|
||||
private Counter connectedClientsMetrics;
|
||||
|
||||
public void init(IConfig props) {
|
||||
this.metrics = new MetricRegistry();
|
||||
this.publishesMetrics = metrics.meter("publish.requests");
|
||||
this.subscribeMetrics = metrics.meter("subscribe.requests");
|
||||
this.connectedClientsMetrics = metrics.counter("connect.num_clients");
|
||||
// ConsoleReporter reporter = ConsoleReporter.forRegistry(metrics)
|
||||
// .convertRatesTo(TimeUnit.SECONDS)
|
||||
// .convertDurationsTo(TimeUnit.MILLISECONDS)
|
||||
// .build();
|
||||
// reporter.start(1, TimeUnit.MINUTES);
|
||||
final String email = props.getProperty(METRICS_LIBRATO_EMAIL_PROPERTY_NAME);
|
||||
final String token = props.getProperty(METRICS_LIBRATO_TOKEN_PROPERTY_NAME);
|
||||
final String source = props.getProperty(METRICS_LIBRATO_SOURCE_PROPERTY_NAME);
|
||||
|
||||
Librato.reporter(this.metrics, email, token)
|
||||
.setSource(source)
|
||||
.start(10, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object message) {
|
||||
MqttMessage msg = (MqttMessage) message;
|
||||
MqttMessageType messageType = msg.fixedHeader().messageType();
|
||||
switch (messageType) {
|
||||
case PUBLISH:
|
||||
this.publishesMetrics.mark();
|
||||
break;
|
||||
case SUBSCRIBE:
|
||||
this.subscribeMetrics.mark();
|
||||
break;
|
||||
case CONNECT:
|
||||
this.connectedClientsMetrics.inc();
|
||||
break;
|
||||
case DISCONNECT:
|
||||
this.connectedClientsMetrics.dec();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
ctx.fireChannelRead(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
|
||||
String clientID = NettyUtils.clientID(ctx.channel());
|
||||
if (clientID != null && !clientID.isEmpty()) {
|
||||
this.connectedClientsMetrics.dec();
|
||||
}
|
||||
ctx.fireChannelInactive();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,10 +22,16 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelPromise;
|
||||
import io.netty.util.Attribute;
|
||||
import io.netty.util.AttributeKey;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static io.moquette.server.netty.NettyUtils.ATTR_USERNAME;
|
||||
|
||||
public class MessageMetricsHandler extends ChannelDuplexHandler {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MessageMetricsHandler.class);
|
||||
private static final AttributeKey<MessageMetrics> ATTR_KEY_METRICS = AttributeKey.valueOf("MessageMetrics");
|
||||
private static final AttributeKey<String> ATTR_KEY_USERNAME = AttributeKey.valueOf(ATTR_USERNAME);
|
||||
|
||||
|
||||
private MessageMetricsCollector m_collector;
|
||||
|
||||
@@ -58,6 +64,12 @@ public class MessageMetricsHandler extends ChannelDuplexHandler {
|
||||
@Override
|
||||
public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception {
|
||||
MessageMetrics metrics = ctx.channel().attr(ATTR_KEY_METRICS).get();
|
||||
String userId = ctx.channel().attr(ATTR_KEY_USERNAME).get();
|
||||
if (userId == null) {
|
||||
userId = "";
|
||||
}
|
||||
|
||||
LOG.info("channel<{}> closing after read {} messages and wrote {} messages", userId, metrics.messagesRead(), metrics.messagesWrote());
|
||||
m_collector.sumReadMessages(metrics.messagesRead());
|
||||
m_collector.sumWroteMessages(metrics.messagesWrote());
|
||||
super.close(ctx, promise);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package io.moquette.spi;
|
||||
|
||||
import cn.wildfirechat.pojos.SystemSettingPojo;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.xiaoleilu.loServer.model.FriendData;
|
||||
import cn.wildfirechat.pojos.InputOutputUserBlockStatus;
|
||||
@@ -96,25 +97,29 @@ public interface IMessagesStore {
|
||||
|
||||
DatabaseStore getDatabaseStore();
|
||||
WFCMessage.Message storeMessage(String fromUser, String fromClientId, WFCMessage.Message message);
|
||||
int getNotifyReceivers(String fromUser, WFCMessage.Message message, Set<String> notifyReceivers);
|
||||
void storeSensitiveMessage(WFCMessage.Message message);
|
||||
int getNotifyReceivers(String fromUser, WFCMessage.Message.Builder message, Set<String> notifyReceivers);
|
||||
Set<String> getAllEnds();
|
||||
WFCMessage.PullMessageResult fetchMessage(String user, String exceptClientId, long fromMessageId, int pullType);
|
||||
WFCMessage.PullMessageResult loadRemoteMessages(String user, WFCMessage.Conversation conversation, long beforeUid, int count);
|
||||
long insertUserMessages(String sender, int conversationType, String target, int line, int messageContentType, String userId, long messageId);
|
||||
WFCMessage.GroupInfo createGroup(String operator, WFCMessage.GroupInfo groupInfo, List<WFCMessage.GroupMember> memberList);
|
||||
ErrorCode addGroupMembers(String operator, String groupId, List<WFCMessage.GroupMember> memberList);
|
||||
ErrorCode kickoffGroupMembers(String operator, String groupId, List<String> memberList);
|
||||
ErrorCode addGroupMembers(String operator, boolean isAdmin, String groupId, List<WFCMessage.GroupMember> memberList);
|
||||
ErrorCode kickoffGroupMembers(String operator, boolean isAdmin, String groupId, List<String> memberList);
|
||||
ErrorCode quitGroup(String operator, String groupId);
|
||||
ErrorCode dismissGroup(String operator, String groupId, boolean isAdmin);
|
||||
ErrorCode modifyGroupInfo(String operator, String groupId, int modifyType, String value);
|
||||
ErrorCode modifyGroupInfo(String operator, String groupId, int modifyType, String value, boolean isAdmin);
|
||||
ErrorCode modifyGroupAlias(String operator, String groupId, String alias);
|
||||
List<WFCMessage.GroupInfo> getGroupInfos(List<WFCMessage.UserRequest> requests);
|
||||
WFCMessage.GroupInfo getGroupInfo(String groupId);
|
||||
ErrorCode getGroupMembers(String groupId, long maxDt, List<WFCMessage.GroupMember> members);
|
||||
WFCMessage.GroupMember getGroupMember(String groupId, String memberId);
|
||||
ErrorCode transferGroup(String operator, String groupId, String newOwner, boolean isAdmin);
|
||||
ErrorCode setGroupManager(String operator, String groupId, int type, List<String> userList, boolean isAdmin);
|
||||
boolean isMemberInGroup(String member, String groupId);
|
||||
boolean isForbiddenInGroup(String member, String groupId);
|
||||
ErrorCode canSendMessageInGroup(String member, String groupId);
|
||||
|
||||
ErrorCode recallMessage(long messageUid, String operatorId);
|
||||
ErrorCode recallMessage(long messageUid, String operatorId, boolean isAdmin);
|
||||
|
||||
WFCMessage.Robot getRobot(String robotId);
|
||||
void addRobot(WFCMessage.Robot robot);
|
||||
@@ -131,6 +136,8 @@ public interface IMessagesStore {
|
||||
WFCMessage.User getUserInfoByMobile(String mobile);
|
||||
List<WFCMessage.User> searchUser(String keyword, boolean buzzy, int page);
|
||||
|
||||
boolean updateSystemSetting(int id, String value, String desc);
|
||||
SystemSettingPojo getSystemSetting(int id);
|
||||
void createChatroom(String chatroomId, WFCMessage.ChatroomInfo chatroomInfo);
|
||||
void destoryChatroom(String chatroomId);
|
||||
WFCMessage.ChatroomInfo getChatroomInfo(String chatroomId);
|
||||
@@ -151,7 +158,7 @@ public interface IMessagesStore {
|
||||
|
||||
ErrorCode saveAddFriendRequest(String userId, WFCMessage.AddFriendRequest request, long[] head);
|
||||
ErrorCode handleFriendRequest(String userId, WFCMessage.HandleFriendRequest request, WFCMessage.Message.Builder msgBuilder, long[] heads, boolean isAdmin);
|
||||
ErrorCode deleteFriend(String userId, String friendUid);
|
||||
ErrorCode deleteFriend(String userId, String friendUid, long[] head);
|
||||
ErrorCode blackUserRequest(String fromUser, String targetUserId, int status, long[] head);
|
||||
ErrorCode SyncFriendRequestUnread(String userId, long unreadDt, long[] head);
|
||||
boolean isBlacked(String fromUser, String userId);
|
||||
|
||||
@@ -308,7 +308,7 @@ public class MessagesPublisher {
|
||||
}
|
||||
|
||||
if (isSlient) {
|
||||
LOG.info("The conversation is slient");
|
||||
LOG.info("Slient of user or conversation");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,7 +143,8 @@ public class ProtocolProcessor {
|
||||
LOG.info("Processing CONNECT message. CId={}, username={}", clientId, payload.userName());
|
||||
|
||||
if (msg.variableHeader().version() != MqttVersion.MQTT_3_1.protocolLevel()
|
||||
&& msg.variableHeader().version() != MqttVersion.MQTT_3_1_1.protocolLevel()) {
|
||||
&& msg.variableHeader().version() != MqttVersion.MQTT_3_1_1.protocolLevel()
|
||||
&& msg.variableHeader().version() != MqttVersion.Wildfire_1.protocolLevel()) {
|
||||
MqttConnAckMessage badProto = connAck(CONNECTION_REFUSED_UNACCEPTABLE_PROTOCOL_VERSION);
|
||||
|
||||
LOG.error("MQTT protocol version is not valid. CId={}", clientId);
|
||||
@@ -162,7 +163,8 @@ public class ProtocolProcessor {
|
||||
}
|
||||
|
||||
|
||||
if (!login(channel, msg, clientId)) {
|
||||
MqttVersion mqttVersion = MqttVersion.fromProtocolLevel(msg.variableHeader().version());
|
||||
if (!login(channel, msg, clientId, mqttVersion)) {
|
||||
channel.close();
|
||||
return;
|
||||
}
|
||||
@@ -238,7 +240,7 @@ public class ProtocolProcessor {
|
||||
MqttConnAckVariableHeader mqttConnAckVariableHeader = new MqttConnAckVariableHeader(returnCode, sessionPresent);
|
||||
return new MqttConnAckMessage(mqttFixedHeader, mqttConnAckVariableHeader, new MqttConnectAckPayload(data));
|
||||
}
|
||||
private boolean login(Channel channel, MqttConnectMessage msg, final String clientId) {
|
||||
private boolean login(Channel channel, MqttConnectMessage msg, final String clientId, MqttVersion mqttVersion) {
|
||||
// handle user authentication
|
||||
if (msg.variableHeader().hasUserName()) {
|
||||
int status = m_messagesStore.getUserStatus(msg.payload().userName());
|
||||
@@ -269,6 +271,7 @@ public class ProtocolProcessor {
|
||||
failedCredentials(channel);
|
||||
return false;
|
||||
}
|
||||
session.setMqttVersion(mqttVersion);
|
||||
} else if (!this.allowAnonymous) {
|
||||
LOG.error("Client didn't supply any password and MQTT anonymous mode is disabled CId={}", clientId);
|
||||
failedCredentials(channel);
|
||||
@@ -620,7 +623,8 @@ public class ProtocolProcessor {
|
||||
|
||||
public void onRpcMsg(String fromUser, String clientId, byte[] message, int messageId, String from, String request, boolean isAdmin) {
|
||||
if(request.equals(RPCCenter.KICKOFF_USER_REQUEST)) {
|
||||
mServer.getImBusinessScheduler().execute(()->handleTargetRemovedFromCurrentNode(new TargetEntry(TargetEntry.Type.TARGET_TYPE_USER, from)));
|
||||
String userId = new String(message);
|
||||
mServer.getImBusinessScheduler().execute(()->handleTargetRemovedFromCurrentNode(new TargetEntry(TargetEntry.Type.TARGET_TYPE_USER, userId)));
|
||||
return;
|
||||
}
|
||||
qos1PublishHandler.onRpcMsg(fromUser, clientId, message, messageId, from, request, isAdmin);
|
||||
|
||||
@@ -23,8 +23,10 @@ import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_NOT_IMPLEMENT;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_OVER_FREQUENCY;
|
||||
import static cn.wildfirechat.common.ErrorCode.ERROR_CODE_SUCCESS;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import cn.wildfirechat.server.ThreadPoolExecutorWrapper;
|
||||
import com.google.gson.Gson;
|
||||
@@ -39,6 +41,7 @@ import io.moquette.server.ConnectionDescriptor;
|
||||
import io.moquette.server.Server;
|
||||
import io.moquette.spi.ClientSession;
|
||||
import io.moquette.spi.impl.security.AES;
|
||||
import io.netty.handler.codec.mqtt.MqttVersion;
|
||||
import io.netty.util.ReferenceCountUtil;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
@@ -114,7 +117,7 @@ public class Qos1PublishHandler extends QosPublishHandler {
|
||||
byte[] response = new byte[ackPayload.readableBytes()];
|
||||
ackPayload.readBytes(response);
|
||||
ReferenceCountUtil.release(ackPayload);
|
||||
RPCCenter.getInstance().sendResponse(ERROR_CODE_SUCCESS.getCode(), response, from, requestId);
|
||||
RPCCenter.getInstance().sendResponse(errorCode.getCode(), response, from, requestId);
|
||||
}
|
||||
}, isAdmin);
|
||||
}
|
||||
@@ -174,8 +177,23 @@ public class Qos1PublishHandler extends QosPublishHandler {
|
||||
data = AES.AESEncrypt(data, "");
|
||||
} else {
|
||||
MemorySessionStore.Session session = m_sessionStore.getSession(clientID);
|
||||
if (session != null && session.getUsername().equals(fromUser))
|
||||
data = AES.AESEncrypt(data, session.getSecret());
|
||||
if (session != null && session.getUsername().equals(fromUser)) {
|
||||
if (data.length > 7*1024 && session.getMqttVersion() == MqttVersion.Wildfire_1) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
GZIPOutputStream gzip;
|
||||
try {
|
||||
gzip = new GZIPOutputStream(out);
|
||||
gzip.write(data);
|
||||
gzip.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
data = out.toByteArray();
|
||||
code = (byte)ErrorCode.ERROR_CODE_SUCCESS_GZIPED.code;
|
||||
}
|
||||
|
||||
data = AES.AESEncrypt(data, session.getSecret());
|
||||
}
|
||||
}
|
||||
}
|
||||
ackPayload.clear();
|
||||
|
||||
@@ -43,7 +43,7 @@ final class MqttCodecUtil {
|
||||
return clientId != null && clientId.length() >= MIN_CLIENT_ID_LENGTH &&
|
||||
clientId.length() <= MAX_CLIENT_ID_LENGTH;
|
||||
}
|
||||
if (mqttVersion == MqttVersion.MQTT_3_1_1) {
|
||||
if (mqttVersion == MqttVersion.MQTT_3_1_1 || mqttVersion == MqttVersion.Wildfire_1) {
|
||||
// In 3.1.3.1 Client Identifier of MQTT 3.1.1 specification, The Server MAY allow ClientId’s
|
||||
// that contain more than 23 encoded bytes. And, The Server MAY allow zero-length ClientId.
|
||||
return clientId != null;
|
||||
|
||||
@@ -223,7 +223,7 @@ public final class MqttDecoder extends ReplayingDecoder<DecoderState> {
|
||||
final int willQos = (b1 & 0x18) >> 3;
|
||||
final boolean willFlag = (b1 & 0x04) == 0x04;
|
||||
final boolean cleanSession = (b1 & 0x02) == 0x02;
|
||||
if (mqttVersion == MqttVersion.MQTT_3_1_1) {
|
||||
if (mqttVersion == MqttVersion.MQTT_3_1_1 || mqttVersion == MqttVersion.Wildfire_1) {
|
||||
final boolean zeroReservedFlag = (b1 & 0x01) == 0x0;
|
||||
if (!zeroReservedFlag) {
|
||||
// MQTT v3.1.1: The Server MUST validate that the reserved flag in the CONNECT Control Packet is
|
||||
|
||||
@@ -24,7 +24,8 @@ import io.netty.util.internal.ObjectUtil;
|
||||
*/
|
||||
public enum MqttVersion {
|
||||
MQTT_3_1("MQIsdp", (byte) 3),
|
||||
MQTT_3_1_1("MQTT", (byte) 4);
|
||||
MQTT_3_1_1("MQTT", (byte) 4),
|
||||
Wildfire_1("MQTT", (byte) 5);
|
||||
|
||||
private final String name;
|
||||
private final byte level;
|
||||
@@ -52,11 +53,19 @@ public enum MqttVersion {
|
||||
if (mv.level == protocolLevel) {
|
||||
return mv;
|
||||
} else {
|
||||
throw new MqttUnacceptableProtocolVersionException(protocolName + " and " +
|
||||
protocolLevel + " are not match");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new MqttUnacceptableProtocolVersionException(protocolName + "is unknown protocol name");
|
||||
}
|
||||
|
||||
public static MqttVersion fromProtocolLevel(int protocolLevel) {
|
||||
for (MqttVersion mv : values()) {
|
||||
if (mv.level == (byte )protocolLevel) {
|
||||
return mv;
|
||||
}
|
||||
}
|
||||
throw new MqttUnacceptableProtocolVersionException(protocolLevel + "is unknown protocol level");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
|
||||
package win.liyufan.im;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.*;
|
||||
import java.util.Properties;
|
||||
|
||||
public class GitRepositoryState {
|
||||
@@ -64,7 +63,9 @@ public class GitRepositoryState {
|
||||
public static GitRepositoryState getGitRepositoryState() throws IOException {
|
||||
Properties properties = new Properties();
|
||||
try {
|
||||
properties.load(new FileInputStream("config/git.properties"));
|
||||
InputStream inputStream = new FileInputStream("config/git.properties");
|
||||
BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream));
|
||||
properties.load(bf);
|
||||
} catch (IOException e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class IDUtils {
|
||||
return ch - 'a' + 26;
|
||||
} else if(ch >= '0' && ch <= '9') {
|
||||
return ch - '0' + 52;
|
||||
} else if(ch == '_') {
|
||||
} else if(ch == '+') {
|
||||
return 62;
|
||||
}
|
||||
return 63;
|
||||
|
||||
@@ -10,10 +10,12 @@ package win.liyufan.im;
|
||||
|
||||
public interface IMTopic {
|
||||
String SendMessageTopic = "MS";
|
||||
String MultiCastMessageTopic = "MMC";
|
||||
String RecallMessageTopic = "MR";
|
||||
String PullMessageTopic = "MP";
|
||||
String NotifyMessageTopic = "MN";
|
||||
String NotifyRecallMessageTopic = "RMN";
|
||||
String BroadcastMessageTopic = "MBC";
|
||||
|
||||
String GetUserSettingTopic = "UG";
|
||||
String PutUserSettingTopic = "UP";
|
||||
@@ -29,7 +31,7 @@ public interface IMTopic {
|
||||
String GetGroupInfoTopic = "GPGI";
|
||||
String GetGroupMemberTopic = "GPGM";
|
||||
String TransferGroupTopic = "GTG";
|
||||
|
||||
String SetGroupManagerTopic = "GSM";
|
||||
|
||||
String GetUserInfoTopic = "UPUI";
|
||||
String ModifyMyInfoTopic = "MMI";
|
||||
|
||||
@@ -65,6 +65,11 @@ public class MessageBundle implements Serializable {
|
||||
}
|
||||
|
||||
public void setMessage(WFCMessage.Message message) {
|
||||
this.fromUser = message.getFromUser();
|
||||
this.type = message.getConversation().getType();
|
||||
this.targetId = message.getConversation().getTarget();
|
||||
this.line = message.getConversation().getLine();
|
||||
this.message = message;
|
||||
this.messageId = message.getMessageId();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,10 +54,15 @@ public class MessageShardingUtil {
|
||||
return "t_messages";
|
||||
}
|
||||
|
||||
mid >>= (nodeIdWidth + rotateIdWidth);
|
||||
Date date = new Date(mid + T201801010000);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
if (mid != Long.MAX_VALUE) {
|
||||
mid >>= (nodeIdWidth + rotateIdWidth);
|
||||
Date date = new Date(mid + T201801010000);
|
||||
calendar.setTime(date);
|
||||
} else {
|
||||
Date date = new Date(System.currentTimeMillis());
|
||||
calendar.setTime(date);
|
||||
}
|
||||
int month = calendar.get(Calendar.MONTH);
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
year %= 3;
|
||||
|
||||
@@ -58,6 +58,7 @@ public class SensitiveFilter {
|
||||
return sensitiveWords;
|
||||
}
|
||||
|
||||
text = text.toLowerCase();
|
||||
for(int i=0;i<text.length();i++){
|
||||
int sensitiveWordLength = getSensitiveWordLength(text, i, matchType);
|
||||
if(sensitiveWordLength>0){
|
||||
|
||||
@@ -59,4 +59,78 @@ public class Utility {
|
||||
|
||||
return macAddressBuilder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化
|
||||
*
|
||||
* @param jsonStr
|
||||
* @return
|
||||
* @author lizhgb
|
||||
* @Date 2015-10-14 下午1:17:35
|
||||
* @Modified 2017-04-28 下午8:55:35
|
||||
*/
|
||||
public static String formatJson(String jsonStr) {
|
||||
if (null == jsonStr || "".equals(jsonStr))
|
||||
return "";
|
||||
StringBuilder sb = new StringBuilder();
|
||||
char last = '\0';
|
||||
char current = '\0';
|
||||
int indent = 0;
|
||||
boolean isInQuotationMarks = false;
|
||||
for (int i = 0; i < jsonStr.length(); i++) {
|
||||
last = current;
|
||||
current = jsonStr.charAt(i);
|
||||
switch (current) {
|
||||
case '"':
|
||||
if (last != '\\'){
|
||||
isInQuotationMarks = !isInQuotationMarks;
|
||||
}
|
||||
sb.append(current);
|
||||
break;
|
||||
case '{':
|
||||
case '[':
|
||||
sb.append(current);
|
||||
if (!isInQuotationMarks) {
|
||||
sb.append('\n');
|
||||
indent++;
|
||||
addIndentBlank(sb, indent);
|
||||
}
|
||||
break;
|
||||
case '}':
|
||||
case ']':
|
||||
if (!isInQuotationMarks) {
|
||||
sb.append('\n');
|
||||
indent--;
|
||||
addIndentBlank(sb, indent);
|
||||
}
|
||||
sb.append(current);
|
||||
break;
|
||||
case ',':
|
||||
sb.append(current);
|
||||
if (last != '\\' && !isInQuotationMarks) {
|
||||
sb.append('\n');
|
||||
addIndentBlank(sb, indent);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sb.append(current);
|
||||
}
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加space
|
||||
*
|
||||
* @param sb
|
||||
* @param indent
|
||||
* @author lizhgb
|
||||
* @Date 2015-10-14 上午10:38:04
|
||||
*/
|
||||
private static void addIndentBlank(StringBuilder sb, int indent) {
|
||||
for (int i = 0; i < indent; i++) {
|
||||
sb.append('\t');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
<!--MySQL数据库驱动程序-->
|
||||
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
|
||||
<!--MySQL数据库地址-->
|
||||
<property name="jdbcUrl">jdbc:mysql://localhost:3306/wfchat?useSSL=false&serverTimezone=GMT&allowPublicKeyRetrieval=true</property>
|
||||
<property name="jdbcUrl">jdbc:mysql://localhost:3306/wfchat?useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8</property>
|
||||
<!--MySQL数据库用户名-->
|
||||
<property name="user">root</property>
|
||||
<!--MySQL数据库密码-->
|
||||
<property name="password">123456</property>
|
||||
<property name="password">lt123456</property>
|
||||
<!-- 初始化连接池中的连接数,取值应在minPoolSize与maxPoolSize之间,默认为3-->
|
||||
<property name="initialPoolSize">10</property>
|
||||
<!--最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。默认值: 0 -->
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
<relativePath>../</relativePath>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.21</version>
|
||||
<version>0.26</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package cn.wildfirechat.client;
|
||||
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import com.google.protobuf.ByteString;
|
||||
import com.google.protobuf.InvalidProtocolBufferException;
|
||||
import cn.wildfirechat.pojos.InputRoute;
|
||||
import com.xiaoleilu.loServer.pojos.InputRoute;
|
||||
import io.moquette.spi.impl.security.AES;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpResponse;
|
||||
@@ -18,6 +19,7 @@ import org.fusesource.mqtt.client.*;
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
@@ -280,15 +282,38 @@ public class IMClient implements Listener {
|
||||
try {
|
||||
WFCMessage.NotifyMessage notifyMessage = WFCMessage.NotifyMessage.parseFrom(body.toByteArray());
|
||||
WFCMessage.PullMessageRequest request = WFCMessage.PullMessageRequest.newBuilder().setId(messageHead).setType(notifyMessage.getType()).build();
|
||||
connection.publish("MP", request.toByteArray(), QoS.AT_LEAST_ONCE, false, new Callback<byte[]>(){
|
||||
byte[] data = request.toByteArray();
|
||||
data = AES.AESEncrypt(data, privateSecret);
|
||||
connection.publish("MP", data, QoS.AT_LEAST_ONCE, false, new Callback<byte[]>(){
|
||||
@Override
|
||||
public void onSuccess(byte[] value) {
|
||||
if (value == null || value.length == 0) {
|
||||
System.out.println("Invalide data");
|
||||
}
|
||||
|
||||
if (value[0] != 0) {
|
||||
System.out.println("Pull message error with errorCode:" + value[0]);
|
||||
}
|
||||
|
||||
byte[] data = new byte[value.length - 1];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = value[i+1];
|
||||
}
|
||||
|
||||
try {
|
||||
byte[] data = AES.AESDecrypt(value, privateSecret, true);
|
||||
data = AES.AESDecrypt(data, privateSecret, true);
|
||||
try {
|
||||
WFCMessage.PullMessageResult result = WFCMessage.PullMessageResult.parseFrom(data);
|
||||
if (receiveMessageCallback != null) {
|
||||
receiveMessageCallback.onReceiveMessages(result.getMessageList(), false);
|
||||
if (receiveMessageCallback != null && result.getMessageList().size() > 0) {
|
||||
List<WFCMessage.Message> messages = result.getMessageList();
|
||||
List<WFCMessage.Message> out = new ArrayList<>();
|
||||
for (WFCMessage.Message msg : messages) {
|
||||
if (msg.getConversation().getType() == ProtoConstants.ConversationType.ConversationType_Private && msg.getConversation().getTarget().equals(userId)) {
|
||||
msg = msg.toBuilder().setConversation(msg.getConversation().toBuilder().setTarget(msg.getFromUser())).build();
|
||||
}
|
||||
out.add(msg);
|
||||
}
|
||||
receiveMessageCallback.onReceiveMessages(out, false);
|
||||
}
|
||||
messageHead = result.getHead();
|
||||
} catch (InvalidProtocolBufferException e) {
|
||||
@@ -355,23 +380,24 @@ public class IMClient implements Listener {
|
||||
|
||||
public static void main(String[] args) {
|
||||
//token与userid和clientid是绑定的,使用时一定要传入正确的userid和clientid,不然会认为token非法
|
||||
IMClient client = new IMClient("yzyOyOKK", "7SJk13q+YdHHe6EwDzry9BKogxTNf3UgtYj50cBTZgWNkNuxEkiqg2koKg0lXViONIX1LmwCR1jN0Mw8hvk6KGpiSKFi+IRaRkIb3mNzgIfrq4afhyIHaQfa2HOfsi6Ws+9YobkdDgdq7W70bEdVfiCSU9+JOIY449nxZzfg2Zw=", "DD72C212-26C7-4B38-A5FC-88550896B170", "192.168.1.101", 80);
|
||||
//clientId唯一代表一个设备,只能有一个登录。如果使用同一个clientId登录多次,会出现不可预料问题。
|
||||
IMClient client = new IMClient("KNK_K_00", "6I7UTfKSQT7VhsUJfU6UCvDeCyblLfcXPfajAFxgFGOcqvfFVQCvYy8A5vfAGUj2LSYgoM5W02MHh6jtG/otQs6ft8zLT4Efz315UlDLfrz+OSQYfwAuGFw9m0/x4ckrgiooprsKFxPMaNcCDact0qvp1dBhbeGUipdWVhI33b4=", "5B6DEB72-8A3D-45E2-A88A-47DC4E692B00", "192.168.0.193", 80);
|
||||
|
||||
client.setReceiveMessageCallback(new ReceiveMessageCallback() {
|
||||
@Override
|
||||
public void onReceiveMessages(List<WFCMessage.Message> messageList, boolean hasMore) {
|
||||
|
||||
System.out.println("recieved messages");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecallMessage(long messageUid) {
|
||||
|
||||
System.out.println("recalled messages");
|
||||
}
|
||||
});
|
||||
|
||||
client.setConnectionStatusCallback((ConnectionStatus newStatus) -> {
|
||||
if (newStatus == ConnectionStatus_Connected) {
|
||||
WFCMessage.Conversation conversation = WFCMessage.Conversation.newBuilder().setType(0).setTarget("yzyOyOKK").setLine(0).build();
|
||||
WFCMessage.Conversation conversation = WFCMessage.Conversation.newBuilder().setType(0).setTarget("IMININnn").setLine(0).build();
|
||||
WFCMessage.MessageContent messageContent = WFCMessage.MessageContent.newBuilder().setSearchableContent("helloworld").setType(1).build();
|
||||
client.sendMessage(conversation, messageContent, new SendMessageCallback() {
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
package com.xiaoleilu.loServer.pojos;
|
||||
|
||||
|
||||
public class InputRoute {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.21</version>
|
||||
<version>0.26</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
public class BroadMessageData {
|
||||
private String sender;
|
||||
private int line;
|
||||
private MessagePayload payload;
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public void setSender(String sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public int getLine() {
|
||||
return line;
|
||||
}
|
||||
|
||||
public void setLine(int line) {
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
public MessagePayload getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void setPayload(MessagePayload payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public static boolean isValide(BroadMessageData sendMessageData) {
|
||||
if(sendMessageData == null ||
|
||||
StringUtil.isNullOrEmpty(sendMessageData.getSender()) ||
|
||||
sendMessageData.getPayload() == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public WFCMessage.Message toProtoMessage() {
|
||||
return WFCMessage.Message.newBuilder().setFromUser(sender)
|
||||
.setConversation(WFCMessage.Conversation.newBuilder().setType(ProtoConstants.ConversationType.ConversationType_Private).setTarget(sender).setLine(line))
|
||||
.setContent(payload.toProtoMessageContent())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class BroadMessageResult {
|
||||
private long messageUid;
|
||||
private long count;
|
||||
|
||||
public BroadMessageResult() {
|
||||
}
|
||||
|
||||
public BroadMessageResult(long messageUid, long count) {
|
||||
this.messageUid = messageUid;
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public long getMessageUid() {
|
||||
return messageUid;
|
||||
}
|
||||
|
||||
public void setMessageUid(long messageUid) {
|
||||
this.messageUid = messageUid;
|
||||
}
|
||||
|
||||
public long getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(long count) {
|
||||
this.count = count;
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,13 @@ public class GroupNotificationBinaryContent {
|
||||
//operator
|
||||
private String o;
|
||||
|
||||
//name
|
||||
//value1(name or something)
|
||||
private String n;
|
||||
|
||||
//members
|
||||
private List<String> ms;
|
||||
|
||||
//members
|
||||
//value2(member or something)
|
||||
private String m;
|
||||
|
||||
public GroupNotificationBinaryContent(String g, String o, String n, String m) {
|
||||
@@ -124,4 +124,27 @@ public class GroupNotificationBinaryContent {
|
||||
public WFCMessage.MessageContent getModifyGroupMemberAliasNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_MODIFY_GROUP_ALIAS);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getChangeGroupMuteNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_MUTE);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getChangeGroupJointypeNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_JOINTYPE);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getChangeGroupPrivatechatNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_PRIVATECHAT);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getChangeGroupSearchableNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_CHANGE_SEARCHABLE);
|
||||
}
|
||||
|
||||
public WFCMessage.MessageContent getSetGroupManagerNotifyContent() {
|
||||
return getGroupNotifyContent(ProtoConstants.MESSAGE_CONTENT_TYPE_SET_MANAGER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
public class InputCreateChannel {
|
||||
private String owner;
|
||||
private String name;
|
||||
private String targetId;
|
||||
private String callback;
|
||||
private String portrait;
|
||||
private int auto;
|
||||
private String secret;
|
||||
private String desc;
|
||||
private int status;
|
||||
private String extra;
|
||||
private long updateDt;
|
||||
|
||||
public WFCMessage.ChannelInfo toProtoChannelInfo() {
|
||||
WFCMessage.ChannelInfo.Builder builder = WFCMessage.ChannelInfo.newBuilder().setOwner(owner);
|
||||
if (!StringUtil.isNullOrEmpty(name))
|
||||
builder = builder.setName(name);
|
||||
if (!StringUtil.isNullOrEmpty(targetId))
|
||||
builder = builder.setTargetId(targetId);
|
||||
if (!StringUtil.isNullOrEmpty(callback))
|
||||
builder = builder.setCallback(callback);
|
||||
if (!StringUtil.isNullOrEmpty(portrait))
|
||||
builder = builder.setPortrait(portrait);
|
||||
builder = builder.setAutomatic(auto);
|
||||
if (!StringUtil.isNullOrEmpty(secret))
|
||||
builder = builder.setSecret(secret);
|
||||
if (!StringUtil.isNullOrEmpty(desc))
|
||||
builder = builder.setDesc(desc);
|
||||
builder = builder.setStatus(status);
|
||||
if (!StringUtil.isNullOrEmpty(extra))
|
||||
builder = builder.setExtra(extra);
|
||||
if (!StringUtil.isNullOrEmpty(name))
|
||||
builder = builder.setUpdateDt(updateDt);
|
||||
else
|
||||
builder = builder.setUpdateDt(System.currentTimeMillis());
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public void setOwner(String owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTargetId() {
|
||||
return targetId;
|
||||
}
|
||||
|
||||
public void setTargetId(String targetId) {
|
||||
this.targetId = targetId;
|
||||
}
|
||||
|
||||
public String getCallback() {
|
||||
return callback;
|
||||
}
|
||||
|
||||
public void setCallback(String callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public String getPortrait() {
|
||||
return portrait;
|
||||
}
|
||||
|
||||
public void setPortrait(String portrait) {
|
||||
this.portrait = portrait;
|
||||
}
|
||||
|
||||
public int getAuto() {
|
||||
return auto;
|
||||
}
|
||||
|
||||
public void setAuto(int auto) {
|
||||
this.auto = auto;
|
||||
}
|
||||
|
||||
public String getSecret() {
|
||||
return secret;
|
||||
}
|
||||
|
||||
public void setSecret(String secret) {
|
||||
this.secret = secret;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getExtra() {
|
||||
return extra;
|
||||
}
|
||||
|
||||
public void setExtra(String extra) {
|
||||
this.extra = extra;
|
||||
}
|
||||
|
||||
public long getUpdateDt() {
|
||||
return updateDt;
|
||||
}
|
||||
|
||||
public void setUpdateDt(long updateDt) {
|
||||
this.updateDt = updateDt;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class InputModifyGroupInfo extends InputGroupBase {
|
||||
private String group_id;
|
||||
//ModifyGroupInfoType
|
||||
private int type;
|
||||
private String value;
|
||||
|
||||
public boolean isValide() {
|
||||
return !StringUtil.isNullOrEmpty(group_id);
|
||||
}
|
||||
public String getGroup_id() {
|
||||
return group_id;
|
||||
}
|
||||
|
||||
public void setGroup_id(String group_id) {
|
||||
this.group_id = group_id;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public WFCMessage.ModifyGroupInfoRequest toProtoGroupRequest() {
|
||||
return WFCMessage.ModifyGroupInfoRequest.newBuilder()
|
||||
.setGroupId(group_id)
|
||||
.setType(type)
|
||||
.setValue(value)
|
||||
.addAllToLine(to_lines == null || to_lines.isEmpty() ? Arrays.asList(0) : to_lines)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class MultiMessageResult {
|
||||
private long messageUid;
|
||||
private long timestamp;
|
||||
|
||||
public MultiMessageResult() {
|
||||
}
|
||||
|
||||
public MultiMessageResult(long messageUid, long timestamp) {
|
||||
this.messageUid = messageUid;
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public long getMessageUid() {
|
||||
return messageUid;
|
||||
}
|
||||
|
||||
public void setMessageUid(long messageUid) {
|
||||
this.messageUid = messageUid;
|
||||
}
|
||||
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
import cn.wildfirechat.proto.ProtoConstants;
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MulticastMessageData {
|
||||
private String sender;
|
||||
private int line;
|
||||
private MessagePayload payload;
|
||||
private List<String> targets;
|
||||
|
||||
public String getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
public void setSender(String sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public int getLine() {
|
||||
return line;
|
||||
}
|
||||
|
||||
public void setLine(int line) {
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
public MessagePayload getPayload() {
|
||||
return payload;
|
||||
}
|
||||
|
||||
public void setPayload(MessagePayload payload) {
|
||||
this.payload = payload;
|
||||
}
|
||||
|
||||
public static boolean isValide(MulticastMessageData sendMessageData) {
|
||||
if(sendMessageData == null ||
|
||||
StringUtil.isNullOrEmpty(sendMessageData.getSender()) ||
|
||||
sendMessageData.getPayload() == null) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public WFCMessage.MultiCastMessage toProtoMessage() {
|
||||
return WFCMessage.MultiCastMessage.newBuilder().setFromUser(sender)
|
||||
.setLine(line)
|
||||
.setContent(payload.toProtoMessageContent())
|
||||
.addAllTo(targets)
|
||||
.build();
|
||||
}
|
||||
|
||||
public List<String> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargets(List<String> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* This file is part of the Wildfire Chat package.
|
||||
* (c) Heavyrain2012 <heavyrain.lee@gmail.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
|
||||
import cn.wildfirechat.proto.WFCMessage;
|
||||
|
||||
public class OutputCreateChannel {
|
||||
private String targetId;
|
||||
|
||||
public OutputCreateChannel(String targetId) {
|
||||
this.targetId = targetId;
|
||||
}
|
||||
|
||||
public String getTargetId() {
|
||||
return targetId;
|
||||
}
|
||||
|
||||
public void setTargetId(String targetId) {
|
||||
this.targetId = targetId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.wildfirechat.pojos;
|
||||
|
||||
public class SystemSettingPojo {
|
||||
public int id;
|
||||
public String value;
|
||||
public String desc;
|
||||
}
|
||||
@@ -25,16 +25,24 @@ public interface APIPath {
|
||||
|
||||
String Msg_Send = "/admin/message/send";
|
||||
String Msg_Recall = "/admin/message/recall";
|
||||
String Msg_Broadcast = "/admin/message/broadcast";
|
||||
String Msg_Multicast = "/admin/message/multicast";
|
||||
|
||||
String Create_Group = "/admin/group/create";
|
||||
String Group_Dismiss = "/admin/group/del";
|
||||
String Group_Transfer = "/admin/group/transfer";
|
||||
String Group_Get_Info = "/admin/group/get_info";
|
||||
String Group_Modify_Info = "/admin/group/modify";
|
||||
String Group_Member_List = "/admin/group/member/list";
|
||||
String Group_Member_Add = "/admin/group/member/add";
|
||||
String Group_Member_Kickoff = "/admin/group/member/del";
|
||||
|
||||
|
||||
String Create_Channel = "/admin/channel/create";
|
||||
String Get_System_Setting = "/admin/system/get_setting";
|
||||
String Put_System_Setting = "/admin/system/put_setting";
|
||||
|
||||
|
||||
String Channel_Message_Send = "/channel/message/send";
|
||||
|
||||
String Robot_User_Info = "/robot/user_info";
|
||||
|
||||
@@ -42,6 +42,7 @@ public enum ErrorCode {
|
||||
|
||||
ERROR_CODE_NOT_IN_CHANNEL(21, "not in channel"),
|
||||
|
||||
ERROR_CODE_GROUP_MUTED(241, "group is muted"),
|
||||
ERROR_CODE_SENSITIVE_MATCHED(242, "sensitive matched"),
|
||||
ERROR_CODE_SIGN_EXPIRED(243, "sign expired"),
|
||||
ERROR_CODE_AUTH_FAILURE(244, "auth failure"),
|
||||
@@ -56,7 +57,7 @@ public enum ErrorCode {
|
||||
ERROR_CODE_NOT_IMPLEMENT(254, "not implement"),
|
||||
|
||||
|
||||
ERROR_CODE_ASYNC_HANDLER(255, "异步执行,服务器内部逻辑需要此代码,为正常情况,不能返回客户端"),;
|
||||
ERROR_CODE_SUCCESS_GZIPED(255, "success withe gzip response"),;
|
||||
|
||||
public int code;
|
||||
public String msg;
|
||||
|
||||
@@ -87,6 +87,10 @@ public class ProtoConstants {
|
||||
int Modify_Group_Name = 0;
|
||||
int Modify_Group_Portrait = 1;
|
||||
int Modify_Group_Extra = 2;
|
||||
int Modify_Group_Mute = 3;
|
||||
int Modify_Group_JoinType = 4;
|
||||
int Modify_Group_PrivateChat = 5;
|
||||
int Modify_Group_Searchable = 6;
|
||||
}
|
||||
|
||||
//ModifyGroupInfoRequest -> type
|
||||
@@ -124,6 +128,9 @@ public class ProtoConstants {
|
||||
}
|
||||
|
||||
|
||||
public interface SystemSettingType {
|
||||
int Group_Max_Member_Count = 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -137,5 +144,12 @@ public class ProtoConstants {
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_GROUP_NAME = 110;
|
||||
public static final int MESSAGE_CONTENT_TYPE_MODIFY_GROUP_ALIAS = 111;
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_GROUP_PORTRAIT = 112;
|
||||
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_MUTE = 113;
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_JOINTYPE = 114;
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_PRIVATECHAT = 115;
|
||||
public static final int MESSAGE_CONTENT_TYPE_CHANGE_SEARCHABLE = 116;
|
||||
|
||||
public static final int MESSAGE_CONTENT_TYPE_SET_MANAGER = 117;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,7 +6,7 @@
|
||||
<!--<relativePath>../pom.xml</relativePath>-->
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
<groupId>cn.wildfirechat</groupId>
|
||||
<version>0.21</version>
|
||||
<version>0.26</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>distribution</artifactId>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<!--MySQL数据库驱动程序-->
|
||||
<property name="driverClass">com.mysql.cj.jdbc.Driver</property>
|
||||
<!--MySQL数据库地址-->
|
||||
<property name="jdbcUrl">jdbc:mysql://localhost:3306/wfchat?useSSL=false&serverTimezone=GMT&allowPublicKeyRetrieval=true</property>
|
||||
<property name="jdbcUrl">jdbc:mysql://localhost:3306/wfchat?useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=utf8</property>
|
||||
<!--MySQL数据库用户名-->
|
||||
<property name="user">root</property>
|
||||
<!--MySQL数据库密码-->
|
||||
|
||||
@@ -26,7 +26,7 @@ host 0.0.0.0
|
||||
##本地绑定端口
|
||||
local_port 80
|
||||
|
||||
##是否使用内置DB。0使用mysql;1使用h2db
|
||||
##是否使用内置DB。0使用mysql;1使用h2db;2使用mysql+mongodb。社区版只支持0和1,专业版支持2
|
||||
embed.db 1
|
||||
|
||||
##服务器管理接口密钥
|
||||
@@ -42,6 +42,12 @@ client.proto.secret_key 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x78,0x79,0x7A,0
|
||||
##用来生产im token的私钥,只在服务器使用,客户端不用。正式使用时为了安全一定要修改这个值,切记切记
|
||||
token.key testim
|
||||
|
||||
##首次登录,是否接收之前的历史消息。0 不接收;1接收。
|
||||
message.roaming 0
|
||||
|
||||
##是否开启拉取远程历史消息
|
||||
message.remote_history_message 0
|
||||
|
||||
#*********************************************************************
|
||||
# hazelcase configuration
|
||||
#*********************************************************************
|
||||
@@ -96,6 +102,15 @@ push.android.server.address http://localhost:8085/android/push
|
||||
##苹果推送服务器地址
|
||||
push.ios.server.address http://localhost:8085/ios/push
|
||||
|
||||
#*********************************************************************
|
||||
# MongoDB configuration
|
||||
#*********************************************************************
|
||||
#专业版支持,社区版请忽略
|
||||
#mongodb.client_uri mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]
|
||||
#mongodb.client_uri mongodb://host1:27017,host2:27017,host3:27017/wfchat?replicaSet=myReplicaSet
|
||||
mongodb.client_uri mongodb://wfc:123456@localhost:27017/wfchat
|
||||
mongodb.database wfchat
|
||||
mongodb.data_expire_days 1096
|
||||
|
||||
#*********************************************************************
|
||||
# Netty Configuration
|
||||
|
||||
@@ -17,9 +17,9 @@ goto end
|
||||
rem Set JavaHome if it exists
|
||||
if exist { "%JAVA_HOME%\bin\java" } (
|
||||
set "JAVA="%JAVA_HOME%\bin\java""
|
||||
) else {
|
||||
) else (
|
||||
set "JAVA="java""
|
||||
}
|
||||
)
|
||||
|
||||
echo Using JAVA_HOME: "%JAVA_HOME%"
|
||||
echo Using WILDFIRECHAT_HOME: "%WILDFIRECHAT_HOME%"
|
||||
@@ -30,6 +30,8 @@ set JAVA_OPTS=
|
||||
set JAVA_OPTS_SCRIPT=-XX:+HeapDumpOnOutOfMemoryError -Djava.awt.headless=true
|
||||
set WILDFIRECHAT_PATH=%WILDFIRECHAT_HOME%
|
||||
set LOG_FILE=%WILDFIRECHAT_HOME%\config\log4j.properties
|
||||
set HZ_CONF_FILE=%WILDFIRECHAT_HOME%\config\hazelcast.xml
|
||||
set C3P0_CONF_FILE=%WILDFIRECHAT_HOME%\config\c3p0-config.xml
|
||||
|
||||
rem Use the Hotspot garbage-first collector.
|
||||
set JAVA_OPTS=%JAVA_OPTS% -XX:+UseG1GC
|
||||
@@ -71,4 +73,4 @@ rem set JAVA_OPTS=%JAVA_OPTS% -XX:+UseGCLogFileRotation
|
||||
rem set JAVA_OPTS=%JAVA_OPTS% -XX:NumberOfGCLogFiles=10
|
||||
rem set JAVA_OPTS=%JAVA_OPTS% -XX:GCLogFileSize=10M"
|
||||
|
||||
%JAVA% -server %JAVA_OPTS% %JAVA_OPTS_SCRIPT% -Dlog4j.configuration=file:%LOG_FILE% -Dwildfirechat.path=%WILDFIRECHAT_PATH% -cp %WILDFIRECHAT_HOME%\lib\* cn.wildfirechat.server.Server
|
||||
%JAVA% -server %JAVA_OPTS% %JAVA_OPTS_SCRIPT% -Dlog4j.configuration=file:%LOG_FILE% -Dcom.mchange.v2.c3p0.cfg.xml=%C3P0_CONF_FILE% -Dhazelcast.configuration=file:%HZ_CONF_FILE% -Dwildfirechat.path=%WILDFIRECHAT_PATH% -cp %WILDFIRECHAT_HOME%\lib\* cn.wildfirechat.server.Server
|
||||
|
||||
@@ -70,7 +70,7 @@ JAVA_OPTS="$JAVA_OPTS -XX:MaxGCPauseMillis=500"
|
||||
### GC logging options -- uncomment to enable
|
||||
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDetails"
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDateStamps"
|
||||
#JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCDateStamps"
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:+PrintHeapAtGC"
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:+PrintTenuringDistribution"
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:+PrintGCApplicationStoppedTime"
|
||||
@@ -80,8 +80,8 @@ JAVA_OPTS="$JAVA_OPTS -XX:+UseGCLogFileRotation"
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:NumberOfGCLogFiles=10"
|
||||
JAVA_OPTS="$JAVA_OPTS -XX:GCLogFileSize=10M"
|
||||
|
||||
#JAVA_OPTS="$JAVA_OPTS -Xmx128M"
|
||||
#JAVA_OPTS="$JAVA_OPTS -Xms128M"
|
||||
|
||||
JAVA_OPTS="$JAVA_OPTS -Xmx128M"
|
||||
JAVA_OPTS="$JAVA_OPTS -Xms128M"
|
||||
|
||||
$JAVA -server $JAVA_OPTS $JAVA_OPTS_SCRIPT -Dlog4j.configuration="file:$LOG_FILE" -Dcom.mchange.v2.c3p0.cfg.xml="$C3P0_CONF_FILE" -Dhazelcast.configuration="file:$HZ_CONF_FILE" -Dwildfirechat.path="$WILDFIRECHAT_PATH" -cp "$WILDFIRECHAT_HOME/lib/*" cn.wildfirechat.server.Server
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<artifactId>wildfirechat-parent</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<version>0.21</version>
|
||||
<version>0.26</version>
|
||||
<name>Wildfire Chat</name>
|
||||
<description>Wildfire Chat Server</description>
|
||||
<inceptionYear>2019</inceptionYear>
|
||||
@@ -30,7 +30,6 @@
|
||||
</licenses>
|
||||
|
||||
|
||||
|
||||
<modules>
|
||||
<module>broker</module>
|
||||
<module>wildfire_jmeter</module>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user