1
0
mirror of https://github.com/chatopera/cosin.git synced 2025-08-01 16:38:02 +08:00
This commit is contained in:
duke 2023-07-13 19:45:22 +08:00
parent da8f78e2d9
commit 2836072602
3 changed files with 21 additions and 27 deletions

View File

@ -20,37 +20,41 @@ import com.corundumstudio.socketio.annotation.SpringAnnotationScanner;
import com.cskefu.cc.exception.InstantMessagingExceptionListener;
import jakarta.annotation.PreDestroy;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.web.server.Ssl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.core.env.Environment;
import java.io.InputStream;
@org.springframework.context.annotation.Configuration
public class MessagingServerConfigure implements ApplicationContextAware {
public class MessagingServerConfigure {
@Value("${uk.im.server.host}")
private String host;
@Value("${uk.im.server.port}")
private Integer port;
@Value("${cs.im.server.ssl.port}")
private Integer sslPort;
@Value("${uk.im.server.threads}")
private String threads;
private SocketIOServer server;
private ApplicationContext applicationContext;
@Bean(name = "webimport")
public Integer getWebIMPort() {
if (sslPort != null) {
return sslPort;
} else {
return port;
}
}
@Autowired
private ServerProperties serverProperties;
@Bean
public SocketIOServer socketIOServer() {
@ -61,7 +65,7 @@ public class MessagingServerConfigure implements ApplicationContextAware {
config.setSocketConfig(tmpConfig);
// config.setHostname(host);
config.setPort(port);
config.setPort(getWebIMPort());
// config.getSocketConfig().setReuseAddress(true);
// config.setSocketConfig(new SocketConfig());
@ -78,7 +82,7 @@ public class MessagingServerConfigure implements ApplicationContextAware {
config.getSocketConfig().setTcpNoDelay(true);
config.getSocketConfig().setTcpKeepAlive(true);
ServerProperties serverProperties = applicationContext.getBean(ServerProperties.class);
// ServerProperties serverProperties = applicationContext.getBean(ServerProperties.class);
Ssl ssl = serverProperties.getSsl();
if (ssl != null) {
@ -102,9 +106,4 @@ public class MessagingServerConfigure implements ApplicationContextAware {
public void destory() {
server.stop();
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
}

View File

@ -23,6 +23,7 @@ import com.cskefu.cc.basic.MainContext;
import com.cskefu.cc.basic.MainUtils;
import com.cskefu.cc.cache.Cache;
import com.cskefu.cc.cache.RedisCommand;
import com.cskefu.cc.config.MessagingServerConfigure;
import com.cskefu.cc.controller.Handler;
import com.cskefu.cc.interceptor.UserExperiencePlanInterceptorHandler;
import com.cskefu.cc.util.restapi.RestUtils;
@ -79,12 +80,6 @@ public class IMController extends Handler {
@Autowired
private PassportWebIMUserRepository onlineUserRes;
@Value("${uk.im.server.host}")
private String host;
@Value("${uk.im.server.port}")
private Integer port;
@Value("${web.upload-path}")
private String path;
@ -662,8 +657,7 @@ public class IMController extends Handler {
String schema = super.getSchema(request);
map.addAttribute("port", port);
map.addAttribute("port", MainContext.getContext().getBean(MessagingServerConfigure.class).getWebIMPort());
map.addAttribute("appid", appid);
map.addAttribute("userid", userid);
map.addAttribute("schema", schema);

View File

@ -30,6 +30,7 @@ server.context-path=/
uk.im.server.port=8036
uk.im.server.host=localhost
uk.im.server.threads=1000
cs.im.server.ssl.port=
spring.mvc.servlet.load-on-startup=1
spring.servlet.multipart.enabled=true