Compare commits
3 Commits
1694a58029
...
4e4a4c2f82
Author | SHA1 | Date | |
---|---|---|---|
4e4a4c2f82 | |||
6eceb64781 | |||
394991611d |
5
.gitignore
vendored
5
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
.idea
|
||||
/.idea/
|
||||
/out/
|
||||
*.iml
|
||||
*.iml
|
||||
/target/
|
@ -2,22 +2,22 @@
|
||||
|
||||
<application port="2091" name="ZIM_LOCAL">
|
||||
<zhubs>
|
||||
<zhub name="zhub" addr="47.111.150.118:6066" groupid="zim-zhub" auth="zchd@123456"/>
|
||||
<zhub name="zhub" addr="47.106.237.198:1216" groupid="zim-zhub" auth="token-12345"/>
|
||||
</zhubs>
|
||||
|
||||
<resources>
|
||||
<properties load="config.properties"></properties>
|
||||
<listener value="com.zdemo.ZhubListener"/>
|
||||
<listener value="com.zchd.base.AppListener"/>
|
||||
<listener value="net.tccn.ZhubListener"/>
|
||||
|
||||
<source name="int_cache" value="com.zdemo.cachex.MyRedisCacheSource">
|
||||
<node addr="47.111.150.118" password="*Zhong9307!" port="6064" db="0"/>
|
||||
<source name="int_cache" value="org.redkalex.cache.redis.MyRedisCacheSource">
|
||||
<node addr="47.106.237.198" password="hello123!" port="6064" db="0"/>
|
||||
</source>
|
||||
<source name="str_cache" value="com.zdemo.cachex.MyRedisCacheSource">
|
||||
<node addr="47.111.150.118" password="*Zhong9307!" port="6064" db="0"/>
|
||||
<source name="str_cache" value="org.redkalex.cache.redis.MyRedisCacheSource">
|
||||
<node addr="47.106.237.198" password="hello123!" port="6064" db="0"/>
|
||||
</source>
|
||||
<source name="long_cache" value="com.zdemo.cachex.MyRedisCacheSource">
|
||||
<node addr="47.111.150.118" password="*Zhong9307!" port="6064" db="0"/>
|
||||
<source name="long_cache" value="org.redkalex.cache.redis.MyRedisCacheSource">
|
||||
<node addr="47.106.237.198" password="hello123!" port="6064" db="0"/>
|
||||
</source>
|
||||
</resources>
|
||||
|
||||
|
@ -6,9 +6,9 @@
|
||||
<persistence-unit name="z_im">
|
||||
<shared-cache-mode>ALL</shared-cache-mode>
|
||||
<properties>
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://47.111.150.118:6063/z_im"/>
|
||||
<property name="javax.persistence.jdbc.user" value="vsport"/>
|
||||
<property name="javax.persistence.jdbc.password" value="*Zhong123098!"/>
|
||||
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://47.106.237.198:3306/z_im"/>
|
||||
<property name="javax.persistence.jdbc.user" value="u_im"/>
|
||||
<property name="javax.persistence.jdbc.password" value="u_im@2024"/>
|
||||
</properties>
|
||||
</persistence-unit>
|
||||
|
||||
|
93
pom.xml
Normal file
93
pom.xml
Normal file
@ -0,0 +1,93 @@
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>dev.zhub</groupId>
|
||||
<artifactId>zim</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>Archetype - dev.zhub.zim</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>maven-release</id>
|
||||
<name>maven-nexus</name>
|
||||
<url>https://nexus.1216.top/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.redkale</groupId>
|
||||
<artifactId>redkale</artifactId>
|
||||
<version>2.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>8.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>net.tccn</groupId>
|
||||
<artifactId>zhub-client-redkale</artifactId>
|
||||
<version>x.22.0</version>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongo-java-driver</artifactId>
|
||||
<version>3.12.14</version>
|
||||
</dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.26</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>com.jfinal</groupId>
|
||||
<artifactId>enjoy</artifactId>
|
||||
<version>4.8.dev</version>
|
||||
</dependency>-->
|
||||
|
||||
<!--<dependency>
|
||||
<groupId>com.github.jsqlparser</groupId>
|
||||
<artifactId>jsqlparser</artifactId>
|
||||
<version>4.9</version>
|
||||
</dependency>-->
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<finalName>lib/zim</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<executions>
|
||||
<!-- 依赖 jar 拷贝 -->
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/lib</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,12 +1,12 @@
|
||||
package com.zchd.base;
|
||||
|
||||
import com.zdemo.cachex.MyRedisCacheSource;
|
||||
import com.zdemo.zhub.ZHubClient;
|
||||
import net.tccn.zhub.ZHubClient;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.service.AbstractService;
|
||||
import org.redkale.service.RetResult;
|
||||
import org.redkale.source.DataSource;
|
||||
import org.redkale.util.Sheet;
|
||||
import org.redkalex.cache.redis.MyRedisCacheSource;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
|
@ -7,8 +7,8 @@ import com.zchd.zim.bean.SubscribeBean;
|
||||
import com.zchd.zim.entity.AppInfo;
|
||||
import com.zchd.zim.entity.ChannelUser;
|
||||
import com.zchd.zim.entity.ImUser;
|
||||
import com.zdemo.cachex.MyRedisCacheSource;
|
||||
import com.zdemo.zhub.RpcResult;
|
||||
import net.tccn.zhub.Lock;
|
||||
import net.tccn.zhub.RpcResult;
|
||||
import org.redkale.convert.json.JsonConvert;
|
||||
import org.redkale.net.http.RestMapping;
|
||||
import org.redkale.net.http.RestService;
|
||||
@ -18,6 +18,7 @@ import org.redkale.util.AnyValue;
|
||||
import org.redkale.util.Comment;
|
||||
import org.redkale.util.TypeToken;
|
||||
import org.redkale.util.Utility;
|
||||
import org.redkalex.cache.redis.MyRedisCacheSource;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
@ -54,9 +55,9 @@ public class ImAccountService extends BaseService {
|
||||
ImBean bean = r.getValue();
|
||||
RetResult<Kv> result = register(bean);
|
||||
if (!result.isSuccess()) {
|
||||
return r.buildError(result.getRetinfo());
|
||||
return r.retError(result.getRetinfo());
|
||||
}
|
||||
return r.buildResp(result.getResult());
|
||||
return r.render(result.getResult());
|
||||
});
|
||||
|
||||
// 获取游戏用户 IM-TOKEN
|
||||
@ -65,9 +66,9 @@ public class ImAccountService extends BaseService {
|
||||
ImBean bean = r.getValue();
|
||||
RetResult<Kv> result = getToken(bean);
|
||||
if (!result.isSuccess()) {
|
||||
return r.buildError(result.getRetinfo());
|
||||
return r.retError(result.getRetinfo());
|
||||
}
|
||||
return r.buildResp(result.getResult());
|
||||
return r.render(result.getResult());
|
||||
});
|
||||
|
||||
// 为用户新增订阅频道
|
||||
@ -75,7 +76,7 @@ public class ImAccountService extends BaseService {
|
||||
}, r -> {
|
||||
SubscribeBean bean = r.getValue();
|
||||
RetResult result = subscribe(bean);
|
||||
return r.buildResp(result.getResult());
|
||||
return r.render(result.getResult());
|
||||
});
|
||||
|
||||
// 为用户取消订阅频道
|
||||
@ -83,7 +84,7 @@ public class ImAccountService extends BaseService {
|
||||
}, r -> {
|
||||
SubscribeBean bean = r.getValue();
|
||||
RetResult result = unsubscribe(bean);
|
||||
return r.buildResp(result.getResult());
|
||||
return r.render(result.getResult());
|
||||
});
|
||||
|
||||
// 禁言 todo: ①禁言时长 ②禁言指定频道
|
||||
@ -96,7 +97,7 @@ public class ImAccountService extends BaseService {
|
||||
int userid = user.getUserid();
|
||||
zimSource.updateColumn(ImUser.class, userid, ColumnValue.create("status", ImUser.STATUS_FREEZE_ACTIVE));
|
||||
intCache.setBit("im:banned-talk", userid, true);
|
||||
return r.buildResp();
|
||||
return r.render();
|
||||
});
|
||||
|
||||
// 取消禁言
|
||||
@ -109,7 +110,7 @@ public class ImAccountService extends BaseService {
|
||||
int userid = user.getUserid();
|
||||
zimSource.updateColumn(ImUser.class, userid, ColumnValue.create("status", 10));
|
||||
intCache.setBit("im:banned-talk", userid, false);
|
||||
return r.buildResp();
|
||||
return r.render();
|
||||
});
|
||||
}
|
||||
|
||||
@ -191,9 +192,9 @@ public class ImAccountService extends BaseService {
|
||||
public RetResult subscribe(SubscribeBean bean) {
|
||||
ImUser user = accountService.currentImUser(bean.getImtoken());
|
||||
int userid = user.getUserid();
|
||||
Lock lock = zhub.lock("im:channel-create:" + userid, 500);
|
||||
try {
|
||||
// 添加数据库订阅关系
|
||||
intCache.tryLock("im:channel-create:" + userid, 500);
|
||||
FilterNode node1 = FilterNode.create("appid", user.getAppid())
|
||||
.and("channeltype", bean.getChanneltype())
|
||||
.and("channelvalue", bean.getChannelvalue())
|
||||
@ -206,7 +207,7 @@ public class ImAccountService extends BaseService {
|
||||
messageMonitor.subscribeChannel(userid, record.buildChannelid(), true);
|
||||
}
|
||||
} finally {
|
||||
intCache.unlock("im:channel-create:" + userid);
|
||||
lock.unLock();
|
||||
}
|
||||
return RET_SUCCESS;
|
||||
}
|
||||
|
@ -7,8 +7,8 @@ import com.zchd.zim.entity.ChannelMessage;
|
||||
import com.zchd.zim.entity.ChannelUser;
|
||||
import com.zchd.zim.entity.FriendMessage;
|
||||
import com.zchd.zim.entity.ImUser;
|
||||
import com.zdemo.zhub.ZHubClient;
|
||||
import net.tccn.timer.Timers;
|
||||
import net.tccn.zhub.ZHubClient;
|
||||
import org.redkale.net.http.RestService;
|
||||
import org.redkale.net.http.WebSocketNode;
|
||||
import org.redkale.source.ColumnValue;
|
||||
|
@ -6,7 +6,6 @@ import com.zchd.base.util.Utils;
|
||||
import com.zchd.zim.entity.ChannelMessage;
|
||||
import com.zchd.zim.entity.FriendMessage;
|
||||
import com.zchd.zim.entity.ImUser;
|
||||
import com.zdemo.cachex.MyRedisCacheSource;
|
||||
import org.redkale.net.http.HttpRequest;
|
||||
import org.redkale.net.http.RestOnMessage;
|
||||
import org.redkale.net.http.RestWebSocket;
|
||||
@ -14,6 +13,7 @@ import org.redkale.net.http.WebSocket;
|
||||
import org.redkale.service.RetResult;
|
||||
import org.redkale.source.DataSource;
|
||||
import org.redkale.util.Comment;
|
||||
import org.redkalex.cache.redis.MyRedisCacheSource;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Map;
|
||||
|
@ -7,13 +7,13 @@ import com.zchd.base.util.Utils;
|
||||
import com.zchd.zim.entity.ChannelMessage;
|
||||
import com.zchd.zim.entity.ChannelUser;
|
||||
import com.zchd.zim.entity.FriendMessage;
|
||||
import com.zdemo.cachex.MyRedisCacheSource;
|
||||
import org.redkale.net.http.RestService;
|
||||
import org.redkale.net.http.WebSocketNode;
|
||||
import org.redkale.util.AnyValue;
|
||||
import org.redkale.util.Comment;
|
||||
import org.redkale.util.TypeToken;
|
||||
import org.redkale.util.Utility;
|
||||
import org.redkalex.cache.redis.MyRedisCacheSource;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.BitSet;
|
||||
|
Loading…
Reference in New Issue
Block a user