diff --git a/cim-boot-server/cim-boot-server.iml b/cim-boot-server/cim-boot-server.iml
index 896b652..f04276c 100644
--- a/cim-boot-server/cim-boot-server.iml
+++ b/cim-boot-server/cim-boot-server.iml
@@ -25,46 +25,46 @@
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
+
diff --git a/cim-boot-server/cim-boot-server.ipr b/cim-boot-server/cim-boot-server.ipr
index f85e559..3e89788 100644
--- a/cim-boot-server/cim-boot-server.ipr
+++ b/cim-boot-server/cim-boot-server.ipr
@@ -121,59 +121,59 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -352,37 +352,37 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -396,15 +396,15 @@
-
+
-
+
-
+
-
+
@@ -440,191 +440,191 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/cim-boot-server/cim-boot-server.iws b/cim-boot-server/cim-boot-server.iws
index 397bba6..7155dfe 100644
--- a/cim-boot-server/cim-boot-server.iws
+++ b/cim-boot-server/cim-boot-server.iws
@@ -18,26 +18,100 @@
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -46,22 +120,33 @@
-
+
-
-
+
+
+
+
+
+
+
+
CIMWebBridge
- memorySessionService
cim-server-sdk-mina-3.7.0.jar
cim.server.port
+ memorySessionService
+ Logger
CIMPushManager
@@ -74,9 +159,19 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -90,7 +185,6 @@
-
@@ -126,23 +220,22 @@
-
-
+
-
-
-
+
+
+
@@ -219,17 +312,18 @@
+
-
+
-
+
@@ -237,7 +331,7 @@
-
+
@@ -247,7 +341,7 @@
-
+
@@ -302,27 +396,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -330,23 +403,197 @@
-
+
-
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/cim-boot-server/lib/cim-server-sdk-netty-3.7.0.jar b/cim-boot-server/lib/cim-server-sdk-netty-3.7.0.jar
index 1c6e9d5..acb64a5 100644
Binary files a/cim-boot-server/lib/cim-server-sdk-netty-3.7.0.jar and b/cim-boot-server/lib/cim-server-sdk-netty-3.7.0.jar differ
diff --git a/cim-boot-server/pom.xml b/cim-boot-server/pom.xml
index 6f92bd3..5e554d8 100644
--- a/cim-boot-server/pom.xml
+++ b/cim-boot-server/pom.xml
@@ -11,7 +11,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.1.5.RELEASE
+ 2.1.6.RELEASE
@@ -39,10 +39,10 @@
com.farsunset
cim-server-sdk
- 3.7
+ 3.7.0
system
-
- ${project.basedir}/lib/cim-server-sdk-mina-3.7.0.jar
+
+ ${project.basedir}/lib/cim-server-sdk-netty-3.7.0.jar
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/SessionController.java b/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/SessionController.java
index ecf240b..c360cf0 100644
--- a/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/SessionController.java
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/SessionController.java
@@ -21,13 +21,12 @@
*/
package com.farsunset.cim.admin.controller;
-import javax.annotation.Resource;
-
+import com.farsunset.cim.service.CIMSessionService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
-import com.farsunset.cim.service.CIMSessionService;
+import javax.annotation.Resource;
@Controller
@RequestMapping("/console/session")
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/MessageController.java b/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/MessageController.java
index c42ed85..6a98061 100644
--- a/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/MessageController.java
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/MessageController.java
@@ -21,32 +21,23 @@
*/
package com.farsunset.cim.api.controller;
-import javax.annotation.Resource;
-
+import com.farsunset.cim.api.controller.dto.MessageResult;
+import com.farsunset.cim.push.DefaultMessagePusher;
+import com.farsunset.cim.sdk.server.model.Message;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
-import com.farsunset.cim.api.controller.dto.MessageResult;
-import com.farsunset.cim.push.DefaultMessagePusher;
-import com.farsunset.cim.push.SystemMessagePusher;
-import com.farsunset.cim.sdk.server.model.Message;
-import com.farsunset.cim.util.Constants;
+import javax.annotation.Resource;
@RestController
@RequestMapping("/api/message")
public class MessageController {
-
-
- @Resource
- private SystemMessagePusher systemMessagePusher;
-
@Resource
private DefaultMessagePusher defaultMessagePusher;
-
/**
* 此方法仅仅在集群时,通过服务器调用
*
@@ -65,11 +56,9 @@ public class MessageController {
MessageResult result = new MessageResult();
message.setId(System.currentTimeMillis());
- if (Constants.MessageType.TYPE_2.equals(message.getAction())) {
- systemMessagePusher.push(message);
- } else {
- defaultMessagePusher.push(message);
- }
+
+ defaultMessagePusher.push(message);
+
result.id = message.getId();
result.timestamp = message.getTimestamp();
return result;
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/BaseResult.java b/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/BaseResult.java
index 02b8198..1c45609 100644
--- a/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/BaseResult.java
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/BaseResult.java
@@ -21,10 +21,10 @@
*/
package com.farsunset.cim.api.controller.dto;
-import java.util.List;
-
import org.springframework.http.HttpStatus;
+import java.util.List;
+
public class BaseResult {
public int code = HttpStatus.OK.value();
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/CIMConfig.java b/cim-boot-server/src/main/java/com/farsunset/cim/config/CIMConfig.java
similarity index 84%
rename from cim-boot-server/src/main/java/com/farsunset/cim/CIMConfig.java
rename to cim-boot-server/src/main/java/com/farsunset/cim/config/CIMConfig.java
index 84ecbde..96eefba 100644
--- a/cim-boot-server/src/main/java/com/farsunset/cim/CIMConfig.java
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/config/CIMConfig.java
@@ -1,11 +1,11 @@
-package com.farsunset.cim;
+package com.farsunset.cim.config;
-import java.util.HashMap;
-
-import javax.annotation.PostConstruct;
-import javax.annotation.Resource;
-
-import org.springframework.beans.factory.annotation.Qualifier;
+import com.farsunset.cim.handler.BindHandler;
+import com.farsunset.cim.handler.SessionClosedHandler;
+import com.farsunset.cim.sdk.server.handler.CIMNioSocketAcceptor;
+import com.farsunset.cim.sdk.server.handler.CIMRequestHandler;
+import com.farsunset.cim.sdk.server.model.CIMSession;
+import com.farsunset.cim.sdk.server.model.SentBody;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.event.ApplicationStartedEvent;
import org.springframework.context.ApplicationContext;
@@ -13,13 +13,9 @@ import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import com.farsunset.cim.handler.BindHandler;
-import com.farsunset.cim.handler.SessionClosedHandler;
-import com.farsunset.cim.sdk.server.handler.CIMNioSocketAcceptor;
-import com.farsunset.cim.sdk.server.handler.CIMRequestHandler;
-import com.farsunset.cim.sdk.server.model.SentBody;
-import com.farsunset.cim.service.CIMSessionService;
-import com.farsunset.cim.sdk.server.model.CIMSession;
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import java.util.HashMap;
@Configuration
public class CIMConfig implements CIMRequestHandler, ApplicationListener {
@@ -48,17 +44,6 @@ public class CIMConfig implements CIMRequestHandler, ApplicationListener map = new ConcurrentHashMap<>();
+
+
+ public void save(CIMSession session){
+ map.put(session.getAccount(),session);
+ }
+
+ public CIMSession get(String account){
+ return map.get(account);
+ }
+
+ public void remove(String account){
+ map.remove(account);
+ }
+
+ public List findAll(){
+ return new LinkedList<>(map.values());
+ }
+}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/service/CIMSessionService.java b/cim-boot-server/src/main/java/com/farsunset/cim/service/CIMSessionService.java
index 45fb9c8..50e355b 100644
--- a/cim-boot-server/src/main/java/com/farsunset/cim/service/CIMSessionService.java
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/service/CIMSessionService.java
@@ -21,10 +21,10 @@
*/
package com.farsunset.cim.service;
-import java.util.List;
-
import com.farsunset.cim.sdk.server.model.CIMSession;
+import java.util.List;
+
/**
* 集群 session管理实现示例, 各位可以自行实现 AbstractSessionManager接口来实现自己的 session管理 服务器集群时
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/ClusterSessionServiceImpl.java b/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/CIMSessionServiceImpl.java
similarity index 75%
rename from cim-boot-server/src/main/java/com/farsunset/cim/service/impl/ClusterSessionServiceImpl.java
rename to cim-boot-server/src/main/java/com/farsunset/cim/service/impl/CIMSessionServiceImpl.java
index 645df62..4ba00e7 100644
--- a/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/ClusterSessionServiceImpl.java
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/CIMSessionServiceImpl.java
@@ -22,52 +22,55 @@
package com.farsunset.cim.service.impl;
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-
+import com.farsunset.cim.repository.SessionRepository;
import com.farsunset.cim.sdk.server.handler.CIMNioSocketAcceptor;
import com.farsunset.cim.sdk.server.model.CIMSession;
import com.farsunset.cim.service.CIMSessionService;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.List;
-/**
- * 集群情况下,数据库或者redis存储实现
- * 自行实现存储管理
- *
- */
-@Service("clusterSessionService")
-public class ClusterSessionServiceImpl implements CIMSessionService {
+@Service
+public class CIMSessionServiceImpl implements CIMSessionService {
@Resource
private CIMNioSocketAcceptor nioSocketAcceptor;
-
+
+ @Resource
+ private SessionRepository sessionRepository;
+
@Override
public void save(CIMSession session) {
-
+ sessionRepository.save(session);
}
+ /**
+ *
+ * @param account 用户id
+ * @return
+ */
@Override
public CIMSession get(String account) {
- /*
- * CIMSession session = database.getSession(account);
- * session.setIoSession(nioSocketAcceptor.getManagedSessions().get(session.getNid()));
- * return session;
- */
-
- return null;
+ CIMSession session = sessionRepository.get(account);
+
+ if (session != null){
+ session.setSession(nioSocketAcceptor.getManagedSession(session.getNid()));
+ }
+
+ return session;
}
@Override
public void remove(String account) {
+ sessionRepository.remove(account);
}
@Override
public List list() {
- return null;
+ return sessionRepository.findAll();
}
}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/JavaApnsServiceImpl.java b/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/JavaApnsServiceImpl.java
index d82f591..b164bf5 100644
--- a/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/JavaApnsServiceImpl.java
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/JavaApnsServiceImpl.java
@@ -21,26 +21,27 @@
*/
package com.farsunset.cim.service.impl;
-import java.io.InputStream;
-import java.util.logging.Logger;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-
-import com.farsunset.cim.sdk.server.model.Message;
-import com.farsunset.cim.service.ApnsService;
-import com.farsunset.cim.util.ApnsPayloadCompat;
-
import cn.teaey.apns4j.Apns4j;
import cn.teaey.apns4j.network.ApnsChannel;
import cn.teaey.apns4j.network.ApnsChannelFactory;
import cn.teaey.apns4j.network.ApnsGateway;
+import com.farsunset.cim.sdk.server.model.Message;
+import com.farsunset.cim.service.ApnsService;
+import com.farsunset.cim.util.ApnsPayloadCompat;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.InputStream;
@Service
public class JavaApnsServiceImpl implements ApnsService {
- private final Logger logger = Logger.getLogger(JavaApnsServiceImpl.class.getName());
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(JavaApnsServiceImpl.class);
+
@Value("${apple.apns.p12.password}")
private String password;
@Value("${apple.apns.p12.file}")
@@ -73,11 +74,10 @@ public class JavaApnsServiceImpl implements ApnsService {
apnsPayload.setFormat(message.getFormat());
apnsPayload.setReceiver(message.getReceiver());
apnsChannel.send(deviceToken, apnsPayload);
-
- logger.info(deviceToken +"\r\ndata:" +apnsPayload.toJsonString());
- }catch(Exception e) {
- e.printStackTrace();
- logger.severe(e.getLocalizedMessage());
+
+ LOGGER.info(deviceToken +"\r\ndata: {}",apnsPayload.toJsonString());
+ }catch(Exception exception) {
+ LOGGER.error("Apns has error",exception);
}finally {
apnsChannel.close();
IOUtils.closeQuietly(stream);
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/MemorySessionServiceImpl.java b/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/MemorySessionServiceImpl.java
deleted file mode 100644
index 200b264..0000000
--- a/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/MemorySessionServiceImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright 2013-2019 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.service.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.springframework.stereotype.Service;
-
-import com.farsunset.cim.sdk.server.model.CIMSession;
-import com.farsunset.cim.service.CIMSessionService;
-
-
-/**
- * 单机,内存存储实现
- *
- */
-@Service("memorySessionService")
-public class MemorySessionServiceImpl implements CIMSessionService {
-
- private ConcurrentHashMap sessionMap = new ConcurrentHashMap();
-
- @Override
- public void save(CIMSession session) {
- if(session.getState() == CIMSession.STATE_DISABLED ) {
- remove(session.getAccount());
- return;
- }
- sessionMap.put(session.getAccount(), session);
- }
-
- @Override
- public CIMSession get(String account) {
- return sessionMap.get(account);
- }
-
- @Override
- public void remove(String account) {
- sessionMap.remove(account);
- }
-
- @Override
- public List list() {
- List onlineList = new ArrayList<>();
- onlineList.addAll(sessionMap.values());
- return onlineList;
- }
-
-}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/util/ApnsPayloadCompat.java b/cim-boot-server/src/main/java/com/farsunset/cim/util/ApnsPayloadCompat.java
index 2cb6566..0604407 100644
--- a/cim-boot-server/src/main/java/com/farsunset/cim/util/ApnsPayloadCompat.java
+++ b/cim-boot-server/src/main/java/com/farsunset/cim/util/ApnsPayloadCompat.java
@@ -25,7 +25,7 @@ import cn.teaey.apns4j.protocol.ApnsPayload;
public class ApnsPayloadCompat extends ApnsPayload {
- public static final String DATA = "{\"aps\": {\"message\": {\"action\":\"%s\",\"content\":\"%s\",\"sender\":\"%s\",\"receiver\":\"%s\",\"format\":\"%s\"},\"content-available\": 1}}";
+ private static final String DATA_FORMAT = "{\"aps\": {\"message\": {\"action\":\"%s\",\"content\":\"%s\",\"sender\":\"%s\",\"receiver\":\"%s\",\"format\":\"%s\"},\"content-available\": 1}}";
private String action;
private String content;
@@ -74,7 +74,8 @@ public class ApnsPayloadCompat extends ApnsPayload {
this.format = format;
}
+ @Override
public String toJsonString() {
- return String.format(DATA, action, content, sender,receiver,format);
+ return String.format(DATA_FORMAT, action, content, sender,receiver,format);
}
}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/util/Constants.java b/cim-boot-server/src/main/java/com/farsunset/cim/util/Constants.java
deleted file mode 100644
index 76fe196..0000000
--- a/cim-boot-server/src/main/java/com/farsunset/cim/util/Constants.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright 2013-2019 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.util;
-
-public interface Constants {
-
- public class Common {
- public final static String STATUS_1 = "1";
- public final static String STATUS_0 = "0";
- public final static String STATUS_2 = "2";
- public final static String STATUS_3 = "3";
- public final static String TYPR_1 = "1";
- public final static String TYPR_2 = "2";
- public final static String TYPR_9 = "9";
-
- }
-
- public class User {
- public final static Integer SUCCESS_CODE = 1;
- public final static Integer ERROR_CODE = 0;
- public final static String User = "User";
-
- }
-
- public class RequestParam {
- public final static String CURRENTPAGE = "currentPage";
- public final static String TYPE = "type";
- public static final String SIZE = "size";
-
- }
-
- public class Number {
-
- public final static Integer INT_0 = 0;
- public final static Integer INT_10 = 10;
- public final static Integer INT_403 = 403;
-
- }
-
- public static interface MessageType {
-
- // 用户之间的普通消息
- public static final String TYPE_0 = "0";
-
- // 系统向用户发送的普通消息
- public static final String TYPE_2 = "2";
-
- }
-
-}
diff --git a/cim-boot-server/src/main/java/com/farsunset/cim/util/StringUtil.java b/cim-boot-server/src/main/java/com/farsunset/cim/util/StringUtil.java
deleted file mode 100644
index fdd07b9..0000000
--- a/cim-boot-server/src/main/java/com/farsunset/cim/util/StringUtil.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/**
- * Copyright 2013-2019 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.util;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.UUID;
-
-public class StringUtil {
-
- public static boolean isEmpty(Object obj) {
- if (null == obj)
- return true;
- if ("".equals(obj.toString().trim())) {
- return true;
- }
- return false;
- }
-
- public static boolean isNotEmpty(Object obj) {
-
- return !isEmpty(obj);
- }
-
- public static String getSequenceId() {
- String mark = String.valueOf(System.currentTimeMillis());
- return mark;
- }
-
- public static String getCurrentlyDateTime() {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
- return dateFormat.format(new Date());
- }
-
- public static String transformDateTime(long t) {
- Date date = new Date(t);
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- return dateFormat.format(date);
- }
-
- public static String getCurrentlyDate() {
- SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
- return dateFormat.format(new Date());
- }
-
- public static String getUUID() {
- return UUID.randomUUID().toString().replaceAll("-", "");
- }
-
-}
diff --git a/cim-boot-server/src/main/resources/application.properties b/cim-boot-server/src/main/resources/application.properties
index 2ad65af..a30c355 100644
--- a/cim-boot-server/src/main/resources/application.properties
+++ b/cim-boot-server/src/main/resources/application.properties
@@ -1,5 +1,7 @@
server.port=8080
-server.host=192.168.1.100
+server.host=127.0.0.1
+
+
##################################################################
# Freemarker Config #
##################################################################
@@ -11,6 +13,8 @@ spring.freemarker.templateLoaderPath=classpath:/page/
spring.freemarker.settings.auto_import = /ftl/spring.ftl as spring
spring.messages.encoding=UTF-8
spring.messages.basename=i18n/messages
+
+
##################################################################
# CIM Config #
##################################################################
@@ -18,14 +22,6 @@ cim.server.port=23456
apple.apns.debug=false
apple.apns.p12.password= your p12 password
apple.apns.p12.file= /apns/lvxin.p12
-##################################################################
-# Undertow Config #
-##################################################################
-server.undertow.accesslog.enabled=false
-server.undertow.worker-threads=16
-server.undertow.io-threads=8
-server.undertow.buffer-size=1024
-server.undertow.direct-buffers=true
##################################################################
diff --git a/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java
index 7ed402c..82bb1ab 100644
--- a/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java
+++ b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java
@@ -34,6 +34,7 @@ import android.net.Network;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
+import android.util.Log;
import com.farsunset.cim.sdk.android.coder.CIMLogger;
import com.farsunset.cim.sdk.android.constant.CIMConstant;
@@ -173,6 +174,11 @@ public class CIMPushService extends Service {
String host = CIMCacheManager.getString(this, CIMCacheManager.KEY_CIM_SERVIER_HOST);
int port = CIMCacheManager.getInt(this, CIMCacheManager.KEY_CIM_SERVIER_PORT);
+ if(host == null || host.trim().length() == 0 || port <= 0) {
+ Log.e(this.getClass().getSimpleName(), "Invalid hostname or port. host:" + host + " port:" + port);
+ return;
+ }
+
manager.connect(host, port);
}
diff --git a/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java
index 88bd1c4..49f870f 100644
--- a/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java
+++ b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java
@@ -73,7 +73,7 @@ public class CIMNioSocketAcceptor extends SimpleChannelInboundHandler
public void bind() {
- /**
+ /*
* 预制websocket握手请求的处理
*/
innerHandlerMap.put(CIMConstant.CLIENT_WEBSOCKET_HANDSHAKE, new WebsocketHandler());
@@ -135,7 +135,7 @@ public class CIMNioSocketAcceptor extends SimpleChannelInboundHandler
CIMSession session = new CIMSession(ctx.channel());
CIMRequestHandler handler = innerHandlerMap.get(body.getKey());
- /**
+ /*
* 如果有内置的特殊handler需要处理,则使用内置的
*/
if (handler != null) {
@@ -143,7 +143,7 @@ public class CIMNioSocketAcceptor extends SimpleChannelInboundHandler
return;
}
- /**
+ /*
* 有业务层去处理其他的sentbody
*/
outerRequestHandler.process(session, body);
@@ -172,7 +172,9 @@ public class CIMNioSocketAcceptor extends SimpleChannelInboundHandler
ctx.channel().writeAndFlush(HeartbeatRequest.getInstance());
}
- // 如果心跳请求发出30秒内没收到响应,则关闭连接
+ /*
+ * 如果心跳请求发出30秒内没收到响应,则关闭连接
+ */
if (evt instanceof IdleStateEvent && ((IdleStateEvent) evt).state().equals(IdleState.READER_IDLE)) {
Long lastTime = (Long) ctx.channel().attr(AttributeKey.valueOf(CIMConstant.HEARTBEAT_KEY)).get();
@@ -189,7 +191,7 @@ public class CIMNioSocketAcceptor extends SimpleChannelInboundHandler
}
- public Channel getManagedChannel(String id) {
+ public Channel getManagedSession(String id) {
if (id == null) {
return null;
}
diff --git a/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/CIMSession.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/CIMSession.java
index 2c3b160..4bd338c 100644
--- a/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/CIMSession.java
+++ b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/CIMSession.java
@@ -84,6 +84,12 @@ public class CIMSession implements Serializable {
}
+
+ public void setSession(Channel session) {
+ this.session = session;
+ }
+
+
public String getAccount() {
return account;
}