mirror of
https://github.com/chatopera/cosin.git
synced 2025-08-01 16:38:02 +08:00
#868 fix bug
This commit is contained in:
parent
da8f78e2d9
commit
2836072602
@ -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;
|
||||
}
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
/*
|
||||
* Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd.
|
||||
* <https://www.chatopera.com>, Licensed under the Chunsong Public
|
||||
* Copyright (C) 2023 Beijing Huaxia Chunsong Technology Co., Ltd.
|
||||
* <https://www.chatopera.com>, 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, <https://www.chatopera.com>, Licensed under the Apache License, Version 2.0,
|
||||
* Copyright (C) 2018-Jun. 2023 Chatopera Inc, <https://www.chatopera.com>, 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);
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user