升级组件版本

This commit is contained in:
远方夕阳 2022-08-29 20:24:42 +08:00
parent 7a9a369960
commit a0ddbe47c5
35 changed files with 264 additions and 50 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.farsunset</groupId>
<artifactId>cim-boot-server</artifactId>
<version>1.2.0</version>
<version>4.2.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
@ -17,10 +17,10 @@
<properties>
<java.version>1.8</java.version>
<netty.version>4.1.70.Final</netty.version>
<protobuf.version>3.19.2</protobuf.version>
<mysql.jdbc.version>8.0.22</mysql.jdbc.version>
<common.pool.version>2.8.0</common.pool.version>
<netty.version>4.1.79.Final</netty.version>
<protobuf.version>3.21.5</protobuf.version>
<mysql.jdbc.version>8.0.30</mysql.jdbc.version>
<common.pool.version>2.11.1</common.pool.version>
<swagger.version>3.0.0</swagger.version>
</properties>
<dependencies>
@ -132,7 +132,7 @@
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.7</version>
<version>2.11.0</version>
</dependency>
<dependency>

View File

@ -1 +1 @@
java -Dcom.sun.akuma.Daemon=daemonized -Dspring.profiles.active=pro -jar ./cim-boot-server-4.0.0.jar
java -Dcom.sun.akuma.Daemon=daemonized -Dspring.profiles.active=pro -jar ./cim-boot-server-4.2.0.jar

View File

@ -1,3 +1,3 @@
#! /bin/bash
java -Dcom.sun.akuma.Daemon=daemonized -Dspring.profiles.active=pro -jar ./cim-boot-server-4.0.0.jar &
java -Dcom.sun.akuma.Daemon=daemonized -Dspring.profiles.active=pro -jar ./cim-boot-server-4.2.0.jar &

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -0,0 +1,37 @@
/*
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
***************************************************************************************
* *
* Website : http://www.farsunset.com *
* *
***************************************************************************************
*/
package com.farsunset.cim.component.event;
import com.farsunset.cim.model.Message;
import org.springframework.context.ApplicationEvent;
public class MessageEvent extends ApplicationEvent {
public MessageEvent(Message message) {
super(message);
}
@Override
public Message getSource() {
return (Message) source;
}
}

View File

@ -0,0 +1,37 @@
/*
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
***************************************************************************************
* *
* Website : http://www.farsunset.com *
* *
***************************************************************************************
*/
package com.farsunset.cim.component.event;
import com.farsunset.cim.entity.Session;
import org.springframework.context.ApplicationEvent;
public class SessionEvent extends ApplicationEvent {
public SessionEvent(Session session) {
super(session);
}
@Override
public Session getSource() {
return (Session) source;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,8 +23,8 @@ package com.farsunset.cim.component.handler;
import com.farsunset.cim.component.handler.annotation.CIMHandler;
import com.farsunset.cim.component.redis.SignalRedisTemplate;
import com.farsunset.cim.entity.Session;
import com.farsunset.cim.constant.ChannelAttr;
import com.farsunset.cim.entity.Session;
import com.farsunset.cim.group.SessionGroup;
import com.farsunset.cim.handler.CIMRequestHandler;
import com.farsunset.cim.model.ReplyBody;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -22,8 +22,8 @@
package com.farsunset.cim.component.handler;
import com.farsunset.cim.component.handler.annotation.CIMHandler;
import com.farsunset.cim.entity.Session;
import com.farsunset.cim.constant.ChannelAttr;
import com.farsunset.cim.entity.Session;
import com.farsunset.cim.group.SessionGroup;
import com.farsunset.cim.handler.CIMRequestHandler;
import com.farsunset.cim.model.SentBody;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,11 +1,34 @@
/*
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
***************************************************************************************
* *
* Website : http://www.farsunset.com *
* *
***************************************************************************************
*/
package com.farsunset.cim.component.message;
import com.farsunset.cim.entity.Session;
import com.farsunset.cim.component.event.SessionEvent;
import com.farsunset.cim.constant.ChannelAttr;
import com.farsunset.cim.entity.Session;
import com.farsunset.cim.group.SessionGroup;
import com.farsunset.cim.model.Message;
import com.farsunset.cim.util.JSONUtils;
import io.netty.channel.Channel;
import org.springframework.context.event.EventListener;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;
@ -43,10 +66,21 @@ public class BindMessageListener implements MessageListener {
conflictMap.put(Session.CHANNEL_MAC,new String[]{Session.CHANNEL_WINDOWS,Session.CHANNEL_WEB,Session.CHANNEL_MAC});
}
@EventListener
public void onMessage(SessionEvent event) {
this.handle(event.getSource());
}
@Override
public void onMessage(org.springframework.data.redis.connection.Message redisMessage, byte[] bytes) {
Session session = JSONUtils.fromJson(redisMessage.getBody(), Session.class);
this.handle(session);
}
private void handle(Session session) {
String uid = session.getUid();
String[] conflictChannels = conflictMap.get(session.getChannel());

View File

@ -1,8 +1,31 @@
/*
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
***************************************************************************************
* *
* Website : http://www.farsunset.com *
* *
***************************************************************************************
*/
package com.farsunset.cim.component.message;
import com.farsunset.cim.component.event.MessageEvent;
import com.farsunset.cim.group.SessionGroup;
import com.farsunset.cim.model.Message;
import com.farsunset.cim.util.JSONUtils;
import org.springframework.context.event.EventListener;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;
@ -24,9 +47,19 @@ public class PushMessageListener implements MessageListener {
Message message = JSONUtils.fromJson(redisMessage.getBody(), Message.class);
this.onMessage(message);
}
@EventListener
public void onMessage(MessageEvent event) {
this.onMessage(event.getSource());
}
public void onMessage(Message message) {
String uid = message.getReceiver();
sessionGroup.write(uid,message);
}
}

View File

@ -1,3 +1,24 @@
/*
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
***************************************************************************************
* *
* Website : http://www.farsunset.com *
* *
***************************************************************************************
*/
package com.farsunset.cim.component.predicate;
import com.farsunset.cim.handshake.HandshakeEvent;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -21,17 +21,31 @@
*/
package com.farsunset.cim.component.redis;
import com.farsunset.cim.component.event.MessageEvent;
import com.farsunset.cim.component.event.SessionEvent;
import com.farsunset.cim.constants.Constants;
import com.farsunset.cim.entity.Session;
import com.farsunset.cim.model.Message;
import com.farsunset.cim.util.JSONUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Objects;
@Component
public class SignalRedisTemplate extends StringRedisTemplate {
@Value("${spring.profiles.active}")
private String env;
@Resource
private ApplicationContext applicationContext;
public SignalRedisTemplate(LettuceConnectionFactory connectionFactory) {
super(connectionFactory);
connectionFactory.setValidateConnection(true);
@ -42,6 +56,10 @@ public class SignalRedisTemplate extends StringRedisTemplate {
* @param message
*/
public void push(Message message) {
if (isDev()){
applicationContext.publishEvent(new MessageEvent(message));
return;
}
super.convertAndSend(Constants.PUSH_MESSAGE_INNER_QUEUE, JSONUtils.toJSONString(message));
}
@ -50,6 +68,19 @@ public class SignalRedisTemplate extends StringRedisTemplate {
* @param session
*/
public void bind(Session session) {
if (isDev()){
applicationContext.publishEvent(new SessionEvent(session));
return;
}
super.convertAndSend(Constants.BIND_MESSAGE_INNER_QUEUE, JSONUtils.toJSONString(session));
}
/**
* 本地调试环境下不走redis避免lettuce 经常command timeout
* @return
*/
private boolean isDev(){
return Objects.equals(env,"dev");
}
}

View File

@ -1,3 +1,24 @@
/*
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* 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.
*
***************************************************************************************
* *
* Website : http://www.farsunset.com *
* *
***************************************************************************************
*/
package com.farsunset.cim.config;
import com.farsunset.cim.acceptor.AppSocketAcceptor;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,22 +23,20 @@ package com.farsunset.cim.entity;
import javax.persistence.*;
import java.io.Serializable;
@Entity
@Table(name = "t_hoxin_session")
public class Session implements Serializable {
public class Session{
private static final transient long serialVersionUID = 1L;
public static final transient int STATE_ACTIVE = 0;
public static final transient int STATE_APNS = 1;
public static final transient int STATE_INACTIVE = 2;
public static final int STATE_ACTIVE = 0;
public static final int STATE_APNS = 1;
public static final int STATE_INACTIVE = 2;
public static final transient String CHANNEL_IOS = "ios";
public static final transient String CHANNEL_ANDROID = "android";
public static final transient String CHANNEL_WINDOWS = "windows";
public static final transient String CHANNEL_MAC = "mac";
public static final transient String CHANNEL_WEB = "web";
public static final String CHANNEL_IOS = "ios";
public static final String CHANNEL_ANDROID = "android";
public static final String CHANNEL_WINDOWS = "windows";
public static final String CHANNEL_MAC = "mac";
public static final String CHANNEL_WEB = "web";
/**
* 数据库主键ID

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -23,8 +23,6 @@ package com.farsunset.cim.mvc.controller.admin;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
@Controller

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013-2019 Xia Jun(3979434@qq.com).
* Copyright 2013-2022 Xia Jun(3979434@qq.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.

View File

@ -1,6 +1,10 @@
server.port=8080
#单台服务器可设置为dev广播消息走本地消息事件(参见SignalRedisTemplate.java)
#多台服务器集群环境设置为prd广播消息走三方消息队列
spring.profiles.active=dev
##################################################################
# JDBC Config #
##################################################################