Skip to content

Commit

Permalink
修改websocket工程bug以及缺包问题
Browse files Browse the repository at this point in the history
  • Loading branch information
GreenOrange520 committed Mar 14, 2022
1 parent c095ac1 commit d19a835
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 17 deletions.
Binary file added maven/package.zip
Binary file not shown.
2 changes: 0 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@
<groupId>com.rotanava.aliyun</groupId>
<artifactId>oss</artifactId>
<version>${oss.version}</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/oss-1.0.3.jar</systemPath>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.ejlchina</groupId>-->
Expand Down
6 changes: 6 additions & 0 deletions rotanava-boot-base/rotanava-boot-base-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@
<version>${commons3.version}</version>
</dependency>

<dependency>
<groupId>com.rotanava.aliyun</groupId>
<artifactId>oss</artifactId>
<version>1.0.3</version>
</dependency>

<!-- 拼音库 -->
<dependency>
<groupId>com.belerweb</groupId>
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions rotanava-boot-base/rotanava-boot-base-dingding/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
<groupId>com.rotanava.boot</groupId>
<artifactId>dingtalk-java-sdk</artifactId>
<version>1.3</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/lib/dingtalk-java-sdk-1.3.jar</systemPath>
</dependency>
</dependencies>

Expand Down
10 changes: 8 additions & 2 deletions rotanava-boot-cloud-module/rotanava-boot-cloud-websocket/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<!-- <groupId>com.rotanova.framework</groupId>-->
<!-- <artifactId>rotanava-boot-base-core</artifactId>-->
<!-- </dependency>-->
<!--反射框架-->
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.10</version>
</dependency>
<!--JWT-->
<dependency>
<groupId>com.auth0</groupId>
Expand Down Expand Up @@ -60,8 +66,8 @@
<groupId>com.rotanava.face</groupId>
<artifactId>comoon-websocket</artifactId>
<version>1.0.7</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/comoon-websocket-1.0.7.jar</systemPath>
<!-- <scope>system</scope>-->
<!-- <systemPath>${project.basedir}/src/main/resources/lib/comoon-websocket-1.0.7.jar</systemPath>-->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
package com.rotanava.boot.system.websocket.config;

import com.rotanava.face.core.config.SpringStartListener;
import com.rotanava.face.core.global.ThreadPoolUtil;
import com.rotanava.boot.system.websocket.thread.ThreadPoolUtil;

import com.rotanava.face.core.websocket.server.ServerBootStrap;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;

@Component
@Log4j2
public class InitInfo extends SpringStartListener {
public class InitInfo implements ApplicationRunner {

@Autowired
ServerBootStrap serverBootStrap;


@Override
public void start(ConfigurableApplicationContext applicationContext) {
public void run(ApplicationArguments args) throws Exception {
ThreadPoolUtil.execute(() -> serverBootStrap.run());
log.info("项目启动成功");
log.info("websocket项目启动成功");
}



}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.rotanava.boot.system.websocket.config;

import com.rotanava.boot.system.websocket.bean.UserClientBean;
import com.rotanava.face.core.util.StringUtil;
import com.rotanava.face.core.websocket.iface.SocketClient;
import com.rotanava.face.core.websocket.server.ClientManage;
import io.netty.util.internal.StringUtil;

import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -38,7 +38,7 @@ public static void put(String token, UserClientBean userClientBean) {

public static SocketClient get(String token) {
UserClientBean userClientBean = map.get(token);
if (!StringUtil.isNullOrEmpty(userClientBean)) {
if (userClientBean!=null) {
return ClientManage.getClient(userClientBean.getSession());
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
import com.auth0.jwt.JWT;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.google.common.collect.Sets;
import com.rotanava.boot.system.websocket.api.model.NoticeBean;
import com.rotanava.boot.system.websocket.bean.UserClientBean;
import com.rotanava.boot.system.websocket.config.SocketClientManage;

import com.rotanava.face.core.global.ThreadPoolUtil;
import com.rotanava.boot.system.websocket.thread.ThreadPoolUtil;
import com.rotanava.face.core.websocket.iface.SocketClient;

import lombok.extern.log4j.Log4j2;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package com.rotanava.boot.system.websocket.thread;



import java.util.concurrent.*;

public class ThreadPoolUtil {

public static ThreadPoolExecutor threadPool;

/**
* 无返回值直接执行
* ThreadRun<?,?> 可以传递两个参数给新线程使用
* @param runnable
*/
public static void execute(ThreadRun<?,?> runnable){
getThreadPool().execute(runnable);
}

/**
* 无返回值直接执行
* ThreadRun<?,?> 可以传递两个参数给新线程使用
* @param runnable
*/
public static void execute(Runnable runnable){
getThreadPool().execute(runnable);
}


/**
* 多线程获取返回值
* @param callable
*/
public static <T> Future<T> submit(Callable<T> callable){
return getThreadPool().submit(callable);
}


/**
* dcs获取线程池
* @return 线程池对象
*/
public static ThreadPoolExecutor getThreadPool() {
if (threadPool != null) {
return threadPool;
} else {
synchronized (ThreadPoolUtil.class) {
if (threadPool == null) {
threadPool = new ThreadPoolExecutor(8, 16, 60, TimeUnit.SECONDS,
new LinkedBlockingQueue<>(32), new ThreadPoolExecutor.CallerRunsPolicy());
}
return threadPool;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.rotanava.boot.system.websocket.thread;

public abstract class ThreadRun<T,E> implements Runnable{
private T param;
private E param2;
public ThreadRun(T param,E param2){
this.param=param;
this.param2=param2;
}
@Override
public void run() {
try {
execute(param,param2);
} catch (Exception e) {
e.printStackTrace();
}
}

public abstract void execute(T param, E param2) throws Exception;



}
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ spring:
application:
name: rotanava-boot-module-system-websocket
profiles:
active: dev
active: test
Binary file not shown.

0 comments on commit d19a835

Please sign in to comment.