From 28360726022e9628628d93072a6d97c881c79679 Mon Sep 17 00:00:00 2001 From: duke <565572696> Date: Thu, 13 Jul 2023 19:45:22 +0800 Subject: [PATCH] #868 fix bug --- .../cc/config/MessagingServerConfigure.java | 29 +++++++++---------- .../cc/controller/apps/IMController.java | 18 ++++-------- .../src/main/resources/application.properties | 1 + 3 files changed, 21 insertions(+), 27 deletions(-) diff --git a/contact-center/app/src/main/java/com/cskefu/cc/config/MessagingServerConfigure.java b/contact-center/app/src/main/java/com/cskefu/cc/config/MessagingServerConfigure.java index dd7659f9..adb25993 100644 --- a/contact-center/app/src/main/java/com/cskefu/cc/config/MessagingServerConfigure.java +++ b/contact-center/app/src/main/java/com/cskefu/cc/config/MessagingServerConfigure.java @@ -20,38 +20,42 @@ 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() { - return port; + if (sslPort != null) { + return sslPort; + } else { + return port; + } } + @Autowired + private ServerProperties serverProperties; + @Bean public SocketIOServer socketIOServer() { Configuration config = new Configuration(); @@ -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; - } } \ No newline at end of file diff --git a/contact-center/app/src/main/java/com/cskefu/cc/controller/apps/IMController.java b/contact-center/app/src/main/java/com/cskefu/cc/controller/apps/IMController.java index e4b14500..e6afc0a4 100644 --- a/contact-center/app/src/main/java/com/cskefu/cc/controller/apps/IMController.java +++ b/contact-center/app/src/main/java/com/cskefu/cc/controller/apps/IMController.java @@ -1,15 +1,15 @@ /* - * Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. - * , Licensed under the Chunsong Public + * Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd. + * , Licensed under the Chunsong Public * License, Version 1.0 (the "License"), https://docs.cskefu.com/licenses/v1.html * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * Copyright (C) 2018-Jun. 2023 Chatopera Inc, , Licensed under the Apache License, Version 2.0, + * Copyright (C) 2018-Jun. 2023 Chatopera Inc, , Licensed under the Apache License, Version 2.0, * http://www.apache.org/licenses/LICENSE-2.0 - * Copyright (C) 2017 优客服-多渠道客服系统, Licensed under the Apache License, Version 2.0, + * Copyright (C) 2017 优客服-多渠道客服系统, Licensed under the Apache License, Version 2.0, * http://www.apache.org/licenses/LICENSE-2.0 */ @@ -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); diff --git a/contact-center/app/src/main/resources/application.properties b/contact-center/app/src/main/resources/application.properties index d5abd1f2..649aea85 100644 --- a/contact-center/app/src/main/resources/application.properties +++ b/contact-center/app/src/main/resources/application.properties @@ -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