diff --git a/3.6.0.VERSION b/3.7.0.VERSION similarity index 100% rename from 3.6.0.VERSION rename to 3.7.0.VERSION diff --git a/README.md b/README.md index a5cd0f7..be791ea 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ #### 项目介绍 -CIM是基于mina和netty框架下的推送系统,我们平常使用第三方的推送SDK,如极光推送,百度推送,小米推送,以及腾讯信鸽等来支撑自己的移动端的业务,或许有一些用户自己实现即时通讯系统的需求,那么CIM为您提供了一个解决方案或者思路,目前CIM支撑 websocket,android,ios,桌面应用,系统应用等多端接入支持,目前CIM服务端使用springboot搭建仅仅拥有消息推送的功能,关于数据缓存与持久化都需要使用者自己开发,但是配备了比较完整的使用文档。最后希望CIM能为您带来一些价值。 +CIM是基于mina或者netty框架下的推送系统,我们平常使用第三方的推送SDK,如极光推送,百度推送,小米推送,以及腾讯信鸽等来支撑自己的移动端的业务,或许有一些用户自己实现即时通讯系统的需求,那么CIM为您提供了一个解决方案或者思路,目前CIM支撑 websocket,android,ios,桌面应用,系统应用等多端接入支持,目前CIM服务端使用springboot搭建仅仅拥有消息推送的功能,关于数据缓存与持久化都需要使用者自己开发,但是配备了比较完整的使用文档。最后希望CIM能为您带来一些价值。 --- ## 相关项目 @@ -14,16 +14,13 @@ CIM是基于mina和netty框架下的推送系统,我们平常使用第三方 --- #### 目录说明 +1.cim-use-examples是各个客户端使用示例 +2.cim-client-sdk 是各个客户端的SDK源码 +3.cim-server-sdk 是服务端SDK源码,分为 mina和netty 两个版本,二者任选其一 +4.cim-boot-server是springboot服务端工程源码,使用Idea工具开发 + +其中所有的sdk均为Eclipse工程,打包成jar导出引入到对应的客户端或服务端工程 -1. cim_for_mina目录下为mina版本实现 -2. cim_for_netty目录下为netty版本实现 -3. doc目录中是相关使用文档,以及protubuf结构体文件 -5. cim-android-sdk 是android客户端封装的的jar包 -6. cim-java-sdk 是java版客户端封装的的jar包 -7. cim-server-sdk 是cim-boot-server 用到的封装的jar -8. cim-boot-server是springboot服务端工程,是intellij idea基于gradle构建 -9. cim-client-android 是android客户端 android studio工具 -10. 说明.txt是服务端环境搭建说明 #### 建议反馈 @@ -59,7 +56,18 @@ CIM是基于mina和netty框架下的推送系统,我们平常使用第三方 3.消息的id字段名由mid修改为id,类型由String修改为long; - +------------------------------------------------------------------------------------------- +版本:3.7.0/时间:2019-05-13 + +1.服务端cim-boot-server修改为idea maven工程 + +2.android sdk优化升级,去除mina或netty相关包的依赖 + +3.java sdk优化升级,去除mina或netty相关包的依赖 + +4.新增web sdk,可以由index.html快速启动demo + +5.修正文档中一些疏漏 diff --git a/cim-boot-server/cim-boot-server.iml b/cim-boot-server/cim-boot-server.iml new file mode 100644 index 0000000..8e0a218 --- /dev/null +++ b/cim-boot-server/cim-boot-server.iml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cim-boot-server/cim-boot-server.ipr b/cim-boot-server/cim-boot-server.ipr new file mode 100644 index 0000000..fcbe79d --- /dev/null +++ b/cim-boot-server/cim-boot-server.ipr @@ -0,0 +1,640 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cim-boot-server/cim-boot-server.iws b/cim-boot-server/cim-boot-server.iws new file mode 100644 index 0000000..d186739 --- /dev/null +++ b/cim-boot-server/cim-boot-server.iws @@ -0,0 +1,321 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + CIMWebBridge + + + CIMPushManager + + + C:\Users\Administrator\Documents\cim\cim-boot-server\src\main\resources + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cim_for_mina/cim-boot-server/src/main/resources/page/ftl/spring.ftl b/cim-boot-server/src/main/resources/page/ftl/spring.ftl similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/page/ftl/spring.ftl rename to cim-boot-server/src/main/resources/page/ftl/spring.ftl diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/css/bootstrap.min.css b/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/css/bootstrap.min.css similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/css/bootstrap.min.css rename to cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/css/bootstrap.min.css diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.eot b/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.eot rename to cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.eot diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.svg b/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.svg rename to cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.svg diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.ttf b/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.ttf rename to cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.ttf diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff b/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff rename to cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff2 b/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff2 similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff2 rename to cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff2 diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/bootstrap.min.js b/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/bootstrap.min.js similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/bootstrap.min.js rename to cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/bootstrap.min.js diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/npm.js b/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/npm.js similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/npm.js rename to cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/npm.js diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/css/common.css b/cim-boot-server/src/main/resources/static/css/common.css similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/css/common.css rename to cim-boot-server/src/main/resources/static/css/common.css diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/image/favicon.ico b/cim-boot-server/src/main/resources/static/image/favicon.ico similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/image/favicon.ico rename to cim-boot-server/src/main/resources/static/image/favicon.ico diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/image/icon.png b/cim-boot-server/src/main/resources/static/image/icon.png similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/image/icon.png rename to cim-boot-server/src/main/resources/static/image/icon.png diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/image/icon/online.svg b/cim-boot-server/src/main/resources/static/image/icon/online.svg similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/image/icon/online.svg rename to cim-boot-server/src/main/resources/static/image/icon/online.svg diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/image/icon_loading_small.gif b/cim-boot-server/src/main/resources/static/image/icon_loading_small.gif similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/image/icon_loading_small.gif rename to cim-boot-server/src/main/resources/static/image/icon_loading_small.gif diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/image/logo.svg b/cim-boot-server/src/main/resources/static/image/logo.svg similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/image/logo.svg rename to cim-boot-server/src/main/resources/static/image/logo.svg diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/image/pattern.png b/cim-boot-server/src/main/resources/static/image/pattern.png similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/image/pattern.png rename to cim-boot-server/src/main/resources/static/image/pattern.png diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/js/cim/cim.web.sdk.js b/cim-boot-server/src/main/resources/static/js/cim/cim.web.sdk.js similarity index 82% rename from cim_for_mina/cim-boot-server/src/main/resources/static/js/cim/cim.web.sdk.js rename to cim-boot-server/src/main/resources/static/js/cim/cim.web.sdk.js index 5126a28..42d63db 100644 --- a/cim_for_mina/cim-boot-server/src/main/resources/static/js/cim/cim.web.sdk.js +++ b/cim-boot-server/src/main/resources/static/js/cim/cim.web.sdk.js @@ -1,9 +1,14 @@ -var CIM_URI="ws://127.0.0.1:23456";// 修改为服务器的真实IP +/*CIM服务器IP*/ +var CIM_HOST = "127.0.0.1"; +/*CIM服务端口*/ +var CIM_PORT = 23456; +var CIM_URI="ws://"+CIM_HOST+":"+CIM_PORT; + var CMD_HEARTBEAT_RESPONSE = new Uint8Array([67,82]); var SDK_VERSION = "1.0.0"; var SDK_CHANNEL = "browser"; var APP_PACKAGE = "com.farsunset.cim"; -const ACTION_999 = "999";//特殊的消息类型,代表被服务端强制下线 +var ACTION_999 = "999";//特殊的消息类型,代表被服务端强制下线 var DATA_HEADER_LENGTH = 3; var C_H_RS = 0; @@ -14,18 +19,18 @@ var REPLYBODY = 4; var socket; var manualStop = false; -var CIMWebBridge = new Object(); -CIMWebBridge.connection = function(){ +var CIMPushManager = {}; +CIMPushManager.connection = function(){ manualStop = false; window.localStorage.account = ''; socket = new WebSocket(CIM_URI); socket.binaryType = 'arraybuffer'; - socket.onopen = CIMWebBridge.innerOnConnectionSuccessed; - socket.onmessage = CIMWebBridge.innerOnMessageReceived; - socket.onclose = CIMWebBridge.innerOnConnectionClosed; + socket.onopen = CIMPushManager.innerOnConnectionSuccessed; + socket.onmessage = CIMPushManager.innerOnMessageReceived; + socket.onclose = CIMPushManager.innerOnConnectionClosed; }; -CIMWebBridge.bindAccount = function(account){ +CIMPushManager.bindAccount = function(account){ window.localStorage.account = account; @@ -45,32 +50,32 @@ CIMWebBridge.bindAccount = function(account){ body.getDataMap().set("packageName", APP_PACKAGE); body.getDataMap().set("deviceId", deviceId); body.getDataMap().set("device", browser.name); - CIMWebBridge.sendRequest(body); + CIMPushManager.sendRequest(body); }; -CIMWebBridge.stop = function(){ +CIMPushManager.stop = function(){ manualStop = true; socket.close(); }; -CIMWebBridge.resume = function(){ +CIMPushManager.resume = function(){ manualStop = false; - CIMWebBridge.connection(); + CIMPushManager.connection(); }; -CIMWebBridge.innerOnConnectionSuccessed = function(){ +CIMPushManager.innerOnConnectionSuccessed = function(){ var account = window.localStorage.account; if(account == '' || account == undefined){ onConnectionSuccessed(); }else{ - CIMWebBridge.bindAccount(account); + CIMPushManager.bindAccount(account); } }; -CIMWebBridge.innerOnMessageReceived = function(e){ +CIMPushManager.innerOnMessageReceived = function(e){ var data = new Uint8Array(e.data); var type = data[0]; @@ -79,7 +84,7 @@ CIMWebBridge.innerOnMessageReceived = function(e){ * 收到服务端发来的心跳请求,立即回复响应,否则服务端会在10秒后断开连接 */ if(type == S_H_RQ){ - CIMWebBridge.sendHeartbeatResponse(); + CIMPushManager.sendHeartbeatResponse(); return; } @@ -114,16 +119,16 @@ CIMWebBridge.innerOnMessageReceived = function(e){ } }; -CIMWebBridge.innerOnConnectionClosed = function(e){ +CIMPushManager.innerOnConnectionClosed = function(e){ if(!manualStop){ var time = Math.floor(Math.random()*(30-15+1)+15); setTimeout(function(){ - CIMWebBridge.connection(); + CIMPushManager.connection(); },time); } }; -CIMWebBridge.sendRequest = function(body){ +CIMPushManager.sendRequest = function(body){ var data = body.serializeBinary(); var header = buildHeader(SENTBODY,data.length); @@ -133,7 +138,7 @@ CIMWebBridge.sendRequest = function(body){ socket.send(protubuf); }; -CIMWebBridge.sendHeartbeatResponse = function(){ +CIMPushManager.sendHeartbeatResponse = function(){ var data = CMD_HEARTBEAT_RESPONSE; var header = buildHeader(C_H_RS,data.length); var protubuf = new Uint8Array(data.length + header.length); diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/js/cim/message.js b/cim-boot-server/src/main/resources/static/js/cim/message.js similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/js/cim/message.js rename to cim-boot-server/src/main/resources/static/js/cim/message.js diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/js/cim/replybody.js b/cim-boot-server/src/main/resources/static/js/cim/replybody.js similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/js/cim/replybody.js rename to cim-boot-server/src/main/resources/static/js/cim/replybody.js diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/js/cim/sentbody.js b/cim-boot-server/src/main/resources/static/js/cim/sentbody.js similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/js/cim/sentbody.js rename to cim-boot-server/src/main/resources/static/js/cim/sentbody.js diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/js/common.js b/cim-boot-server/src/main/resources/static/js/common.js similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/js/common.js rename to cim-boot-server/src/main/resources/static/js/common.js diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/js/jquery-3.3.1.min.js b/cim-boot-server/src/main/resources/static/js/jquery-3.3.1.min.js similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/js/jquery-3.3.1.min.js rename to cim-boot-server/src/main/resources/static/js/jquery-3.3.1.min.js diff --git a/cim_for_mina/cim-boot-server/src/main/resources/static/js/jquery-ui.min.js b/cim-boot-server/src/main/resources/static/js/jquery-ui.min.js similarity index 100% rename from cim_for_mina/cim-boot-server/src/main/resources/static/js/jquery-ui.min.js rename to cim-boot-server/src/main/resources/static/js/jquery-ui.min.js diff --git a/cim_for_mina/cim-android-sdk/.classpath b/cim-client-sdk/cim-android-sdk/.classpath similarity index 76% rename from cim_for_mina/cim-android-sdk/.classpath rename to cim-client-sdk/cim-android-sdk/.classpath index 1a0b2f0..d11fdcc 100644 --- a/cim_for_mina/cim-android-sdk/.classpath +++ b/cim-client-sdk/cim-android-sdk/.classpath @@ -2,8 +2,6 @@ - - diff --git a/cim_for_mina/cim-android-sdk/.project b/cim-client-sdk/cim-android-sdk/.project similarity index 100% rename from cim_for_mina/cim-android-sdk/.project rename to cim-client-sdk/cim-android-sdk/.project diff --git a/cim_for_mina/cim-android-sdk/.settings/org.eclipse.core.resources.prefs b/cim-client-sdk/cim-android-sdk/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from cim_for_mina/cim-android-sdk/.settings/org.eclipse.core.resources.prefs rename to cim-client-sdk/cim-android-sdk/.settings/org.eclipse.core.resources.prefs diff --git a/cim_for_mina/cim-android-sdk/.settings/org.eclipse.jdt.core.prefs b/cim-client-sdk/cim-android-sdk/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from cim_for_mina/cim-android-sdk/.settings/org.eclipse.jdt.core.prefs rename to cim-client-sdk/cim-android-sdk/.settings/org.eclipse.jdt.core.prefs diff --git a/cim_for_mina/cim-android-sdk/libs/protobuf-java-3.7.0.jar b/cim-client-sdk/cim-android-sdk/libs/protobuf-java-3.7.0.jar similarity index 100% rename from cim_for_mina/cim-android-sdk/libs/protobuf-java-3.7.0.jar rename to cim-client-sdk/cim-android-sdk/libs/protobuf-java-3.7.0.jar diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java diff --git a/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java new file mode 100644 index 0000000..917f8a4 --- /dev/null +++ b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java @@ -0,0 +1,501 @@ +/** + * 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.sdk.android; + +import java.io.IOException; +import java.net.ConnectException; +import java.net.InetSocketAddress; +import java.net.StandardSocketOptions; +import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; +import java.util.Random; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicBoolean; + +import com.farsunset.cim.sdk.android.coder.CIMLogger; +import com.farsunset.cim.sdk.android.coder.ClientMessageDecoder; +import com.farsunset.cim.sdk.android.coder.ClientMessageEncoder; +import com.farsunset.cim.sdk.android.constant.CIMConstant; +import com.farsunset.cim.sdk.android.exception.SessionClosedException; +import com.farsunset.cim.sdk.android.model.HeartbeatRequest; +import com.farsunset.cim.sdk.android.model.HeartbeatResponse; +import com.farsunset.cim.sdk.android.model.Message; +import com.farsunset.cim.sdk.android.model.ReplyBody; +import com.farsunset.cim.sdk.android.model.SentBody; + +import android.content.Context; +import android.content.Intent; +import android.net.ConnectivityManager; +import android.net.NetworkInfo; +import android.os.Handler; +import android.util.ArrayMap; + +/** + * 连接服务端管理,cim核心处理类,管理连接,以及消息处理 + * + * @author 3979434@qq.com + */ +class CIMConnectorManager { + + private final int READ_BUFFER_SIZE = 2048; + private final int WRITE_BUFFER_SIZE = 1024; + + private final int READ_IDLE_TIME = 120 * 1000;// 秒 + private final int HEARBEAT_TIME_OUT = (READ_IDLE_TIME + 10) * 1000;// 收到服务端心跳请求超时时间 毫秒 + + private final String KEY_LAST_HEART_TIME = "KEY_LAST_HEART_TIME"; + + private Selector selector; + private SocketChannel socketChannel ; + private Context context; + private static CIMConnectorManager manager; + + private CIMLogger logger = CIMLogger.getLogger(); + + + + private ByteBuffer readBuffer = ByteBuffer.allocate(READ_BUFFER_SIZE); + + private ArrayMap attr = new ArrayMap<>(); + + private ExecutorService workerExecutor = Executors.newFixedThreadPool(1); + private ExecutorService bossExecutor = Executors.newFixedThreadPool(1); + + private final AtomicBoolean CONNECTING_FLAG = new AtomicBoolean(false) ; + + private ClientMessageEncoder messageEncoder = new ClientMessageEncoder(); + private ClientMessageDecoder messageDecoder = new ClientMessageDecoder(); + + + private CIMConnectorManager(Context ctx) { + context = ctx; + makeNioConnector(); + } + + private void makeNioConnector() { + try { + if(socketChannel == null || !socketChannel.isOpen()) { + socketChannel = SocketChannel.open(); + socketChannel.configureBlocking(false); + socketChannel.setOption(StandardSocketOptions.SO_RCVBUF,READ_BUFFER_SIZE); + socketChannel.setOption(StandardSocketOptions.SO_SNDBUF, WRITE_BUFFER_SIZE); + socketChannel.setOption(StandardSocketOptions.SO_KEEPALIVE, true); + socketChannel.setOption(StandardSocketOptions.TCP_NODELAY,true); + } + + if(selector == null || !selector.isOpen()) { + selector = Selector.open(); + } + + selector.wakeup(); + socketChannel.register(selector, SelectionKey.OP_CONNECT); + + }catch(Exception e) { + + } + + } + + + + public synchronized static CIMConnectorManager getManager(Context context) { + + if (manager == null) { + manager = new CIMConnectorManager(context); + } + + return manager; + + } + + + + public void connect(final String host, final int port) { + + if (!isNetworkConnected(context)) { + + Intent intent = new Intent(); + intent.setPackage(context.getPackageName()); + intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED); + context.sendBroadcast(intent); + + return; + } + + boolean isConnected = isConnected(); + if (CONNECTING_FLAG.get() || isConnected) { + return; + } + + CONNECTING_FLAG.set(true); + + if(!socketChannel.isOpen() ||!selector.isOpen()) { + makeNioConnector(); + } + + bossExecutor.execute(new Runnable() { + @Override + public void run() { + + + final InetSocketAddress remoteAddress = new InetSocketAddress(host, port); + + logger.startConnect(remoteAddress); + + CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_CIM_CONNECTION_STATE, false); + + try { + socketChannel.connect(remoteAddress); + }catch(Exception e){ + closeSession(); + return; + } + + + workerExecutor.execute(new Runnable() { + @Override + public void run() { + while (socketChannel.isOpen()) { + + try { + selector.select(); + for(SelectionKey key : selector.selectedKeys()){ + if (key.isConnectable() && socketChannel.finishConnect()) { + handelConnectionEvent(); + continue; + } + + if (key.isReadable()) { + handelReadEvent(); + } + } + + } catch (Exception e) { + if(e instanceof ConnectException) { + handleConnectFailure(remoteAddress); + }else { + closeSession(); + } + } + } + } + }); + + } + }); + } + + + Handler idleHandler = new Handler() { + public void handleMessage(android.os.Message m) { + sessionIdle(); + } + }; + + private void handelConnectionEvent() throws Exception { + CONNECTING_FLAG.set(false); + socketChannel.register(selector, SelectionKey.OP_READ); + sessionCreated(); + + idleHandler.sendEmptyMessageDelayed(0, READ_IDLE_TIME); + } + + private void handelReadEvent() throws Exception { + + idleHandler.removeCallbacksAndMessages(null); + + idleHandler.sendEmptyMessageDelayed(0, READ_IDLE_TIME); + + + int result = 0; + + while((result = socketChannel.read(readBuffer)) > 0) { + if(readBuffer.position() == readBuffer.capacity()) { + extemdByteBuffer(); + } + } + + if(result == -1) { + closeSession(); + return; + } + + readBuffer.position(0); + + Object message = messageDecoder.doDecode(readBuffer); + + if(message == null) { + return; + } + + + logger.messageReceived(socketChannel,message); + + if(isRequest(message)) { + send(getResponse()); + return; + } + + this.messageReceived(message); + } + + + private void extemdByteBuffer() { + + ByteBuffer newBuffer = ByteBuffer.allocate(readBuffer.capacity() + READ_BUFFER_SIZE / 2); + readBuffer.position(0); + newBuffer.put(readBuffer); + + readBuffer.clear(); + readBuffer = newBuffer; + } + + private void handleConnectFailure(InetSocketAddress remoteAddress) { + + CONNECTING_FLAG.set(false); + + long interval = CIMConstant.RECONN_INTERVAL_TIME - (5 * 1000 - new Random().nextInt(15 * 1000)); + + logger.connectFailure(remoteAddress, interval); + + + Intent intent = new Intent(); + intent.setPackage(context.getPackageName()); + intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED); + intent.putExtra("interval", interval); + context.sendBroadcast(intent); + + + } + + public void send(final SentBody body) { + + bossExecutor.execute(new Runnable() { + + @Override + public void run() { + boolean isSuccessed = false; + String exceptionName = SessionClosedException.class.getSimpleName(); + if (isConnected()) { + + try { + ByteBuffer buffer = messageEncoder.encode(body); + int result = 0; + while(buffer.hasRemaining()){ + result += socketChannel.write(buffer); + } + isSuccessed = result > 0; + } catch (IOException e) { + exceptionName = e.getClass().getSimpleName(); + closeSession(); + } + + } + + if (!isSuccessed) { + Intent intent = new Intent(); + intent.setPackage(context.getPackageName()); + intent.setAction(CIMConstant.IntentAction.ACTION_SENT_FAILED); + intent.putExtra(Exception.class.getName(), exceptionName); + intent.putExtra(SentBody.class.getName(), body); + context.sendBroadcast(intent); + }else { + messageSent(body); + } + } + }); + + } + + + public void send(final HeartbeatResponse body) { + + bossExecutor.execute(new Runnable() { + @Override + public void run() { + try { + socketChannel.write(messageEncoder.encode(body)); + messageSent(body); + } catch (IOException e) { + closeSession(); + } + } + }); + + } + + + public void sessionCreated() throws Exception { + + logger.sessionCreated(socketChannel); + + setLastHeartbeatTime(); + + Intent intent = new Intent(); + intent.setPackage(context.getPackageName()); + intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_SUCCESSED); + context.sendBroadcast(intent); + + } + + public void sessionClosed() { + + readBuffer.clear(); + + if(readBuffer.capacity() > READ_BUFFER_SIZE) { + readBuffer = ByteBuffer.allocate(READ_BUFFER_SIZE); + } + + attr.clear(); + + logger.sessionClosed(socketChannel); + + closeSelector(); + + Intent intent = new Intent(); + intent.setPackage(context.getPackageName()); + intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_CLOSED); + context.sendBroadcast(intent); + + } + + public void sessionIdle() { + + logger.sessionIdle(socketChannel); + + /** + * 用于解决,wifi情况下。偶而路由器与服务器断开连接时,客户端并没及时收到关闭事件 导致这样的情况下当前连接无效也不会重连的问题 + * + */ + long lastHeartbeatTime = getLastHeartbeatTime(); + if (System.currentTimeMillis() - lastHeartbeatTime >= HEARBEAT_TIME_OUT) { + closeSession(); + } + } + + + public void messageReceived(Object obj) { + + if (obj instanceof Message) { + + Intent intent = new Intent(); + intent.setPackage(context.getPackageName()); + intent.setAction(CIMConstant.IntentAction.ACTION_MESSAGE_RECEIVED); + intent.putExtra(Message.class.getName(), (Message) obj); + context.sendBroadcast(intent); + + } + if (obj instanceof ReplyBody) { + + Intent intent = new Intent(); + intent.setPackage(context.getPackageName()); + intent.setAction(CIMConstant.IntentAction.ACTION_REPLY_RECEIVED); + intent.putExtra(ReplyBody.class.getName(), (ReplyBody) obj); + context.sendBroadcast(intent); + } + } + + + public void messageSent(Object message) { + + logger.messageSent(socketChannel, message); + + if (message instanceof SentBody) { + Intent intent = new Intent(); + intent.setPackage(context.getPackageName()); + intent.setAction(CIMConstant.IntentAction.ACTION_SENT_SUCCESSED); + intent.putExtra(SentBody.class.getName(), (SentBody) message); + context.sendBroadcast(intent); + } + } + + + private void setLastHeartbeatTime() { + attr.put(KEY_LAST_HEART_TIME, System.currentTimeMillis()); + } + + + private long getLastHeartbeatTime() { + long time = 0; + Object value = attr.get(KEY_LAST_HEART_TIME); + if (value != null) { + time = Long.parseLong(value.toString()); + } + return time; + } + + public static boolean isNetworkConnected(Context context) { + try { + ConnectivityManager nw = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); + NetworkInfo networkInfo = nw.getActiveNetworkInfo(); + return networkInfo != null; + } catch (Exception e) { + } + + return false; + } + + + public HeartbeatResponse getResponse() { + return HeartbeatResponse.getInstance(); + } + + public boolean isRequest(Object data) { + + setLastHeartbeatTime(); + + return data instanceof HeartbeatRequest; + } + + public void destroy() { + + closeSession(); + closeSelector(); + + } + + public boolean isConnected() { + return socketChannel != null && socketChannel.isConnected(); + } + + public void closeSession() { + try { + socketChannel.close(); + } catch (IOException ignore) { + }finally { + this.sessionClosed(); + } + } + + public void closeSelector() { + if (selector != null) { + try { + selector.close(); + } catch (IOException ignore) { + } + } + } + +} diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java similarity index 97% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java index 33b36f8..a0633bc 100644 --- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java +++ b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java @@ -78,8 +78,7 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver { */ if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED)) { long interval = intent.getLongExtra("interval", CIMConstant.RECONN_INTERVAL_TIME); - String exceptionName = intent.getStringExtra(Exception.class.getName()); - onConnectionFailed(exceptionName, interval); + onConnectionFailed(interval); } /* @@ -149,7 +148,7 @@ public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver { onConnectionClosed(); } - private void onConnectionFailed(String exceptionName, long reinterval) { + private void onConnectionFailed(long reinterval) { if (CIMConnectorManager.isNetworkConnected(context)) { onConnectionFailed(); diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java diff --git a/cim_for_mina/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 similarity index 96% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java index 1c1a05a..3a437fb 100644 --- a/cim_for_mina/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 @@ -38,8 +38,8 @@ import android.os.Message; import java.util.concurrent.Semaphore; +import com.farsunset.cim.sdk.android.coder.CIMLogger; import com.farsunset.cim.sdk.android.constant.CIMConstant; -import com.farsunset.cim.sdk.android.filter.CIMLoggingFilter; import com.farsunset.cim.sdk.android.model.SentBody; /** @@ -140,7 +140,7 @@ public class CIMPushService extends Service { if (CIMPushManager.ACTION_SET_LOGGER_EANABLE.equals(action)) { boolean enable = intent.getBooleanExtra(KEY_LOGGER_ENABLE, true); - CIMLoggingFilter.getLogger().debugMode(enable); + CIMLogger.getLogger().debugMode(enable); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -174,14 +174,14 @@ public class CIMPushService extends Service { private void handleKeepAlive() { if (manager.isConnected()) { - CIMLoggingFilter.getLogger().connectState(true); + CIMLogger.getLogger().connectState(true); return; } boolean isManualStop = CIMCacheManager.getBoolean(getApplicationContext(), CIMCacheManager.KEY_MANUAL_STOP); boolean isDestroyed = CIMCacheManager.getBoolean(getApplicationContext(), CIMCacheManager.KEY_CIM_DESTROYED); - CIMLoggingFilter.getLogger().connectState(false, isManualStop, isDestroyed); + CIMLogger.getLogger().connectState(false, isManualStop, isDestroyed); CIMPushManager.connect(this, 0); diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/CIMLoggingFilter.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/coder/CIMLogger.java similarity index 51% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/CIMLoggingFilter.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/coder/CIMLogger.java index 5339fef..d1a7a0a 100644 --- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/CIMLoggingFilter.java +++ b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/coder/CIMLogger.java @@ -19,14 +19,11 @@ * * *************************************************************************************** */ -package com.farsunset.cim.sdk.android.filter; +package com.farsunset.cim.sdk.android.coder; +import java.io.IOException; import java.net.InetSocketAddress; - -import org.apache.mina.core.filterchain.IoFilterAdapter; -import org.apache.mina.core.session.IdleStatus; -import org.apache.mina.core.session.IoSession; -import org.apache.mina.core.write.WriteRequest; +import java.nio.channels.SocketChannel; import android.util.Log; @@ -34,82 +31,59 @@ import android.util.Log; /** * 日志打印,添加session 的id和ip address */ -public class CIMLoggingFilter extends IoFilterAdapter { +public class CIMLogger { private final static String TAG = "CIM"; private boolean debug = true; - public static CIMLoggingFilter getLogger() { + public static CIMLogger getLogger() { return LoggerHolder.logger; } - private CIMLoggingFilter() { + private CIMLogger() { } private static class LoggerHolder{ - private static CIMLoggingFilter logger = new CIMLoggingFilter(); + private static CIMLogger logger = new CIMLogger(); } public void debugMode(boolean mode) { debug = mode; } - - @Override - public void exceptionCaught(NextFilter nextFilter, IoSession session, Throwable cause) { - if(debug) { - Log.d(TAG,String.format("EXCEPTION" + getSessionInfo(session) + "\n%s", cause.getClass().getName())); - } - session.closeOnFlush(); - } - @Override - public void messageReceived(NextFilter nextFilter, IoSession session, Object message) { + public void messageReceived(SocketChannel session, Object message) { if(debug) { Log.i(TAG,String.format("RECEIVED" + getSessionInfo(session) + "\n%s", message)); } - nextFilter.messageReceived(session, message); } - @Override - public void messageSent(NextFilter nextFilter, IoSession session, WriteRequest writeRequest) { + public void messageSent(SocketChannel session, Object message) { if(debug) { - Log.i(TAG,String.format("SENT" + getSessionInfo(session) + "\n%s", writeRequest.getOriginalRequest().getMessage())); + Log.i(TAG,String.format("SENT" + getSessionInfo(session) + "\n%s", message)); } - nextFilter.messageSent(session, writeRequest); } - @Override - public void sessionCreated(NextFilter nextFilter, IoSession session) throws Exception { - nextFilter.sessionCreated(session); - } - - @Override - public void sessionOpened(NextFilter nextFilter, IoSession session) throws Exception { + public void sessionCreated( SocketChannel session) throws Exception { if(debug) { Log.i(TAG,"OPENED" + getSessionInfo(session)); } - nextFilter.sessionOpened(session); } - @Override - public void sessionIdle(NextFilter nextFilter, IoSession session, IdleStatus status) { + public void sessionIdle( SocketChannel session) { if(debug) { - Log.i(TAG,"IDLE " + status.toString().toUpperCase() + getSessionInfo(session)); + Log.d(TAG,"IDLE READ" + getSessionInfo(session)); } - nextFilter.sessionIdle(session, status); } - @Override - public void sessionClosed(NextFilter nextFilter, IoSession session) { + public void sessionClosed( SocketChannel session) { if(debug) { - Log.i(TAG,"CLOSED" + getSessionInfo(session)); + Log.w(TAG,"CLOSED ID = " + session.hashCode()); } - nextFilter.sessionClosed(session); } public void connectFailure(InetSocketAddress remoteAddress,long interval) { if(debug) { - Log.i(TAG,"CONNECT FAILURE TRY RECONNECT AFTER " + interval +"ms"); + Log.d(TAG,"CONNECT FAILURE TRY RECONNECT AFTER " + interval +"ms"); } } @@ -121,30 +95,36 @@ public class CIMLoggingFilter extends IoFilterAdapter { public void connectState(boolean isConnected) { if(debug) { - Log.i(TAG,"CONNECTED:" + isConnected); + Log.d(TAG,"CONNECTED:" + isConnected); } } public void connectState(boolean isConnected,boolean isManualStop,boolean isDestroyed) { if(debug) { - Log.i(TAG,"CONNECTED:" + isConnected + " STOPED:"+isManualStop+ " DESTROYED:"+isDestroyed); + Log.d(TAG,"CONNECTED:" + isConnected + " STOPED:"+isManualStop+ " DESTROYED:"+isDestroyed); } } - private String getSessionInfo(IoSession session) { + private String getSessionInfo(SocketChannel session) { StringBuilder builder = new StringBuilder(); if (session == null) { return ""; } builder.append(" ["); - builder.append("id:").append(session.getId()); + builder.append("id:").append(session.hashCode()); - if (session.getLocalAddress() != null) { - builder.append(" L:").append(session.getLocalAddress().toString()); + try { + if (session.getLocalAddress() != null) { + builder.append(" L:").append(session.getLocalAddress().toString()); + } + } catch (Exception ignore) { } - if (session.getRemoteAddress() != null) { - builder.append(" R:").append(session.getRemoteAddress().toString()); + try { + if (session.getRemoteAddress() != null) { + builder.append(" R:").append(session.getRemoteAddress().toString()); + } + } catch (Exception ignore) { } builder.append("]"); return builder.toString(); diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageDecoder.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/coder/ClientMessageDecoder.java similarity index 85% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageDecoder.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/coder/ClientMessageDecoder.java index 9ddc1ec..ff2ce6a 100644 --- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageDecoder.java +++ b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/coder/ClientMessageDecoder.java @@ -19,12 +19,11 @@ * * *************************************************************************************** */ -package com.farsunset.cim.sdk.android.filter; +package com.farsunset.cim.sdk.android.coder; + + +import java.nio.ByteBuffer; -import org.apache.mina.core.buffer.IoBuffer; -import org.apache.mina.core.session.IoSession; -import org.apache.mina.filter.codec.CumulativeProtocolDecoder; -import org.apache.mina.filter.codec.ProtocolDecoderOutput; import com.farsunset.cim.sdk.android.constant.CIMConstant; import com.farsunset.cim.sdk.android.model.HeartbeatRequest; @@ -37,17 +36,16 @@ import com.google.protobuf.InvalidProtocolBufferException; /** * 客户端消息解码 */ -public class ClientMessageDecoder extends CumulativeProtocolDecoder { +public class ClientMessageDecoder { - @Override - public boolean doDecode(IoSession iosession, IoBuffer iobuffer, ProtocolDecoderOutput out) throws Exception { - + public Object doDecode(ByteBuffer iobuffer) throws Exception { + /** * 消息头3位 */ if (iobuffer.remaining() < CIMConstant.DATA_HEADER_LENGTH) { - return false; + return null; } iobuffer.mark(); @@ -62,18 +60,16 @@ public class ClientMessageDecoder extends CumulativeProtocolDecoder { // 如果消息体没有接收完整,则重置读取,等待下一次重新读取 if (conetnLength > iobuffer.remaining()) { iobuffer.reset(); - return false; + return null; } byte[] dataBytes = new byte[conetnLength]; iobuffer.get(dataBytes, 0, conetnLength); - Object message = mappingMessageObject(dataBytes, conetnType); - if (message != null) { - out.write(message); - } - - return true; + iobuffer.position(0); + + return mappingMessageObject(dataBytes, conetnType); + } private Object mappingMessageObject(byte[] bytes, byte type) throws InvalidProtocolBufferException { diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageEncoder.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/coder/ClientMessageEncoder.java similarity index 73% rename from cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageEncoder.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/coder/ClientMessageEncoder.java index d7fc81c..1fae3aa 100644 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageEncoder.java +++ b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/coder/ClientMessageEncoder.java @@ -19,29 +19,30 @@ * * *************************************************************************************** */ -package com.farsunset.cim.sdk.android.filter; +package com.farsunset.cim.sdk.android.coder; + +import java.nio.ByteBuffer; import com.farsunset.cim.sdk.android.constant.CIMConstant; import com.farsunset.cim.sdk.android.model.Protobufable; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToByteEncoder; - /** - * 客户端消息发送前进行编码,可在此加密消息 - * + * 客户端消息发送前进行编码 */ -public class ClientMessageEncoder extends MessageToByteEncoder { +public class ClientMessageEncoder { - @Override - protected void encode(ChannelHandlerContext ctx, Protobufable message, ByteBuf out) throws Exception { + public ByteBuffer encode(Object object) { - Protobufable data = (Protobufable) message; + Protobufable data = (Protobufable) object; byte[] byteArray = data.getByteArray(); - out.writeBytes(createHeader(data.getType(), byteArray.length)); - out.writeBytes(byteArray); + ByteBuffer iobuffer = ByteBuffer.allocate(byteArray.length + CIMConstant.DATA_HEADER_LENGTH); + + iobuffer.put(createHeader(data.getType(), byteArray.length)); + iobuffer.put(byteArray); + iobuffer.flip(); + + return iobuffer; } diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java similarity index 97% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java index 61daffb..f22dacb 100644 --- a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java +++ b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java @@ -61,9 +61,6 @@ public interface CIMConstant { String CLIENT_LOGOUT = "client_logout"; - @Deprecated - String CLIENT_PULL_MESSAGE = "client_pull_message"; - } public static interface MessageAction { diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisabledException.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisabledException.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisabledException.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisabledException.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionClosedException.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionClosedException.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionClosedException.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionClosedException.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/Message.proto b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/Message.proto similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/Message.proto rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/Message.proto diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBody.proto b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBody.proto similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBody.proto rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBody.proto diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBody.proto b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBody.proto similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBody.proto rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBody.proto diff --git a/cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java b/cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java similarity index 100% rename from cim_for_mina/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java rename to cim-client-sdk/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java diff --git a/cim_for_mina/cim-java-sdk/.classpath b/cim-client-sdk/cim-java-sdk/.classpath similarity index 78% rename from cim_for_mina/cim-java-sdk/.classpath rename to cim-client-sdk/cim-java-sdk/.classpath index 153238c..7867dc7 100644 --- a/cim_for_mina/cim-java-sdk/.classpath +++ b/cim-client-sdk/cim-java-sdk/.classpath @@ -2,10 +2,8 @@ - - diff --git a/cim_for_mina/cim-java-sdk/.project b/cim-client-sdk/cim-java-sdk/.project similarity index 100% rename from cim_for_mina/cim-java-sdk/.project rename to cim-client-sdk/cim-java-sdk/.project diff --git a/cim_for_mina/cim-java-sdk/.settings/org.eclipse.core.resources.prefs b/cim-client-sdk/cim-java-sdk/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from cim_for_mina/cim-java-sdk/.settings/org.eclipse.core.resources.prefs rename to cim-client-sdk/cim-java-sdk/.settings/org.eclipse.core.resources.prefs diff --git a/cim_for_mina/cim-java-sdk/libs/protobuf-java-3.7.0.jar b/cim-client-sdk/cim-java-sdk/libs/protobuf-java-3.7.0.jar similarity index 100% rename from cim_for_mina/cim-java-sdk/libs/protobuf-java-3.7.0.jar rename to cim-client-sdk/cim-java-sdk/libs/protobuf-java-3.7.0.jar diff --git a/cim_for_mina/cim-java-sdk/libs/slf4j-api-1.7.5.jar b/cim-client-sdk/cim-java-sdk/libs/slf4j-api-1.7.5.jar similarity index 100% rename from cim_for_mina/cim-java-sdk/libs/slf4j-api-1.7.5.jar rename to cim-client-sdk/cim-java-sdk/libs/slf4j-api-1.7.5.jar diff --git a/cim_for_mina/cim-java-sdk/libs/slf4j-nop-1.7.5.jar b/cim-client-sdk/cim-java-sdk/libs/slf4j-nop-1.7.5.jar similarity index 100% rename from cim_for_mina/cim-java-sdk/libs/slf4j-nop-1.7.5.jar rename to cim-client-sdk/cim-java-sdk/libs/slf4j-nop-1.7.5.jar diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMCacheManager.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMCacheManager.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMCacheManager.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMCacheManager.java diff --git a/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMConnectorManager.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMConnectorManager.java new file mode 100644 index 0000000..f32e6db --- /dev/null +++ b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMConnectorManager.java @@ -0,0 +1,490 @@ +/** + * 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.sdk.client; + +import java.io.IOException; +import java.net.ConnectException; +import java.net.InetSocketAddress; +import java.net.StandardSocketOptions; +import java.nio.ByteBuffer; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.nio.channels.SocketChannel; +import java.util.HashMap; +import java.util.Random; +import java.util.Timer; +import java.util.TimerTask; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.atomic.AtomicBoolean; + +import com.farsunset.cim.sdk.client.coder.CIMLogger; +import com.farsunset.cim.sdk.client.coder.ClientMessageDecoder; +import com.farsunset.cim.sdk.client.coder.ClientMessageEncoder; +import com.farsunset.cim.sdk.client.constant.CIMConstant; +import com.farsunset.cim.sdk.client.exception.SessionClosedException; +import com.farsunset.cim.sdk.client.model.HeartbeatRequest; +import com.farsunset.cim.sdk.client.model.HeartbeatResponse; +import com.farsunset.cim.sdk.client.model.Intent; +import com.farsunset.cim.sdk.client.model.Message; +import com.farsunset.cim.sdk.client.model.ReplyBody; +import com.farsunset.cim.sdk.client.model.SentBody; + + + +/** + * 连接服务端管理,cim核心处理类,管理连接,以及消息处理 + * + * @author 3979434@qq.com + */ +class CIMConnectorManager { + + private final int READ_BUFFER_SIZE = 2048; + private final int WRITE_BUFFER_SIZE = 1024; + + private final int READ_IDLE_TIME = 120 * 1000;// 秒 + private final int HEARBEAT_TIME_OUT = (READ_IDLE_TIME + 10) * 1000;// 收到服务端心跳请求超时时间 毫秒 + + private final String KEY_LAST_HEART_TIME = "KEY_LAST_HEART_TIME"; + + private Selector selector; + private SocketChannel socketChannel ; + private static CIMConnectorManager manager; + + private CIMLogger logger = CIMLogger.getLogger(); + + + + private ByteBuffer readBuffer = ByteBuffer.allocate(READ_BUFFER_SIZE); + + private HashMap attr = new HashMap<>(); + + private ExecutorService eventExecutor = Executors.newFixedThreadPool(1); + private ExecutorService workerExecutor = Executors.newFixedThreadPool(1); + private ExecutorService bossExecutor = Executors.newFixedThreadPool(1); + + private final AtomicBoolean CONNECTING_FLAG = new AtomicBoolean(false) ; + + private ClientMessageEncoder messageEncoder = new ClientMessageEncoder(); + private ClientMessageDecoder messageDecoder = new ClientMessageDecoder(); + + private Timer idleHandler = new Timer();; + + private ReadIdleTask idleTask = new ReadIdleTask();; + + private CIMConnectorManager() { + makeNioConnector(); + } + + private void makeNioConnector() { + try { + if(socketChannel == null || !socketChannel.isOpen()) { + socketChannel = SocketChannel.open(); + socketChannel.configureBlocking(false); + socketChannel.setOption(StandardSocketOptions.SO_RCVBUF,READ_BUFFER_SIZE); + socketChannel.setOption(StandardSocketOptions.SO_SNDBUF, WRITE_BUFFER_SIZE); + socketChannel.setOption(StandardSocketOptions.SO_KEEPALIVE, true); + socketChannel.setOption(StandardSocketOptions.TCP_NODELAY,true); + } + + if(selector == null || !selector.isOpen()) { + selector = Selector.open(); + } + + selector.wakeup(); + socketChannel.register(selector, SelectionKey.OP_CONNECT); + }catch(Exception e) { + + } + + } + + + + public synchronized static CIMConnectorManager getManager() { + + if (manager == null) { + manager = new CIMConnectorManager(); + } + + return manager; + + } + + + + public void connect(final String host, final int port) { + + + if (CONNECTING_FLAG.get() || isConnected()) { + return; + } + + CONNECTING_FLAG.set(true); + + if(!socketChannel.isOpen() ||!selector.isOpen()) { + makeNioConnector(); + } + + bossExecutor.execute(new Runnable() { + @Override + public void run() { + + + final InetSocketAddress remoteAddress = new InetSocketAddress(host, port); + + logger.startConnect(remoteAddress); + + CIMCacheManager.getInstance().putBoolean(CIMCacheManager.KEY_CIM_CONNECTION_STATE, false); + + + try { + socketChannel.connect(remoteAddress); + }catch(Exception e) { + closeSession(); + return; + } + + + workerExecutor.execute(new Runnable() { + @Override + public void run() { + while (socketChannel.isOpen()) { + + try { + selector.select(); + for(SelectionKey key : selector.selectedKeys()){ + if (key.isConnectable() && socketChannel.finishConnect()) { + handelConnectionEvent(); + continue; + } + + if (key.isReadable()) { + handelReadEvent(); + } + } + + } catch (Exception e) { + if(e instanceof ConnectException) { + handleConnectFailure(remoteAddress); + }else { + closeSession(); + } + } + } + } + }); + + } + }); + } + + + + private void handelConnectionEvent() throws Exception { + CONNECTING_FLAG.set(false); + socketChannel.register(selector, SelectionKey.OP_READ); + sessionCreated(); + + idleHandler.schedule(idleTask = new ReadIdleTask(), READ_IDLE_TIME); + } + + private void handelReadEvent() throws Exception { + + if(idleTask != null) { + idleTask.cancel(); + } + + idleHandler.schedule(idleTask = new ReadIdleTask(), READ_IDLE_TIME); + + + int result = 0; + + while((result = socketChannel.read(readBuffer)) > 0) { + if(readBuffer.position() == readBuffer.capacity()) { + extemdByteBuffer(); + } + } + + if(result == -1) { + closeSession(); + return; + } + + readBuffer.position(0); + + Object message = messageDecoder.doDecode(readBuffer); + + if(message == null) { + return; + } + + + logger.messageReceived(socketChannel,message); + + if(isRequest(message)) { + send(getResponse()); + return; + } + + this.messageReceived(message); + } + + + private void extemdByteBuffer() { + + ByteBuffer newBuffer = ByteBuffer.allocate(readBuffer.capacity() + READ_BUFFER_SIZE / 2); + readBuffer.position(0); + newBuffer.put(readBuffer); + + readBuffer.clear(); + readBuffer = newBuffer; + } + + private void handleConnectFailure(InetSocketAddress remoteAddress) { + + CONNECTING_FLAG.set(false); + + long interval = CIMConstant.RECONN_INTERVAL_TIME - (5 * 1000 - new Random().nextInt(15 * 1000)); + + logger.connectFailure(remoteAddress, interval); + + + Intent intent = new Intent(); + intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED); + intent.putExtra("interval", interval); + sendBroadcast(intent); + + + } + + public void send(final SentBody body) { + + bossExecutor.execute(new Runnable() { + + @Override + public void run() { + boolean isSuccessed = false; + String exceptionName = SessionClosedException.class.getSimpleName(); + if (isConnected()) { + + try { + ByteBuffer buffer = messageEncoder.encode(body); + int result = 0; + while(buffer.hasRemaining()){ + result += socketChannel.write(buffer); + } + isSuccessed = result > 0; + } catch (IOException e) { + exceptionName = e.getClass().getSimpleName(); + closeSession(); + } + + } + + if (!isSuccessed) { + Intent intent = new Intent(); + intent.setAction(CIMConstant.IntentAction.ACTION_SENT_FAILED); + intent.putExtra(Exception.class.getName(), exceptionName); + intent.putExtra(SentBody.class.getName(), body); + sendBroadcast(intent); + + }else { + messageSent(body); + } + } + }); + + } + + + public void send(final HeartbeatResponse body) { + + bossExecutor.execute(new Runnable() { + @Override + public void run() { + try { + socketChannel.write(messageEncoder.encode(body)); + messageSent(body); + } catch (IOException e) { + closeSession(); + } + } + }); + + } + + + public void sessionCreated() throws Exception { + + logger.sessionCreated(socketChannel); + + setLastHeartbeatTime(); + + Intent intent = new Intent(); + intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_SUCCESSED); + sendBroadcast(intent); + + } + + public void sessionClosed() { + + readBuffer.clear(); + + if(readBuffer.capacity() > READ_BUFFER_SIZE) { + readBuffer = ByteBuffer.allocate(READ_BUFFER_SIZE); + } + + attr.clear(); + + logger.sessionClosed(socketChannel); + + closeSelector(); + + Intent intent = new Intent(); + intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_CLOSED); + sendBroadcast(intent); + + } + + public void sessionIdle() { + + logger.sessionIdle(socketChannel); + + /** + * 用于解决,wifi情况下。偶而路由器与服务器断开连接时,客户端并没及时收到关闭事件 导致这样的情况下当前连接无效也不会重连的问题 + * + */ + long lastHeartbeatTime = getLastHeartbeatTime(); + if (System.currentTimeMillis() - lastHeartbeatTime >= HEARBEAT_TIME_OUT) { + closeSession(); + } + } + + + public void messageReceived(Object obj) { + + if (obj instanceof Message) { + + Intent intent = new Intent(); + intent.setAction(CIMConstant.IntentAction.ACTION_MESSAGE_RECEIVED); + intent.putExtra(Message.class.getName(), (Message) obj); + sendBroadcast(intent); + + } + if (obj instanceof ReplyBody) { + + Intent intent = new Intent(); + intent.setAction(CIMConstant.IntentAction.ACTION_REPLY_RECEIVED); + intent.putExtra(ReplyBody.class.getName(), (ReplyBody) obj); + sendBroadcast(intent); + } + } + + + public void messageSent(Object message) { + + logger.messageSent(socketChannel, message); + + if (message instanceof SentBody) { + Intent intent = new Intent(); + intent.setAction(CIMConstant.IntentAction.ACTION_SENT_SUCCESSED); + intent.putExtra(SentBody.class.getName(), (SentBody) message); + sendBroadcast(intent); + } + } + + + private void setLastHeartbeatTime() { + attr.put(KEY_LAST_HEART_TIME, System.currentTimeMillis()); + } + + + private long getLastHeartbeatTime() { + long time = 0; + Object value = attr.get(KEY_LAST_HEART_TIME); + if (value != null) { + time = Long.parseLong(value.toString()); + } + return time; + } + + + public HeartbeatResponse getResponse() { + return HeartbeatResponse.getInstance(); + } + + public boolean isRequest(Object data) { + + setLastHeartbeatTime(); + + return data instanceof HeartbeatRequest; + } + + public void destroy() { + + closeSession(); + closeSelector(); + + } + + public boolean isConnected() { + return socketChannel != null && socketChannel.isConnected(); + } + + public void closeSession() { + try { + socketChannel.close(); + } catch (IOException ignore) { + }finally { + this.sessionClosed(); + } + } + + public void closeSelector() { + if (selector != null) { + try { + selector.close(); + } catch (IOException ignore) { + } + } + } + + private void sendBroadcast(final Intent intent) { + eventExecutor.execute(new Runnable() { + @Override + public void run() { + CIMEventBroadcastReceiver.getInstance().onReceive(intent); + } + }); + } + + + private class ReadIdleTask extends TimerTask{ + + @Override + public void run() { + sessionIdle(); + } + } + +} diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventBroadcastReceiver.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventBroadcastReceiver.java similarity index 94% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventBroadcastReceiver.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventBroadcastReceiver.java index ce4594c..9975310 100644 --- a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventBroadcastReceiver.java +++ b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventBroadcastReceiver.java @@ -26,7 +26,7 @@ import java.util.Timer; import java.util.TimerTask; import com.farsunset.cim.sdk.client.constant.CIMConstant; -import com.farsunset.cim.sdk.client.exception.SessionDisconnectedException; +import com.farsunset.cim.sdk.client.exception.SessionClosedException; import com.farsunset.cim.sdk.client.model.Intent; import com.farsunset.cim.sdk.client.model.Message; import com.farsunset.cim.sdk.client.model.ReplyBody; @@ -66,7 +66,7 @@ public class CIMEventBroadcastReceiver { */ if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED)) { long interval = intent.getLongExtra("interval", CIMConstant.RECONN_INTERVAL_TIME); - onInnerConnectionFailed((Exception) intent.getExtra(Exception.class.getName()), interval); + onInnerConnectionFailed(interval); } /* @@ -129,11 +129,11 @@ public class CIMEventBroadcastReceiver { } - private void onInnerConnectionFailed(Exception e, long interval) { + private void onInnerConnectionFailed(long interval) { connectionHandler.schedule(new ConnectionTask(), interval); - listener.onConnectionFailed(e); + listener.onConnectionFailed(); } private void onInnerConnectionSuccessed() { @@ -163,7 +163,7 @@ public class CIMEventBroadcastReceiver { e.printStackTrace(); // 与服务端端开链接,重新连接 - if (e instanceof SessionDisconnectedException) { + if (e instanceof SessionClosedException) { CIMPushManager.connect(); } else { // 发送失败 重新发送 diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventListener.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventListener.java similarity index 98% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventListener.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventListener.java index 2ddb32f..3e3d026 100644 --- a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventListener.java +++ b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMEventListener.java @@ -60,7 +60,7 @@ public interface CIMEventListener { * 当服务器连接失败的时候回调 * */ - void onConnectionFailed(Exception e); + void onConnectionFailed(); /** * 监听器在容器里面的排序。值越大则越先接收 diff --git a/cim_for_netty/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMListenerManager.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMListenerManager.java similarity index 92% rename from cim_for_netty/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMListenerManager.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMListenerManager.java index 267df63..a16bc56 100644 --- a/cim_for_netty/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMListenerManager.java +++ b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMListenerManager.java @@ -38,7 +38,7 @@ public class CIMListenerManager { private static ArrayList cimListeners = new ArrayList(); private static CIMMessageReceiveComparator comparator = new CIMMessageReceiveComparator(); - protected static final Logger logger = LoggerFactory.getLogger(CIMListenerManager.class); + private static final Logger LOGGER = LoggerFactory.getLogger(CIMListenerManager.class); public static void registerMessageListener(CIMEventListener listener) { @@ -80,9 +80,9 @@ public class CIMListenerManager { } } - public static void notifyOnConnectionFailed(Exception e) { + public static void notifyOnConnectionFailed() { for (CIMEventListener listener : cimListeners) { - listener.onConnectionFailed(e); + listener.onConnectionFailed(); } } @@ -92,7 +92,7 @@ public class CIMListenerManager { public static void logListenersName() { for (CIMEventListener listener : cimListeners) { - logger.debug("#######" + listener.getClass().getName() + "#######"); + LOGGER.debug("#######" + listener.getClass().getName() + "#######"); } } diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMPushManager.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMPushManager.java similarity index 93% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMPushManager.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMPushManager.java index 41d9929..01c2089 100644 --- a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMPushManager.java +++ b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMPushManager.java @@ -24,8 +24,7 @@ package com.farsunset.cim.sdk.client; import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Properties; - -import org.apache.log4j.Logger; +import java.util.UUID; import com.farsunset.cim.sdk.client.constant.CIMConstant; import com.farsunset.cim.sdk.client.model.Intent; @@ -35,7 +34,7 @@ import com.farsunset.cim.sdk.client.model.SentBody; * CIM 功能接口 */ public class CIMPushManager { - protected static final Logger logger = Logger.getLogger(CIMPushManager.class); + static String ACTION_ACTIVATE_PUSH_SERVICE = "ACTION_ACTIVATE_PUSH_SERVICE"; static String ACTION_CREATE_CIM_CONNECTION = "ACTION_CREATE_CIM_CONNECTION"; @@ -106,9 +105,9 @@ public class CIMPushManager { Properties sysPro = System.getProperties(); sent.setKey(CIMConstant.RequestKey.CLIENT_BIND); sent.put("account", account); - sent.put("deviceId", getLocalMac()); + sent.put("deviceId", getDeviceId()); sent.put("channel", sysPro.getProperty("os.name")); - sent.put("device", getDeviceModel()); + sent.put("device", System.getenv().get("COMPUTERNAME")); sent.put("version", getClientVersion()); sent.put("osVersion", sysPro.getProperty("os.version")); sendRequest(sent); @@ -234,9 +233,6 @@ public class CIMPushManager { return STATE_NORMAL; } - public static String getDeviceModel() { - return System.getProperties().getProperty(CIMConstant.ConfigKey.DEVICE_MODEL); - } public static String getClientVersion() { return System.getProperties().getProperty(CIMConstant.ConfigKey.CLIENT_VERSION); @@ -253,12 +249,8 @@ public class CIMPushManager { public static void setClientVersion(String version) { System.getProperties().put(CIMConstant.ConfigKey.CLIENT_VERSION, version); } - - public static void setDeviceModel(String model) { - System.getProperties().put(CIMConstant.ConfigKey.DEVICE_MODEL, model); - } - - private static String getLocalMac() { + + private static String getDeviceId() { InetAddress ia; try { ia = InetAddress.getLocalHost(); @@ -277,7 +269,7 @@ public class CIMPushManager { sb.append(str); } } - return sb.toString().toUpperCase(); + return UUID.fromString(sb.toString()).toString().replaceAll("-", "").toUpperCase(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMPushService.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMPushService.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMPushService.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMPushService.java diff --git a/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/coder/CIMLogger.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/coder/CIMLogger.java new file mode 100644 index 0000000..cff92ac --- /dev/null +++ b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/coder/CIMLogger.java @@ -0,0 +1,116 @@ +/** + * 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.sdk.client.coder; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.channels.SocketChannel; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +/** + * 日志打印,添加session 的id和ip address + */ +public class CIMLogger { + private static final Logger LOGGER = LoggerFactory.getLogger(CIMLogger.class); + + public static CIMLogger getLogger() { + return LoggerHolder.logger; + } + + private CIMLogger() { + + } + + private static class LoggerHolder{ + private static CIMLogger logger = new CIMLogger(); + } + + + public void messageReceived(SocketChannel session, Object message) { + LOGGER.info(String.format("RECEIVED" + getSessionInfo(session) + "\n%s", message)); + } + + public void messageSent(SocketChannel session, Object message) { + LOGGER.info(String.format("SENT" + getSessionInfo(session) + "\n%s", message)); + } + + public void sessionCreated( SocketChannel session) throws Exception { + LOGGER.info("OPENED" + getSessionInfo(session)); + } + + public void sessionIdle( SocketChannel session) { + LOGGER.debug("IDLE READ" + getSessionInfo(session)); + } + + public void sessionClosed( SocketChannel session) { + LOGGER.warn("CLOSED ID = " + session.hashCode()); + + } + + public void connectFailure(InetSocketAddress remoteAddress,long interval) { + LOGGER.debug("CONNECT FAILURE TRY RECONNECT AFTER " + interval +"ms"); + } + + public void startConnect(InetSocketAddress remoteAddress) { + LOGGER.info("START CONNECT REMOTE HOST: " + remoteAddress.toString()); + } + + public void connectState(boolean isConnected) { + LOGGER.debug("CONNECTED:" + isConnected); + } + + public void connectState(boolean isConnected,boolean isManualStop,boolean isDestroyed) { + LOGGER.debug("CONNECTED:" + isConnected + " STOPED:"+isManualStop+ " DESTROYED:"+isDestroyed); + } + private String getSessionInfo(SocketChannel session) { + StringBuilder builder = new StringBuilder(); + if (session == null) { + return ""; + } + builder.append(" ["); + builder.append("id:").append(session.hashCode()); + + try { + if (session.getLocalAddress() != null) { + builder.append(" L:").append(session.getLocalAddress().toString()); + } + } catch (IOException e) { + e.printStackTrace(); + } + + + try { + if (session.getRemoteAddress() != null) { + builder.append(" R:").append(session.getRemoteAddress().toString()); + } + } catch (IOException e) { + e.printStackTrace(); + } + builder.append("]"); + return builder.toString(); + } + + +} diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageDecoder.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/coder/ClientMessageDecoder.java similarity index 80% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageDecoder.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/coder/ClientMessageDecoder.java index a2beb92..c8a95a3 100644 --- a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageDecoder.java +++ b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/coder/ClientMessageDecoder.java @@ -19,13 +19,10 @@ * * *************************************************************************************** */ -package com.farsunset.cim.sdk.client.filter; +package com.farsunset.cim.sdk.client.coder; -import org.apache.log4j.Logger; -import org.apache.mina.core.buffer.IoBuffer; -import org.apache.mina.core.session.IoSession; -import org.apache.mina.filter.codec.CumulativeProtocolDecoder; -import org.apache.mina.filter.codec.ProtocolDecoderOutput; + +import java.nio.ByteBuffer; import com.farsunset.cim.sdk.client.constant.CIMConstant; import com.farsunset.cim.sdk.client.model.HeartbeatRequest; @@ -38,17 +35,16 @@ import com.google.protobuf.InvalidProtocolBufferException; /** * 客户端消息解码 */ -public class ClientMessageDecoder extends CumulativeProtocolDecoder { - protected final Logger logger = Logger.getLogger(ClientMessageDecoder.class); +public class ClientMessageDecoder { - @Override - public boolean doDecode(IoSession iosession, IoBuffer iobuffer, ProtocolDecoderOutput out) throws Exception { + public Object doDecode(ByteBuffer iobuffer) throws Exception { + /** * 消息头3位 */ if (iobuffer.remaining() < CIMConstant.DATA_HEADER_LENGTH) { - return false; + return null; } iobuffer.mark(); @@ -63,25 +59,22 @@ public class ClientMessageDecoder extends CumulativeProtocolDecoder { // 如果消息体没有接收完整,则重置读取,等待下一次重新读取 if (conetnLength > iobuffer.remaining()) { iobuffer.reset(); - return false; + return null; } byte[] dataBytes = new byte[conetnLength]; iobuffer.get(dataBytes, 0, conetnLength); - Object message = mappingMessageObject(dataBytes, conetnType); - if (message != null) { - out.write(message); - } - - return true; + iobuffer.position(0); + + return mappingMessageObject(dataBytes, conetnType); + } private Object mappingMessageObject(byte[] bytes, byte type) throws InvalidProtocolBufferException { if (CIMConstant.ProtobufType.S_H_RQ == type) { HeartbeatRequest request = HeartbeatRequest.getInstance(); - logger.info(request.toString()); return request; } @@ -93,9 +86,6 @@ public class ClientMessageDecoder extends CumulativeProtocolDecoder { body.putAll(bodyProto.getDataMap()); body.setCode(bodyProto.getCode()); body.setMessage(bodyProto.getMessage()); - - logger.info(body.toString()); - return body; } @@ -111,8 +101,6 @@ public class ClientMessageDecoder extends CumulativeProtocolDecoder { message.setExtra(bodyProto.getExtra()); message.setTimestamp(bodyProto.getTimestamp()); message.setFormat(bodyProto.getFormat()); - - logger.info(message.toString()); return message; } diff --git a/cim_for_netty/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageEncoder.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/coder/ClientMessageEncoder.java similarity index 64% rename from cim_for_netty/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageEncoder.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/coder/ClientMessageEncoder.java index c0fb8ec..dd1dfcc 100644 --- a/cim_for_netty/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageEncoder.java +++ b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/coder/ClientMessageEncoder.java @@ -19,39 +19,32 @@ * * *************************************************************************************** */ -package com.farsunset.cim.sdk.client.filter; +package com.farsunset.cim.sdk.client.coder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import java.nio.ByteBuffer; import com.farsunset.cim.sdk.client.constant.CIMConstant; import com.farsunset.cim.sdk.client.model.Protobufable; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToByteEncoder; /** - * 客户端消息发送前进行编码,可在此加密消息 - * + * 客户端消息发送前进行编码 */ -public class ClientMessageEncoder extends MessageToByteEncoder { - protected final Logger logger = LoggerFactory.getLogger(ClientMessageEncoder.class.getSimpleName()); +public class ClientMessageEncoder { - @Override - protected void encode(ChannelHandlerContext ctx, Object message, ByteBuf out) throws Exception { + public ByteBuffer encode(Object object) { - if (message instanceof Protobufable) { + Protobufable data = (Protobufable) object; + byte[] byteArray = data.getByteArray(); - Protobufable data = (Protobufable) message; - byte[] byteArray = data.getByteArray(); + ByteBuffer iobuffer = ByteBuffer.allocate(byteArray.length + CIMConstant.DATA_HEADER_LENGTH); - out.writeBytes(createHeader(data.getType(), byteArray.length)); - out.writeBytes(byteArray); + iobuffer.put(createHeader(data.getType(), byteArray.length)); + iobuffer.put(byteArray); + iobuffer.flip(); - } + return iobuffer; - logger.info(message.toString()); } /** diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/constant/CIMConstant.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/constant/CIMConstant.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/constant/CIMConstant.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/constant/CIMConstant.java diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionClosedException.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/exception/SessionClosedException.java similarity index 88% rename from cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionClosedException.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/exception/SessionClosedException.java index 84e35d5..ff4c719 100644 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/SessionClosedException.java +++ b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/exception/SessionClosedException.java @@ -19,11 +19,9 @@ * * *************************************************************************************** */ -package com.farsunset.cim.sdk.android.exception; +package com.farsunset.cim.sdk.client.exception; -import java.io.Serializable; - -public class SessionClosedException extends Exception implements Serializable { +public class SessionClosedException extends Exception { private static final long serialVersionUID = 1L; diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/HeartbeatRequest.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/HeartbeatRequest.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/HeartbeatRequest.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/HeartbeatRequest.java diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/HeartbeatResponse.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/HeartbeatResponse.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/HeartbeatResponse.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/HeartbeatResponse.java diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Intent.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Intent.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Intent.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Intent.java diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Message.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Message.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Message.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Message.java diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Protobufable.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Protobufable.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Protobufable.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/Protobufable.java diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/ReplyBody.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/ReplyBody.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/ReplyBody.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/ReplyBody.java diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/SentBody.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/SentBody.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/SentBody.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/client/model/SentBody.java diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/Message.proto b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/Message.proto similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/Message.proto rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/Message.proto diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/MessageProto.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/MessageProto.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/MessageProto.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/MessageProto.java diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/ReplyBody.proto b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/ReplyBody.proto similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/ReplyBody.proto rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/ReplyBody.proto diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/ReplyBodyProto.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/ReplyBodyProto.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/ReplyBodyProto.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/ReplyBodyProto.java diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/SentBody.proto b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/SentBody.proto similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/SentBody.proto rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/SentBody.proto diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/SentBodyProto.java b/cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/SentBodyProto.java similarity index 100% rename from cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/SentBodyProto.java rename to cim-client-sdk/cim-java-sdk/src/com/farsunset/cim/sdk/model/proto/SentBodyProto.java diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/js/cim/cim.web.sdk.js b/cim-client-sdk/cim-web-sdk/cim.web.sdk.js similarity index 82% rename from cim_for_netty/cim-boot-server/src/main/resources/static/js/cim/cim.web.sdk.js rename to cim-client-sdk/cim-web-sdk/cim.web.sdk.js index f9e928b..42d63db 100644 --- a/cim_for_netty/cim-boot-server/src/main/resources/static/js/cim/cim.web.sdk.js +++ b/cim-client-sdk/cim-web-sdk/cim.web.sdk.js @@ -1,9 +1,14 @@ -var CIM_URI="ws://127.0.0.1:23456";// 修改为服务器的真实IP +/*CIM服务器IP*/ +var CIM_HOST = "127.0.0.1"; +/*CIM服务端口*/ +var CIM_PORT = 23456; +var CIM_URI="ws://"+CIM_HOST+":"+CIM_PORT; + var CMD_HEARTBEAT_RESPONSE = new Uint8Array([67,82]); var SDK_VERSION = "1.0.0"; var SDK_CHANNEL = "browser"; var APP_PACKAGE = "com.farsunset.cim"; -const ACTION_999 = "999";//特殊的消息类型,代表被服务端强制下线 +var ACTION_999 = "999";//特殊的消息类型,代表被服务端强制下线 var DATA_HEADER_LENGTH = 3; var C_H_RS = 0; @@ -14,18 +19,18 @@ var REPLYBODY = 4; var socket; var manualStop = false; -var CIMWebBridge = new Object(); -CIMWebBridge.connection = function(){ +var CIMPushManager = {}; +CIMPushManager.connection = function(){ manualStop = false; window.localStorage.account = ''; socket = new WebSocket(CIM_URI); socket.binaryType = 'arraybuffer'; - socket.onopen = CIMWebBridge.innerOnConnectionSuccessed; - socket.onmessage = CIMWebBridge.innerOnMessageReceived; - socket.onclose = CIMWebBridge.innerOnConnectionClosed; + socket.onopen = CIMPushManager.innerOnConnectionSuccessed; + socket.onmessage = CIMPushManager.innerOnMessageReceived; + socket.onclose = CIMPushManager.innerOnConnectionClosed; }; -CIMWebBridge.bindAccount = function(account){ +CIMPushManager.bindAccount = function(account){ window.localStorage.account = account; @@ -45,32 +50,32 @@ CIMWebBridge.bindAccount = function(account){ body.getDataMap().set("packageName", APP_PACKAGE); body.getDataMap().set("deviceId", deviceId); body.getDataMap().set("device", browser.name); - CIMWebBridge.sendRequest(body); + CIMPushManager.sendRequest(body); }; -CIMWebBridge.stop = function(){ +CIMPushManager.stop = function(){ manualStop = true; socket.close(); }; -CIMWebBridge.resume = function(){ +CIMPushManager.resume = function(){ manualStop = false; - CIMWebBridge.connection(); + CIMPushManager.connection(); }; -CIMWebBridge.innerOnConnectionSuccessed = function(){ +CIMPushManager.innerOnConnectionSuccessed = function(){ var account = window.localStorage.account; if(account == '' || account == undefined){ onConnectionSuccessed(); }else{ - CIMWebBridge.bindAccount(account); + CIMPushManager.bindAccount(account); } }; -CIMWebBridge.innerOnMessageReceived = function(e){ +CIMPushManager.innerOnMessageReceived = function(e){ var data = new Uint8Array(e.data); var type = data[0]; @@ -79,7 +84,7 @@ CIMWebBridge.innerOnMessageReceived = function(e){ * 收到服务端发来的心跳请求,立即回复响应,否则服务端会在10秒后断开连接 */ if(type == S_H_RQ){ - CIMWebBridge.sendHeartbeatResponse(); + CIMPushManager.sendHeartbeatResponse(); return; } @@ -114,16 +119,16 @@ CIMWebBridge.innerOnMessageReceived = function(e){ } }; -CIMWebBridge.innerOnConnectionClosed = function(e){ +CIMPushManager.innerOnConnectionClosed = function(e){ if(!manualStop){ var time = Math.floor(Math.random()*(30-15+1)+15); setTimeout(function(){ - CIMWebBridge.connection(); + CIMPushManager.connection(); },time); } }; -CIMWebBridge.sendRequest = function(body){ +CIMPushManager.sendRequest = function(body){ var data = body.serializeBinary(); var header = buildHeader(SENTBODY,data.length); @@ -131,10 +136,9 @@ CIMWebBridge.sendRequest = function(body){ protubuf.set(header,0); protubuf.set(data,header.length); socket.send(protubuf); - }; -CIMWebBridge.sendHeartbeatResponse = function(){ +CIMPushManager.sendHeartbeatResponse = function(){ var data = CMD_HEARTBEAT_RESPONSE; var header = buildHeader(C_H_RS,data.length); var protubuf = new Uint8Array(data.length + header.length); diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/js/cim/message.js b/cim-client-sdk/cim-web-sdk/message.js similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/js/cim/message.js rename to cim-client-sdk/cim-web-sdk/message.js diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/js/cim/replybody.js b/cim-client-sdk/cim-web-sdk/replybody.js similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/js/cim/replybody.js rename to cim-client-sdk/cim-web-sdk/replybody.js diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/js/cim/sentbody.js b/cim-client-sdk/cim-web-sdk/sentbody.js similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/js/cim/sentbody.js rename to cim-client-sdk/cim-web-sdk/sentbody.js diff --git a/cim_for_mina/cim-server-sdk/.classpath b/cim-server-sdk/cim-server-sdk-mina/.classpath similarity index 100% rename from cim_for_mina/cim-server-sdk/.classpath rename to cim-server-sdk/cim-server-sdk-mina/.classpath diff --git a/cim_for_netty/cim-server-sdk/.project b/cim-server-sdk/cim-server-sdk-mina/.project similarity index 95% rename from cim_for_netty/cim-server-sdk/.project rename to cim-server-sdk/cim-server-sdk-mina/.project index 70c4662..3bd7588 100644 --- a/cim_for_netty/cim-server-sdk/.project +++ b/cim-server-sdk/cim-server-sdk-mina/.project @@ -1,6 +1,6 @@ - cim-server-sdk + cim-server-sdk-mina diff --git a/cim_for_mina/cim-server-sdk/.settings/org.eclipse.core.resources.prefs b/cim-server-sdk/cim-server-sdk-mina/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from cim_for_mina/cim-server-sdk/.settings/org.eclipse.core.resources.prefs rename to cim-server-sdk/cim-server-sdk-mina/.settings/org.eclipse.core.resources.prefs diff --git a/cim_for_mina/cim-server-sdk/.settings/org.eclipse.jdt.core.prefs b/cim-server-sdk/cim-server-sdk-mina/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from cim_for_mina/cim-server-sdk/.settings/org.eclipse.jdt.core.prefs rename to cim-server-sdk/cim-server-sdk-mina/.settings/org.eclipse.jdt.core.prefs diff --git a/cim_for_mina/cim-server-sdk/.settings/org.eclipse.wst.common.project.facet.core.xml b/cim-server-sdk/cim-server-sdk-mina/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from cim_for_mina/cim-server-sdk/.settings/org.eclipse.wst.common.project.facet.core.xml rename to cim-server-sdk/cim-server-sdk-mina/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/cim_for_mina/cim-android-sdk/libs/mina-core-2.0.16.jar b/cim-server-sdk/cim-server-sdk-mina/libs/mina-core-2.0.16.jar similarity index 100% rename from cim_for_mina/cim-android-sdk/libs/mina-core-2.0.16.jar rename to cim-server-sdk/cim-server-sdk-mina/libs/mina-core-2.0.16.jar diff --git a/cim_for_mina/cim-server-sdk/libs/protobuf-java-3.7.0.jar b/cim-server-sdk/cim-server-sdk-mina/libs/protobuf-java-3.7.0.jar similarity index 100% rename from cim_for_mina/cim-server-sdk/libs/protobuf-java-3.7.0.jar rename to cim-server-sdk/cim-server-sdk-mina/libs/protobuf-java-3.7.0.jar diff --git a/cim_for_mina/cim-server-sdk/libs/slf4j-api-1.7.25.jar b/cim-server-sdk/cim-server-sdk-mina/libs/slf4j-api-1.7.25.jar similarity index 100% rename from cim_for_mina/cim-server-sdk/libs/slf4j-api-1.7.25.jar rename to cim-server-sdk/cim-server-sdk-mina/libs/slf4j-api-1.7.25.jar diff --git a/cim_for_mina/cim-server-sdk/src/META-INF/MANIFEST.MF b/cim-server-sdk/cim-server-sdk-mina/src/META-INF/MANIFEST.MF similarity index 100% rename from cim_for_mina/cim-server-sdk/src/META-INF/MANIFEST.MF rename to cim-server-sdk/cim-server-sdk-mina/src/META-INF/MANIFEST.MF diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/constant/CIMConstant.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/constant/CIMConstant.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/constant/CIMConstant.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/constant/CIMConstant.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/CIMLoggingFilter.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/CIMLoggingFilter.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/CIMLoggingFilter.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/CIMLoggingFilter.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/ServerMessageCodecFactory.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/ServerMessageCodecFactory.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/ServerMessageCodecFactory.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/ServerMessageCodecFactory.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/ServerMessageDecoder.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/ServerMessageDecoder.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/ServerMessageDecoder.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/ServerMessageDecoder.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/ServerMessageEncoder.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/ServerMessageEncoder.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/ServerMessageEncoder.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/ServerMessageEncoder.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/decoder/AppMessageDecoder.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/decoder/AppMessageDecoder.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/decoder/AppMessageDecoder.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/decoder/AppMessageDecoder.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/decoder/WebMessageDecoder.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/decoder/WebMessageDecoder.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/decoder/WebMessageDecoder.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/filter/decoder/WebMessageDecoder.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java similarity index 97% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java index d49383d..f89c5e8 100644 --- a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java +++ b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java @@ -156,11 +156,15 @@ public class CIMNioSocketAcceptor extends IoHandlerAdapter implements KeepAliveM return acceptor.getManagedSessions(); } - public IoSession getManagedSession(Long nid) { + public IoSession getManagedSession(String nid) { if (nid == null) { return null; } - return getManagedSessions().get(nid); + try { + return getManagedSessions().get(Long.parseLong(nid)); + }catch(Exception ignore) { + return null; + } } public void setPort(int port) { diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/CIMRequestHandler.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/handler/CIMRequestHandler.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/CIMRequestHandler.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/handler/CIMRequestHandler.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/WebsocketHandler.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/handler/WebsocketHandler.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/WebsocketHandler.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/handler/WebsocketHandler.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/CIMSession.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/CIMSession.java similarity index 98% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/CIMSession.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/CIMSession.java index d3dcfb8..16b8580 100644 --- a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/CIMSession.java +++ b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/CIMSession.java @@ -58,7 +58,7 @@ public class CIMSession implements Serializable { private transient IoSession session; private String account;// session绑定的账号,主键,一个账号同一时间之内在一个设备在线 - private Long nid;// session在本台服务器上的ID + private String nid;// session在本台服务器上的ID private String deviceId;// 客户端ID (设备号码+应用包名),ios为devicetoken private String host;// session绑定的服务器IP private String channel;// 终端设备类型 @@ -74,7 +74,7 @@ public class CIMSession implements Serializable { public CIMSession(IoSession session) { this.session = session; - this.nid = session.getId(); + this.nid = String.valueOf(session.getId()); } public CIMSession() { @@ -115,11 +115,11 @@ public class CIMSession implements Serializable { this.location = location; } - public Long getNid() { + public String getNid() { return nid; } - public void setNid(Long nid) { + public void setNid(String nid) { this.nid = nid; } diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HandshakerResponse.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/HandshakerResponse.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HandshakerResponse.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/HandshakerResponse.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HeartbeatRequest.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/HeartbeatRequest.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HeartbeatRequest.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/HeartbeatRequest.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HeartbeatResponse.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/HeartbeatResponse.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HeartbeatResponse.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/HeartbeatResponse.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/Message.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/Message.java similarity index 95% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/Message.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/Message.java index c271927..0c90bd0 100644 --- a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/Message.java +++ b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/Message.java @@ -1,205 +1,205 @@ -/** - * 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.sdk.server.model; - -import java.io.Serializable; -import com.farsunset.cim.sdk.server.constant.CIMConstant; -import com.farsunset.cim.sdk.server.model.feature.EncodeFormatable; -import com.farsunset.cim.sdk.server.model.proto.MessageProto; - -/** - * 消息对象 - */ -public class Message implements Serializable, EncodeFormatable { - - private static final long serialVersionUID = 1L; - - /** - * 消息类型,用户自定义消息类别 - */ - private long id; - - /** - * 消息类型,用户自定义消息类别 - */ - private String action; - /** - * 消息标题 - */ - private String title; - /** - * 消息类容,于action 组合为任何类型消息,content 根据 format 可表示为 text,json ,xml数据格式 - */ - private String content; - - /** - * 消息发送者账号 - */ - private String sender; - /** - * 消息发送者接收者 - */ - private String receiver; - - /** - * content 内容格式 - */ - private String format; - - /** - * 附加内容 内容 - */ - private String extra; - - private long timestamp; - - public Message() { - timestamp = System.currentTimeMillis(); - } - - - public long getId() { - return id; - } - - - public void setId(long id) { - this.id = id; - } - - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getSender() { - return sender; - } - - public void setSender(String sender) { - this.sender = sender; - } - - public String getReceiver() { - return receiver; - } - - public void setReceiver(String receiver) { - this.receiver = receiver; - } - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - - public String getExtra() { - return extra; - } - - public void setExtra(String extra) { - this.extra = extra; - } - - @Override - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("#Message#").append("\n"); - buffer.append("id:").append(id).append("\n"); - buffer.append("action:").append(action).append("\n"); - buffer.append("title:").append(title).append("\n"); - buffer.append("content:").append(content).append("\n"); - buffer.append("extra:").append(extra).append("\n"); - buffer.append("sender:").append(sender).append("\n"); - buffer.append("receiver:").append(receiver).append("\n"); - buffer.append("format:").append(format).append("\n"); - buffer.append("timestamp:").append(timestamp); - return buffer.toString(); - } - - public boolean isNotEmpty(String txt) { - return txt != null && txt.trim().length() != 0; - } - - @Override - public byte[] getProtobufBody() { - MessageProto.Model.Builder builder = MessageProto.Model.newBuilder(); - builder.setId(id); - builder.setAction(action); - builder.setSender(sender); - builder.setReceiver(receiver); - builder.setTimestamp(timestamp); - - /** - * 下面字段可能为空 - */ - if (content != null) { - builder.setContent(content); - } - if (title != null) { - builder.setTitle(title); - } - if (extra != null) { - builder.setExtra(extra); - } - if (format != null) { - builder.setFormat(format); - } - return builder.build().toByteArray(); - } - - @Override - public byte getDataType() { - return CIMConstant.ProtobufType.MESSAGE; - } -} +/** + * 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.sdk.server.model; + +import java.io.Serializable; +import com.farsunset.cim.sdk.server.constant.CIMConstant; +import com.farsunset.cim.sdk.server.model.feature.EncodeFormatable; +import com.farsunset.cim.sdk.server.model.proto.MessageProto; + +/** + * 消息对象 + */ +public class Message implements Serializable, EncodeFormatable { + + private static final long serialVersionUID = 1L; + + /** + * 消息类型,用户自定义消息类别 + */ + private long id; + + /** + * 消息类型,用户自定义消息类别 + */ + private String action; + /** + * 消息标题 + */ + private String title; + /** + * 消息类容,于action 组合为任何类型消息,content 根据 format 可表示为 text,json ,xml数据格式 + */ + private String content; + + /** + * 消息发送者账号 + */ + private String sender; + /** + * 消息发送者接收者 + */ + private String receiver; + + /** + * content 内容格式 + */ + private String format; + + /** + * 附加内容 内容 + */ + private String extra; + + private long timestamp; + + public Message() { + timestamp = System.currentTimeMillis(); + } + + + public long getId() { + return id; + } + + + public void setId(long id) { + this.id = id; + } + + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getSender() { + return sender; + } + + public void setSender(String sender) { + this.sender = sender; + } + + public String getReceiver() { + return receiver; + } + + public void setReceiver(String receiver) { + this.receiver = receiver; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getExtra() { + return extra; + } + + public void setExtra(String extra) { + this.extra = extra; + } + + @Override + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append("#Message#").append("\n"); + buffer.append("id:").append(id).append("\n"); + buffer.append("action:").append(action).append("\n"); + buffer.append("title:").append(title).append("\n"); + buffer.append("content:").append(content).append("\n"); + buffer.append("extra:").append(extra).append("\n"); + buffer.append("sender:").append(sender).append("\n"); + buffer.append("receiver:").append(receiver).append("\n"); + buffer.append("format:").append(format).append("\n"); + buffer.append("timestamp:").append(timestamp); + return buffer.toString(); + } + + public boolean isNotEmpty(String txt) { + return txt != null && txt.trim().length() != 0; + } + + @Override + public byte[] getProtobufBody() { + MessageProto.Model.Builder builder = MessageProto.Model.newBuilder(); + builder.setId(id); + builder.setAction(action); + builder.setSender(sender); + builder.setReceiver(receiver); + builder.setTimestamp(timestamp); + + /** + * 下面字段可能为空 + */ + if (content != null) { + builder.setContent(content); + } + if (title != null) { + builder.setTitle(title); + } + if (extra != null) { + builder.setExtra(extra); + } + if (format != null) { + builder.setFormat(format); + } + return builder.build().toByteArray(); + } + + @Override + public byte getDataType() { + return CIMConstant.ProtobufType.MESSAGE; + } +} diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/ReplyBody.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/ReplyBody.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/ReplyBody.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/ReplyBody.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/SentBody.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/SentBody.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/SentBody.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/SentBody.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/feature/EncodeFormatable.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/feature/EncodeFormatable.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/feature/EncodeFormatable.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/feature/EncodeFormatable.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/Message.proto b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/Message.proto similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/Message.proto rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/Message.proto diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/MessageProto.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/MessageProto.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/MessageProto.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/MessageProto.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/ReplyBody.proto b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/ReplyBody.proto similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/ReplyBody.proto rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/ReplyBody.proto diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/ReplyBodyProto.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/ReplyBodyProto.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/ReplyBodyProto.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/ReplyBodyProto.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SentBody.proto b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/SentBody.proto similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SentBody.proto rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/SentBody.proto diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SentBodyProto.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/SentBodyProto.java similarity index 100% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SentBodyProto.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/SentBodyProto.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/Session.proto b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/Session.proto similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/Session.proto rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/Session.proto diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SessionProto.java b/cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/SessionProto.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SessionProto.java rename to cim-server-sdk/cim-server-sdk-mina/src/com/farsunset/cim/sdk/server/model/proto/SessionProto.java diff --git a/cim_for_netty/cim-server-sdk/.classpath b/cim-server-sdk/cim-server-sdk-netty/.classpath similarity index 100% rename from cim_for_netty/cim-server-sdk/.classpath rename to cim-server-sdk/cim-server-sdk-netty/.classpath diff --git a/cim_for_mina/cim-server-sdk/.project b/cim-server-sdk/cim-server-sdk-netty/.project similarity index 95% rename from cim_for_mina/cim-server-sdk/.project rename to cim-server-sdk/cim-server-sdk-netty/.project index 70c4662..ad3ba92 100644 --- a/cim_for_mina/cim-server-sdk/.project +++ b/cim-server-sdk/cim-server-sdk-netty/.project @@ -1,6 +1,6 @@ - cim-server-sdk + cim-server-sdk-netty diff --git a/cim_for_netty/cim-android-sdk/.settings/org.eclipse.core.resources.prefs b/cim-server-sdk/cim-server-sdk-netty/.settings/org.eclipse.core.resources.prefs similarity index 100% rename from cim_for_netty/cim-android-sdk/.settings/org.eclipse.core.resources.prefs rename to cim-server-sdk/cim-server-sdk-netty/.settings/org.eclipse.core.resources.prefs diff --git a/cim_for_netty/cim-server-sdk/.settings/org.eclipse.jdt.core.prefs b/cim-server-sdk/cim-server-sdk-netty/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from cim_for_netty/cim-server-sdk/.settings/org.eclipse.jdt.core.prefs rename to cim-server-sdk/cim-server-sdk-netty/.settings/org.eclipse.jdt.core.prefs diff --git a/cim_for_netty/cim-server-sdk/.settings/org.eclipse.wst.common.project.facet.core.xml b/cim-server-sdk/cim-server-sdk-netty/.settings/org.eclipse.wst.common.project.facet.core.xml similarity index 100% rename from cim_for_netty/cim-server-sdk/.settings/org.eclipse.wst.common.project.facet.core.xml rename to cim-server-sdk/cim-server-sdk-netty/.settings/org.eclipse.wst.common.project.facet.core.xml diff --git a/cim_for_netty/cim-server-sdk/libs/netty-buffer-4.1.28.Final.jar b/cim-server-sdk/cim-server-sdk-netty/libs/netty-buffer-4.1.28.Final.jar similarity index 100% rename from cim_for_netty/cim-server-sdk/libs/netty-buffer-4.1.28.Final.jar rename to cim-server-sdk/cim-server-sdk-netty/libs/netty-buffer-4.1.28.Final.jar diff --git a/cim_for_netty/cim-server-sdk/libs/netty-codec-4.1.28.Final.jar b/cim-server-sdk/cim-server-sdk-netty/libs/netty-codec-4.1.28.Final.jar similarity index 100% rename from cim_for_netty/cim-server-sdk/libs/netty-codec-4.1.28.Final.jar rename to cim-server-sdk/cim-server-sdk-netty/libs/netty-codec-4.1.28.Final.jar diff --git a/cim_for_netty/cim-server-sdk/libs/netty-codec-http-4.1.28.Final.jar b/cim-server-sdk/cim-server-sdk-netty/libs/netty-codec-http-4.1.28.Final.jar similarity index 100% rename from cim_for_netty/cim-server-sdk/libs/netty-codec-http-4.1.28.Final.jar rename to cim-server-sdk/cim-server-sdk-netty/libs/netty-codec-http-4.1.28.Final.jar diff --git a/cim_for_netty/cim-server-sdk/libs/netty-common-4.1.28.Final.jar b/cim-server-sdk/cim-server-sdk-netty/libs/netty-common-4.1.28.Final.jar similarity index 100% rename from cim_for_netty/cim-server-sdk/libs/netty-common-4.1.28.Final.jar rename to cim-server-sdk/cim-server-sdk-netty/libs/netty-common-4.1.28.Final.jar diff --git a/cim_for_netty/cim-server-sdk/libs/netty-handler-4.1.28.Final.jar b/cim-server-sdk/cim-server-sdk-netty/libs/netty-handler-4.1.28.Final.jar similarity index 100% rename from cim_for_netty/cim-server-sdk/libs/netty-handler-4.1.28.Final.jar rename to cim-server-sdk/cim-server-sdk-netty/libs/netty-handler-4.1.28.Final.jar diff --git a/cim_for_netty/cim-server-sdk/libs/netty-transport-4.1.28.Final.jar b/cim-server-sdk/cim-server-sdk-netty/libs/netty-transport-4.1.28.Final.jar similarity index 100% rename from cim_for_netty/cim-server-sdk/libs/netty-transport-4.1.28.Final.jar rename to cim-server-sdk/cim-server-sdk-netty/libs/netty-transport-4.1.28.Final.jar diff --git a/cim_for_netty/cim-android-sdk/libs/protobuf-java-3.7.0.jar b/cim-server-sdk/cim-server-sdk-netty/libs/protobuf-java-3.7.0.jar similarity index 100% rename from cim_for_netty/cim-android-sdk/libs/protobuf-java-3.7.0.jar rename to cim-server-sdk/cim-server-sdk-netty/libs/protobuf-java-3.7.0.jar diff --git a/cim_for_netty/cim-java-sdk/libs/slf4j-api-1.7.25.jar b/cim-server-sdk/cim-server-sdk-netty/libs/slf4j-api-1.7.25.jar similarity index 100% rename from cim_for_netty/cim-java-sdk/libs/slf4j-api-1.7.25.jar rename to cim-server-sdk/cim-server-sdk-netty/libs/slf4j-api-1.7.25.jar diff --git a/cim_for_netty/cim-server-sdk/src/META-INF/MANIFEST.MF b/cim-server-sdk/cim-server-sdk-netty/src/META-INF/MANIFEST.MF similarity index 100% rename from cim_for_netty/cim-server-sdk/src/META-INF/MANIFEST.MF rename to cim-server-sdk/cim-server-sdk-netty/src/META-INF/MANIFEST.MF diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/constant/CIMConstant.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/constant/CIMConstant.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/constant/CIMConstant.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/constant/CIMConstant.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/ServerMessageDecoder.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/filter/ServerMessageDecoder.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/ServerMessageDecoder.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/filter/ServerMessageDecoder.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/ServerMessageEncoder.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/filter/ServerMessageEncoder.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/ServerMessageEncoder.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/filter/ServerMessageEncoder.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/decoder/AppMessageDecoder.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/filter/decoder/AppMessageDecoder.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/decoder/AppMessageDecoder.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/filter/decoder/AppMessageDecoder.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/decoder/WebMessageDecoder.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/filter/decoder/WebMessageDecoder.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/filter/decoder/WebMessageDecoder.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/filter/decoder/WebMessageDecoder.java diff --git a/cim_for_netty/cim-server-sdk/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 similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/CIMNioSocketAcceptor.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/CIMRequestHandler.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/CIMRequestHandler.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/CIMRequestHandler.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/CIMRequestHandler.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/HeartbeatHandler.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/HeartbeatHandler.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/HeartbeatHandler.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/HeartbeatHandler.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/WebsocketHandler.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/WebsocketHandler.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/WebsocketHandler.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/handler/WebsocketHandler.java diff --git a/cim_for_netty/cim-server-sdk/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 similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/CIMSession.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/CIMSession.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HandshakerResponse.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/HandshakerResponse.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HandshakerResponse.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/HandshakerResponse.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HeartbeatRequest.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/HeartbeatRequest.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HeartbeatRequest.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/HeartbeatRequest.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HeartbeatResponse.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/HeartbeatResponse.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/HeartbeatResponse.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/HeartbeatResponse.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/Message.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/Message.java similarity index 95% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/Message.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/Message.java index c271927..0c90bd0 100644 --- a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/Message.java +++ b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/Message.java @@ -1,205 +1,205 @@ -/** - * 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.sdk.server.model; - -import java.io.Serializable; -import com.farsunset.cim.sdk.server.constant.CIMConstant; -import com.farsunset.cim.sdk.server.model.feature.EncodeFormatable; -import com.farsunset.cim.sdk.server.model.proto.MessageProto; - -/** - * 消息对象 - */ -public class Message implements Serializable, EncodeFormatable { - - private static final long serialVersionUID = 1L; - - /** - * 消息类型,用户自定义消息类别 - */ - private long id; - - /** - * 消息类型,用户自定义消息类别 - */ - private String action; - /** - * 消息标题 - */ - private String title; - /** - * 消息类容,于action 组合为任何类型消息,content 根据 format 可表示为 text,json ,xml数据格式 - */ - private String content; - - /** - * 消息发送者账号 - */ - private String sender; - /** - * 消息发送者接收者 - */ - private String receiver; - - /** - * content 内容格式 - */ - private String format; - - /** - * 附加内容 内容 - */ - private String extra; - - private long timestamp; - - public Message() { - timestamp = System.currentTimeMillis(); - } - - - public long getId() { - return id; - } - - - public void setId(long id) { - this.id = id; - } - - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getSender() { - return sender; - } - - public void setSender(String sender) { - this.sender = sender; - } - - public String getReceiver() { - return receiver; - } - - public void setReceiver(String receiver) { - this.receiver = receiver; - } - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - - public String getExtra() { - return extra; - } - - public void setExtra(String extra) { - this.extra = extra; - } - - @Override - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("#Message#").append("\n"); - buffer.append("id:").append(id).append("\n"); - buffer.append("action:").append(action).append("\n"); - buffer.append("title:").append(title).append("\n"); - buffer.append("content:").append(content).append("\n"); - buffer.append("extra:").append(extra).append("\n"); - buffer.append("sender:").append(sender).append("\n"); - buffer.append("receiver:").append(receiver).append("\n"); - buffer.append("format:").append(format).append("\n"); - buffer.append("timestamp:").append(timestamp); - return buffer.toString(); - } - - public boolean isNotEmpty(String txt) { - return txt != null && txt.trim().length() != 0; - } - - @Override - public byte[] getProtobufBody() { - MessageProto.Model.Builder builder = MessageProto.Model.newBuilder(); - builder.setId(id); - builder.setAction(action); - builder.setSender(sender); - builder.setReceiver(receiver); - builder.setTimestamp(timestamp); - - /** - * 下面字段可能为空 - */ - if (content != null) { - builder.setContent(content); - } - if (title != null) { - builder.setTitle(title); - } - if (extra != null) { - builder.setExtra(extra); - } - if (format != null) { - builder.setFormat(format); - } - return builder.build().toByteArray(); - } - - @Override - public byte getDataType() { - return CIMConstant.ProtobufType.MESSAGE; - } -} +/** + * 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.sdk.server.model; + +import java.io.Serializable; +import com.farsunset.cim.sdk.server.constant.CIMConstant; +import com.farsunset.cim.sdk.server.model.feature.EncodeFormatable; +import com.farsunset.cim.sdk.server.model.proto.MessageProto; + +/** + * 消息对象 + */ +public class Message implements Serializable, EncodeFormatable { + + private static final long serialVersionUID = 1L; + + /** + * 消息类型,用户自定义消息类别 + */ + private long id; + + /** + * 消息类型,用户自定义消息类别 + */ + private String action; + /** + * 消息标题 + */ + private String title; + /** + * 消息类容,于action 组合为任何类型消息,content 根据 format 可表示为 text,json ,xml数据格式 + */ + private String content; + + /** + * 消息发送者账号 + */ + private String sender; + /** + * 消息发送者接收者 + */ + private String receiver; + + /** + * content 内容格式 + */ + private String format; + + /** + * 附加内容 内容 + */ + private String extra; + + private long timestamp; + + public Message() { + timestamp = System.currentTimeMillis(); + } + + + public long getId() { + return id; + } + + + public void setId(long id) { + this.id = id; + } + + + public long getTimestamp() { + return timestamp; + } + + public void setTimestamp(long timestamp) { + this.timestamp = timestamp; + } + + public String getAction() { + return action; + } + + public void setAction(String action) { + this.action = action; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getSender() { + return sender; + } + + public void setSender(String sender) { + this.sender = sender; + } + + public String getReceiver() { + return receiver; + } + + public void setReceiver(String receiver) { + this.receiver = receiver; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getExtra() { + return extra; + } + + public void setExtra(String extra) { + this.extra = extra; + } + + @Override + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append("#Message#").append("\n"); + buffer.append("id:").append(id).append("\n"); + buffer.append("action:").append(action).append("\n"); + buffer.append("title:").append(title).append("\n"); + buffer.append("content:").append(content).append("\n"); + buffer.append("extra:").append(extra).append("\n"); + buffer.append("sender:").append(sender).append("\n"); + buffer.append("receiver:").append(receiver).append("\n"); + buffer.append("format:").append(format).append("\n"); + buffer.append("timestamp:").append(timestamp); + return buffer.toString(); + } + + public boolean isNotEmpty(String txt) { + return txt != null && txt.trim().length() != 0; + } + + @Override + public byte[] getProtobufBody() { + MessageProto.Model.Builder builder = MessageProto.Model.newBuilder(); + builder.setId(id); + builder.setAction(action); + builder.setSender(sender); + builder.setReceiver(receiver); + builder.setTimestamp(timestamp); + + /** + * 下面字段可能为空 + */ + if (content != null) { + builder.setContent(content); + } + if (title != null) { + builder.setTitle(title); + } + if (extra != null) { + builder.setExtra(extra); + } + if (format != null) { + builder.setFormat(format); + } + return builder.build().toByteArray(); + } + + @Override + public byte getDataType() { + return CIMConstant.ProtobufType.MESSAGE; + } +} diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/ReplyBody.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/ReplyBody.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/ReplyBody.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/ReplyBody.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/SentBody.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/SentBody.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/SentBody.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/SentBody.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/feature/EncodeFormatable.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/feature/EncodeFormatable.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/feature/EncodeFormatable.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/feature/EncodeFormatable.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/Message.proto b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/Message.proto similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/Message.proto rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/Message.proto diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/MessageProto.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/MessageProto.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/MessageProto.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/MessageProto.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/ReplyBody.proto b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/ReplyBody.proto similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/ReplyBody.proto rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/ReplyBody.proto diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/ReplyBodyProto.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/ReplyBodyProto.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/ReplyBodyProto.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/ReplyBodyProto.java diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SentBody.proto b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/SentBody.proto similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SentBody.proto rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/SentBody.proto diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SentBodyProto.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/SentBodyProto.java similarity index 100% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SentBodyProto.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/SentBodyProto.java diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/Session.proto b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/Session.proto similarity index 95% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/Session.proto rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/Session.proto index edce10d..da000b8 100644 --- a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/Session.proto +++ b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/Session.proto @@ -3,7 +3,7 @@ package com.farsunset.cim.sdk.server.model.proto; option java_outer_classname="SessionProto"; message Model { string account = 1; - int64 nid = 2; + string nid = 2; string deviceId = 3; string host = 4; string channel = 5; diff --git a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SessionProto.java b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/SessionProto.java similarity index 91% rename from cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SessionProto.java rename to cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/SessionProto.java index 8b2b859..966c489 100644 --- a/cim_for_mina/cim-server-sdk/src/com/farsunset/cim/sdk/server/model/proto/SessionProto.java +++ b/cim-server-sdk/cim-server-sdk-netty/src/com/farsunset/cim/sdk/server/model/proto/SessionProto.java @@ -29,9 +29,14 @@ public final class SessionProto { getAccountBytes(); /** - * int64 nid = 2; + * string nid = 2; */ - long getNid(); + java.lang.String getNid(); + /** + * string nid = 2; + */ + com.google.protobuf.ByteString + getNidBytes(); /** * string deviceId = 3; @@ -142,19 +147,14 @@ public final class SessionProto { } private Model() { account_ = ""; - nid_ = 0L; + nid_ = ""; deviceId_ = ""; host_ = ""; channel_ = ""; deviceModel_ = ""; clientVersion_ = ""; systemVersion_ = ""; - bindTime_ = 0L; - longitude_ = 0D; - latitude_ = 0D; location_ = ""; - apns_ = 0; - state_ = 0; } @java.lang.Override @@ -181,22 +181,16 @@ public final class SessionProto { case 0: done = true; break; - default: { - if (!parseUnknownFieldProto3( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } case 10: { java.lang.String s = input.readStringRequireUtf8(); account_ = s; break; } - case 16: { + case 18: { + java.lang.String s = input.readStringRequireUtf8(); - nid_ = input.readInt64(); + nid_ = s; break; } case 26: { @@ -266,6 +260,13 @@ public final class SessionProto { state_ = input.readInt32(); break; } + default: { + if (!parseUnknownField( + input, unknownFields, extensionRegistry, tag)) { + done = true; + } + break; + } } } } catch (com.google.protobuf.InvalidProtocolBufferException e) { @@ -283,6 +284,7 @@ public final class SessionProto { return com.farsunset.cim.sdk.server.model.proto.SessionProto.internal_static_com_farsunset_cim_sdk_server_model_proto_Model_descriptor; } + @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.farsunset.cim.sdk.server.model.proto.SessionProto.internal_static_com_farsunset_cim_sdk_server_model_proto_Model_fieldAccessorTable @@ -325,12 +327,37 @@ public final class SessionProto { } public static final int NID_FIELD_NUMBER = 2; - private long nid_; + private volatile java.lang.Object nid_; /** - * int64 nid = 2; + * string nid = 2; */ - public long getNid() { - return nid_; + public java.lang.String getNid() { + java.lang.Object ref = nid_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nid_ = s; + return s; + } + } + /** + * string nid = 2; + */ + public com.google.protobuf.ByteString + getNidBytes() { + java.lang.Object ref = nid_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } } public static final int DEVICEID_FIELD_NUMBER = 3; @@ -617,6 +644,7 @@ public final class SessionProto { } private byte memoizedIsInitialized = -1; + @java.lang.Override public final boolean isInitialized() { byte isInitialized = memoizedIsInitialized; if (isInitialized == 1) return true; @@ -626,13 +654,14 @@ public final class SessionProto { return true; } + @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { if (!getAccountBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 1, account_); } - if (nid_ != 0L) { - output.writeInt64(2, nid_); + if (!getNidBytes().isEmpty()) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, nid_); } if (!getDeviceIdBytes().isEmpty()) { com.google.protobuf.GeneratedMessageV3.writeString(output, 3, deviceId_); @@ -673,6 +702,7 @@ public final class SessionProto { unknownFields.writeTo(output); } + @java.lang.Override public int getSerializedSize() { int size = memoizedSize; if (size != -1) return size; @@ -681,9 +711,8 @@ public final class SessionProto { if (!getAccountBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, account_); } - if (nid_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, nid_); + if (!getNidBytes().isEmpty()) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, nid_); } if (!getDeviceIdBytes().isEmpty()) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, deviceId_); @@ -741,41 +770,38 @@ public final class SessionProto { } com.farsunset.cim.sdk.server.model.proto.SessionProto.Model other = (com.farsunset.cim.sdk.server.model.proto.SessionProto.Model) obj; - boolean result = true; - result = result && getAccount() - .equals(other.getAccount()); - result = result && (getNid() - == other.getNid()); - result = result && getDeviceId() - .equals(other.getDeviceId()); - result = result && getHost() - .equals(other.getHost()); - result = result && getChannel() - .equals(other.getChannel()); - result = result && getDeviceModel() - .equals(other.getDeviceModel()); - result = result && getClientVersion() - .equals(other.getClientVersion()); - result = result && getSystemVersion() - .equals(other.getSystemVersion()); - result = result && (getBindTime() - == other.getBindTime()); - result = result && ( - java.lang.Double.doubleToLongBits(getLongitude()) - == java.lang.Double.doubleToLongBits( - other.getLongitude())); - result = result && ( - java.lang.Double.doubleToLongBits(getLatitude()) - == java.lang.Double.doubleToLongBits( - other.getLatitude())); - result = result && getLocation() - .equals(other.getLocation()); - result = result && (getApns() - == other.getApns()); - result = result && (getState() - == other.getState()); - result = result && unknownFields.equals(other.unknownFields); - return result; + if (!getAccount() + .equals(other.getAccount())) return false; + if (!getNid() + .equals(other.getNid())) return false; + if (!getDeviceId() + .equals(other.getDeviceId())) return false; + if (!getHost() + .equals(other.getHost())) return false; + if (!getChannel() + .equals(other.getChannel())) return false; + if (!getDeviceModel() + .equals(other.getDeviceModel())) return false; + if (!getClientVersion() + .equals(other.getClientVersion())) return false; + if (!getSystemVersion() + .equals(other.getSystemVersion())) return false; + if (getBindTime() + != other.getBindTime()) return false; + if (java.lang.Double.doubleToLongBits(getLongitude()) + != java.lang.Double.doubleToLongBits( + other.getLongitude())) return false; + if (java.lang.Double.doubleToLongBits(getLatitude()) + != java.lang.Double.doubleToLongBits( + other.getLatitude())) return false; + if (!getLocation() + .equals(other.getLocation())) return false; + if (getApns() + != other.getApns()) return false; + if (getState() + != other.getState()) return false; + if (!unknownFields.equals(other.unknownFields)) return false; + return true; } @java.lang.Override @@ -788,8 +814,7 @@ public final class SessionProto { hash = (37 * hash) + ACCOUNT_FIELD_NUMBER; hash = (53 * hash) + getAccount().hashCode(); hash = (37 * hash) + NID_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getNid()); + hash = (53 * hash) + getNid().hashCode(); hash = (37 * hash) + DEVICEID_FIELD_NUMBER; hash = (53 * hash) + getDeviceId().hashCode(); hash = (37 * hash) + HOST_FIELD_NUMBER; @@ -892,6 +917,7 @@ public final class SessionProto { .parseWithIOException(PARSER, input, extensionRegistry); } + @java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() { return DEFAULT_INSTANCE.toBuilder(); @@ -899,6 +925,7 @@ public final class SessionProto { public static Builder newBuilder(com.farsunset.cim.sdk.server.model.proto.SessionProto.Model prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } + @java.lang.Override public Builder toBuilder() { return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); @@ -922,6 +949,7 @@ public final class SessionProto { return com.farsunset.cim.sdk.server.model.proto.SessionProto.internal_static_com_farsunset_cim_sdk_server_model_proto_Model_descriptor; } + @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { return com.farsunset.cim.sdk.server.model.proto.SessionProto.internal_static_com_farsunset_cim_sdk_server_model_proto_Model_fieldAccessorTable @@ -944,11 +972,12 @@ public final class SessionProto { .alwaysUseFieldBuilders) { } } + @java.lang.Override public Builder clear() { super.clear(); account_ = ""; - nid_ = 0L; + nid_ = ""; deviceId_ = ""; @@ -977,15 +1006,18 @@ public final class SessionProto { return this; } + @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { return com.farsunset.cim.sdk.server.model.proto.SessionProto.internal_static_com_farsunset_cim_sdk_server_model_proto_Model_descriptor; } + @java.lang.Override public com.farsunset.cim.sdk.server.model.proto.SessionProto.Model getDefaultInstanceForType() { return com.farsunset.cim.sdk.server.model.proto.SessionProto.Model.getDefaultInstance(); } + @java.lang.Override public com.farsunset.cim.sdk.server.model.proto.SessionProto.Model build() { com.farsunset.cim.sdk.server.model.proto.SessionProto.Model result = buildPartial(); if (!result.isInitialized()) { @@ -994,6 +1026,7 @@ public final class SessionProto { return result; } + @java.lang.Override public com.farsunset.cim.sdk.server.model.proto.SessionProto.Model buildPartial() { com.farsunset.cim.sdk.server.model.proto.SessionProto.Model result = new com.farsunset.cim.sdk.server.model.proto.SessionProto.Model(this); result.account_ = account_; @@ -1014,32 +1047,39 @@ public final class SessionProto { return result; } + @java.lang.Override public Builder clone() { - return (Builder) super.clone(); + return super.clone(); } + @java.lang.Override public Builder setField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return (Builder) super.setField(field, value); + return super.setField(field, value); } + @java.lang.Override public Builder clearField( com.google.protobuf.Descriptors.FieldDescriptor field) { - return (Builder) super.clearField(field); + return super.clearField(field); } + @java.lang.Override public Builder clearOneof( com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return (Builder) super.clearOneof(oneof); + return super.clearOneof(oneof); } + @java.lang.Override public Builder setRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { - return (Builder) super.setRepeatedField(field, index, value); + return super.setRepeatedField(field, index, value); } + @java.lang.Override public Builder addRepeatedField( com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { - return (Builder) super.addRepeatedField(field, value); + return super.addRepeatedField(field, value); } + @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { if (other instanceof com.farsunset.cim.sdk.server.model.proto.SessionProto.Model) { return mergeFrom((com.farsunset.cim.sdk.server.model.proto.SessionProto.Model)other); @@ -1055,8 +1095,9 @@ public final class SessionProto { account_ = other.account_; onChanged(); } - if (other.getNid() != 0L) { - setNid(other.getNid()); + if (!other.getNid().isEmpty()) { + nid_ = other.nid_; + onChanged(); } if (!other.getDeviceId().isEmpty()) { deviceId_ = other.deviceId_; @@ -1106,10 +1147,12 @@ public final class SessionProto { return this; } + @java.lang.Override public final boolean isInitialized() { return true; } + @java.lang.Override public Builder mergeFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) @@ -1197,28 +1240,71 @@ public final class SessionProto { return this; } - private long nid_ ; + private java.lang.Object nid_ = ""; /** - * int64 nid = 2; + * string nid = 2; */ - public long getNid() { - return nid_; + public java.lang.String getNid() { + java.lang.Object ref = nid_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = + (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + nid_ = s; + return s; + } else { + return (java.lang.String) ref; + } } /** - * int64 nid = 2; + * string nid = 2; */ - public Builder setNid(long value) { - + public com.google.protobuf.ByteString + getNidBytes() { + java.lang.Object ref = nid_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8( + (java.lang.String) ref); + nid_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * string nid = 2; + */ + public Builder setNid( + java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + nid_ = value; onChanged(); return this; } /** - * int64 nid = 2; + * string nid = 2; */ public Builder clearNid() { - nid_ = 0L; + nid_ = getDefaultInstance().getNid(); + onChanged(); + return this; + } + /** + * string nid = 2; + */ + public Builder setNidBytes( + com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + + nid_ = value; onChanged(); return this; } @@ -1835,11 +1921,13 @@ public final class SessionProto { onChanged(); return this; } + @java.lang.Override public final Builder setUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFieldsProto3(unknownFields); + return super.setUnknownFields(unknownFields); } + @java.lang.Override public final Builder mergeUnknownFields( final com.google.protobuf.UnknownFieldSet unknownFields) { return super.mergeUnknownFields(unknownFields); @@ -1861,6 +1949,7 @@ public final class SessionProto { private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + @java.lang.Override public Model parsePartialFrom( com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) @@ -1878,6 +1967,7 @@ public final class SessionProto { return PARSER; } + @java.lang.Override public com.farsunset.cim.sdk.server.model.proto.SessionProto.Model getDefaultInstanceForType() { return DEFAULT_INSTANCE; } @@ -1900,7 +1990,7 @@ public final class SessionProto { java.lang.String[] descriptorData = { "\n\rSession.proto\022(com.farsunset.cim.sdk.s" + "erver.model.proto\"\377\001\n\005Model\022\017\n\007account\030\001" + - " \001(\t\022\013\n\003nid\030\002 \001(\003\022\020\n\010deviceId\030\003 \001(\t\022\014\n\004h" + + " \001(\t\022\013\n\003nid\030\002 \001(\t\022\020\n\010deviceId\030\003 \001(\t\022\014\n\004h" + "ost\030\004 \001(\t\022\017\n\007channel\030\005 \001(\t\022\023\n\013deviceMode" + "l\030\006 \001(\t\022\025\n\rclientVersion\030\007 \001(\t\022\025\n\rsystem" + "Version\030\010 \001(\t\022\020\n\010bindTime\030\t \001(\003\022\021\n\tlongi" + diff --git a/cim_for_mina/cim-client-android/.gitignore b/cim-use-examples/cim-client-android/.gitignore similarity index 100% rename from cim_for_mina/cim-client-android/.gitignore rename to cim-use-examples/cim-client-android/.gitignore diff --git a/cim-use-examples/cim-client-android/.idea/caches/build_file_checksums.ser b/cim-use-examples/cim-client-android/.idea/caches/build_file_checksums.ser new file mode 100644 index 0000000..aff8cac Binary files /dev/null and b/cim-use-examples/cim-client-android/.idea/caches/build_file_checksums.ser differ diff --git a/cim-use-examples/cim-client-android/.idea/caches/gradle_models.ser b/cim-use-examples/cim-client-android/.idea/caches/gradle_models.ser new file mode 100644 index 0000000..b6cc572 Binary files /dev/null and b/cim-use-examples/cim-client-android/.idea/caches/gradle_models.ser differ diff --git a/cim-use-examples/cim-client-android/.idea/encodings.xml b/cim-use-examples/cim-client-android/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/cim-use-examples/cim-client-android/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/cim_for_mina/cim-client-android/.idea/gradle.xml b/cim-use-examples/cim-client-android/.idea/gradle.xml similarity index 100% rename from cim_for_mina/cim-client-android/.idea/gradle.xml rename to cim-use-examples/cim-client-android/.idea/gradle.xml diff --git a/cim_for_mina/cim-client-android/.idea/misc.xml b/cim-use-examples/cim-client-android/.idea/misc.xml similarity index 100% rename from cim_for_mina/cim-client-android/.idea/misc.xml rename to cim-use-examples/cim-client-android/.idea/misc.xml diff --git a/cim_for_mina/cim-client-android/.idea/modules.xml b/cim-use-examples/cim-client-android/.idea/modules.xml similarity index 100% rename from cim_for_mina/cim-client-android/.idea/modules.xml rename to cim-use-examples/cim-client-android/.idea/modules.xml diff --git a/cim_for_mina/cim-client-android/.idea/runConfigurations.xml b/cim-use-examples/cim-client-android/.idea/runConfigurations.xml similarity index 100% rename from cim_for_mina/cim-client-android/.idea/runConfigurations.xml rename to cim-use-examples/cim-client-android/.idea/runConfigurations.xml diff --git a/cim_for_mina/cim-client-android/.idea/vcs.xml b/cim-use-examples/cim-client-android/.idea/vcs.xml similarity index 56% rename from cim_for_mina/cim-client-android/.idea/vcs.xml rename to cim-use-examples/cim-client-android/.idea/vcs.xml index b2bdec2..822f525 100644 --- a/cim_for_mina/cim-client-android/.idea/vcs.xml +++ b/cim-use-examples/cim-client-android/.idea/vcs.xml @@ -1,6 +1,8 @@ + + \ No newline at end of file diff --git a/cim_for_mina/cim-client-android/app/.gitignore b/cim-use-examples/cim-client-android/app/.gitignore similarity index 100% rename from cim_for_mina/cim-client-android/app/.gitignore rename to cim-use-examples/cim-client-android/app/.gitignore diff --git a/cim_for_mina/cim-client-android/app/build.gradle b/cim-use-examples/cim-client-android/app/build.gradle similarity index 93% rename from cim_for_mina/cim-client-android/app/build.gradle rename to cim-use-examples/cim-client-android/app/build.gradle index 33d6139..72f3cbf 100644 --- a/cim_for_mina/cim-client-android/app/build.gradle +++ b/cim-use-examples/cim-client-android/app/build.gradle @@ -27,5 +27,4 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.google.protobuf:protobuf-java:3.7.0' - implementation 'org.apache.mina:mina-core:2.0.20' } diff --git a/cim_for_mina/cim-client-android/app/libs/cim-android-sdk-3.6.jar b/cim-use-examples/cim-client-android/app/libs/cim-android-sdk-3.7.0.jar similarity index 69% rename from cim_for_mina/cim-client-android/app/libs/cim-android-sdk-3.6.jar rename to cim-use-examples/cim-client-android/app/libs/cim-android-sdk-3.7.0.jar index 6486d6d..a255dd7 100644 Binary files a/cim_for_mina/cim-client-android/app/libs/cim-android-sdk-3.6.jar and b/cim-use-examples/cim-client-android/app/libs/cim-android-sdk-3.7.0.jar differ diff --git a/cim_for_mina/cim-client-android/app/proguard-rules.pro b/cim-use-examples/cim-client-android/app/proguard-rules.pro similarity index 100% rename from cim_for_mina/cim-client-android/app/proguard-rules.pro rename to cim-use-examples/cim-client-android/app/proguard-rules.pro diff --git a/cim_for_mina/cim-client-android/app/src/main/AndroidManifest.xml b/cim-use-examples/cim-client-android/app/src/main/AndroidManifest.xml similarity index 98% rename from cim_for_mina/cim-client-android/app/src/main/AndroidManifest.xml rename to cim-use-examples/cim-client-android/app/src/main/AndroidManifest.xml index 5d3e85e..5f38a8d 100644 --- a/cim_for_mina/cim-client-android/app/src/main/AndroidManifest.xml +++ b/cim-use-examples/cim-client-android/app/src/main/AndroidManifest.xml @@ -48,7 +48,8 @@ + android:process=":cimpush" + /> + + + + + + + + diff --git a/cim_for_netty/cim-java-sdk/.project b/cim-use-examples/cim-client-java/.project similarity index 59% rename from cim_for_netty/cim-java-sdk/.project rename to cim-use-examples/cim-client-java/.project index f63422e..1b7a502 100644 --- a/cim_for_netty/cim-java-sdk/.project +++ b/cim-use-examples/cim-client-java/.project @@ -1,6 +1,6 @@ - cim-java-sdk + cim-client-java @@ -10,14 +10,8 @@ - - com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder - - - - com.genuitec.eclipse.ast.deploy.core.deploymentnature org.eclipse.jdt.core.javanature diff --git a/cim_for_netty/cim-android-sdk/.settings/org.eclipse.jdt.core.prefs b/cim-use-examples/cim-client-java/.settings/org.eclipse.jdt.core.prefs similarity index 67% rename from cim_for_netty/cim-android-sdk/.settings/org.eclipse.jdt.core.prefs rename to cim-use-examples/cim-client-java/.settings/org.eclipse.jdt.core.prefs index d17b672..3a21537 100644 --- a/cim_for_netty/cim-android-sdk/.settings/org.eclipse.jdt.core.prefs +++ b/cim-use-examples/cim-client-java/.settings/org.eclipse.jdt.core.prefs @@ -1,12 +1,11 @@ eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/cim-use-examples/cim-client-java/lib/cim-java-sdk-3.7.0.jar b/cim-use-examples/cim-client-java/lib/cim-java-sdk-3.7.0.jar new file mode 100644 index 0000000..e51ca99 Binary files /dev/null and b/cim-use-examples/cim-client-java/lib/cim-java-sdk-3.7.0.jar differ diff --git a/cim-use-examples/cim-client-java/lib/slf4j-api-1.7.5.jar b/cim-use-examples/cim-client-java/lib/slf4j-api-1.7.5.jar new file mode 100644 index 0000000..8766455 Binary files /dev/null and b/cim-use-examples/cim-client-java/lib/slf4j-api-1.7.5.jar differ diff --git a/cim-use-examples/cim-client-java/lib/slf4j-nop-1.7.5.jar b/cim-use-examples/cim-client-java/lib/slf4j-nop-1.7.5.jar new file mode 100644 index 0000000..e55bdd8 Binary files /dev/null and b/cim-use-examples/cim-client-java/lib/slf4j-nop-1.7.5.jar differ diff --git a/cim-use-examples/cim-client-java/src/CIMJavaClient.java b/cim-use-examples/cim-client-java/src/CIMJavaClient.java new file mode 100644 index 0000000..503439e --- /dev/null +++ b/cim-use-examples/cim-client-java/src/CIMJavaClient.java @@ -0,0 +1,93 @@ +import com.farsunset.cim.sdk.client.CIMEventBroadcastReceiver; +import com.farsunset.cim.sdk.client.CIMEventListener; +import com.farsunset.cim.sdk.client.CIMPushManager; +import com.farsunset.cim.sdk.client.model.Message; +import com.farsunset.cim.sdk.client.model.ReplyBody; +public class CIMJavaClient implements CIMEventListener { + public static void startup() { + /** + * 第一步 设置运行时参数 + */ + CIMPushManager.setClientVersion("1.0.0");// 客户端程序版本 + + + /** + * 第二步 设置全局的事件监听器 + */ + CIMEventBroadcastReceiver.getInstance().setGlobalCIMEventListener(new CIMJavaClient()); + + + /** + * 第三步 连接到服务器 + */ + CIMPushManager.connect("127.0.0.1", 23456); + + } + + + @Override + public void onConnectionClosed() { + System.out.println("onConnectionClosed"); + /** + * 在此可以将事件分发到各个监听了CIMEventBroadcastReceiver的地方 + * 第一步 连接到服务器 在需要监听事件的类调用CIMListenerManager.registerMessageListener(listener); + * 第二部 在此调用CIMListenerManager.notifyOnConnectionClosed() + */ + } + + @Override + public void onConnectionFailed() { + System.out.println("onConnectionFailed"); + /** + * 在此可以将事件分发到各个监听了CIMEventBroadcastReceiver的地方 + * 第一步 连接到服务器 在需要监听事件的类调用CIMListenerManager.registerMessageListener(listener); + * 第二部 在此调用CIMListenerManager.notifyOnConnectionFailed(e) + */ + } + + @Override + public void onConnectionSuccessed(boolean hasAutoBind) { + System.out.println("onConnectionSuccessed"); + if(!hasAutoBind){ + CIMPushManager.bindAccount("10000"); + } + /** + * 在此可以将事件分发到各个监听了CIMEventBroadcastReceiver的地方 + * 第一步 连接到服务器 在需要监听事件的类调用CIMListenerManager.registerMessageListener(listener); + * 第二部 在此调用CIMListenerManager.notifyOnConnectionSuccessed(hasAutoBind) + */ + } + + @Override + public void onMessageReceived(Message message) { + System.out.println(message.toString()); + /** + * 在此可以将事件分发到各个监听了CIMEventBroadcastReceiver的地方 + * 第一步 连接到服务器 在需要监听事件的类调用CIMListenerManager.registerMessageListener(listener); + * 第二部 在此调用CIMListenerManager.notifyOnMessageReceived(message) + */ + } + + + @Override + public void onReplyReceived(ReplyBody replybody) { + System.out.println(replybody.toString()); + /** + * 在此可以将事件分发到各个监听了CIMEventBroadcastReceiver的地方 + * 第一步 连接到服务器 在需要监听事件的类调用CIMListenerManager.registerMessageListener(listener); + * 第二部 在此调用CIMListenerManager.notifyOnReplyReceived(replybody) + */ + } + + public static void main(String[] a){ + startup(); + } + + + @Override + public int getEventDispatchOrder() { + // TODO Auto-generated method stub + return 0; + } + +} diff --git a/cim-use-examples/cim-client-web/README.txt b/cim-use-examples/cim-client-web/README.txt new file mode 100644 index 0000000..40151e1 --- /dev/null +++ b/cim-use-examples/cim-client-web/README.txt @@ -0,0 +1 @@ +Զ̵/js/cim/cim.web.sdk.js һ޸ķIPַ \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/css/bootstrap.min.css b/cim-use-examples/cim-client-web/css/bootstrap.min.css similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/css/bootstrap.min.css rename to cim-use-examples/cim-client-web/css/bootstrap.min.css diff --git a/cim-use-examples/cim-client-web/css/common.css b/cim-use-examples/cim-client-web/css/common.css new file mode 100644 index 0000000..5f2959c --- /dev/null +++ b/cim-use-examples/cim-client-web/css/common.css @@ -0,0 +1 @@ +@CHARSET "UTF-8";html,body{height:100%;font-family:微软雅黑;background:url(../image/pattern.png) repeat,linear-gradient(#e1e4e7,#f3f4f5);}.header{position:fixed;height:100px;background:#2b345d;width:100%;z-index:999;line-height:100px;-webkit-box-shadow:0 0 12px 0 #0d1e33;box-shadow:0 0 12px 0 #0d1e33;}.header_liner{position:fixed;height:5px;top:95px;width:100%;z-index:998;background:linear-gradient(to right,#ff4444,#99cc00,#33b5e5,#aa66cc,#ffbb33);}#mainWrapper{width:auto;margin-left:180px;min-height:600px;padding-bottom:50px;padding-top:100px;}ul,ol{margin:0;padding:0;list-style:none;}.tip_blue{zoom:1;background:#3391D7;color:#FFFFFF;text-align:center;line-height:50px;height:50px;font-family:楷体;min-width:300px;position:absolute;z-index:9999;font-size:16px;font-weight:bold;padding:0 15px;border-radius:3px;border:1px solid rgba(0,0,0,.2);-webkit-box-shadow:0 3px 9px rgba(0,0,0,.4);box-shadow:0 3px 5px rgba(0,0,0,.4);}.tip_red{zoom:1;background:#DF3D3D;color:#FFFFFF;text-align:center;font-family:楷体;line-height:50px;height:50px;min-width:300px;position:absolute;z-index:9999;font-size:16px;font-weight:bold;padding:0 15px;border-radius:3px;border:1px solid rgba(0,0,0,.2);-webkit-box-shadow:0 3px 9px rgba(0,0,0,.4);box-shadow:0 3px 5px rgba(0,0,0,.4);}.tip_green{zoom:1;background:#54ad18;color:#ffffff;text-align:center;font-family:楷体;line-height:50px;height:50px;min-width:300px;position:absolute;z-index:9999;font-size:16px;font-weight:bold;padding:0 15px;border-radius:3px;border:1px solid rgba(0,0,0,.2);-webkit-box-shadow:0 3px 9px rgba(0,0,0,.4);box-shadow:0 3px 5px rgba(0,0,0,.4);}.tip_process{zoom:1;color:#394A5E;text-align:center;line-height:50px;height:50px;font-family:楷体;background-color:white;min-width:300px;position:absolute;z-index:9999;border-radius:4px;border:1px solid rgba(0,0,0,.2);-webkit-box-shadow:0 3px 9px rgba(0,0,0,.5);box-shadow:0 3px 9px rgba(0,0,0,.5);}.icon_loading_small{background:url(../image/icon_loading_small.gif) no-repeat;width:22px;height:22px;left:20px;top:15px;position:absolute;}.form-group label{width:70px;text-align:right;}.lay-main-toolbar{height:60px;border-radius:0px;border-right:1px solid #B5BBBF;border-bottom:#c8c8c8 solid 1px;background:white;box-shadow:rgba(0,0,0,0.15) 0px 1px 8px;position:relative;width:100%;padding:8px;}.nav-menu-divider{box-shadow:#e9eaeb 0px 1px 0px;border-bottom:#c4c6c7 solid 1px;}.btn i{font-size:17px;margin-right:2px;font-weight:bold;font-style:normal;line-height:17px;}.modal-dialog{margin:150px auto;}.dialog_close:hover,.dialog_close:focus{opacity:.6;filter:alpha(opacity=60);}.gdialog .modal-header{cursor:move;}.ui-vnav{position:fixed;top:100px;left:0;width:180px;min-height:560px;height:960px;_overflow:hidden;background:#ffffff;z-index:88;box-shadow:1px 0 4px rgba(0,0,0,.3);}.ui-vnav .ui-bar{height:20px;overflow:hidden;}.ui-vnav .ui-bd{display:block;margin:9px 0;width:100%;height:0px;line-height:0px;border-top:1px solid #afb1b2;border-bottom:1px solid #eaeaea;}.ui-vnav .ui-item{height:45px;line-height:45px;padding:0 10px;text-align:center;cursor:pointer;border-bottom:1px #e4e5e6 solid;}.ui-vnav .ui-item:hover{color:white;background-color:#F3F3F3;}.ui-vnav .current,.ui-vnav .current:hover{background-color:#FFFFFF;border-left:6px #44b549 solid;padding-left:4px;}.ui-vnav .ui-item a{position:relative;display:block;height:45px;line-height:45px;font-size:16px;color:#666;text-decoration:none;}.ui-vnav .ui-shd{position:absolute;right:0;top:0;width:4px;height:100%;overflow:hidden;border-right:1px solid #b5b5b6;background-image:-webkit-linear-gradient(left,transparent,rgba(0,0,0,.1));background-image:-moz-linear-gradient(left,transparent,rgba(0,0,0,.1));background-image:-o-linear-gradient(left,transparent,rgba(0,0,0,.1));background-image:linear-gradient(top right,transparent,#c9cacb);filter:progid:DXImageTransform.Microsoft.gradient(startColorStr='#00DBDCDD',EndColorStr='#B5B5B6',gradientType=1);}.utable{border-collapse:collapse;border-spacing:0;text-align:center;font-size:12px;background:#ffffff;word-break:break-all;table-layout:fixed;margin-right:10px;}.utable tr th{background-color:#eff1f9;border-right:solid 1px #D4D4D4;border-left:solid 1px #D4D4D4;border-bottom:solid 1px #D4D4D4;color:#463E5E;line-height:40px;font-size:14px;text-align:center;}.utable tr:hover{background-color:#f5f6f9;}.utable tr td{border-right:solid 1px #D4D4D4;border-bottom:solid 1px #D4D4D4;color:#666;max-height:80px;line-height:35px;height:35px;padding-left:5px;padding-right:5px;word-break:keep-all;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.datarecord{text-align:center;line-height:30px;background-color:#14A7D5;margin-right:10px;}.input-pagenumber{width:50px;display:inline;height:31px;margin-left:20px;border-top-left-radius:4px;border-bottom-left-radius:4px;border-top-right-radius:0px;border-bottom-right-radius:0px;}textarea{resize:none;}.modal-header{border-bottom:#c8c8c8 solid 1px;box-shadow:rgba(0,0,0,0.15) 0px 1px 8px;height:50px;}.modal-open .modal{overflow-y:hidden;}.btn:focus,button:focus{outline:none;}.bar-button{color:#222222;background-color:#ffffff;border-color:#7d7d7d;}.input-required{border-color:#e91e63;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(204,42,79,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(204,42,79,.6);} \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.eot b/cim-use-examples/cim-client-web/fonts/glyphicons-halflings-regular.eot similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.eot rename to cim-use-examples/cim-client-web/fonts/glyphicons-halflings-regular.eot diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.svg b/cim-use-examples/cim-client-web/fonts/glyphicons-halflings-regular.svg similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.svg rename to cim-use-examples/cim-client-web/fonts/glyphicons-halflings-regular.svg diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.ttf b/cim-use-examples/cim-client-web/fonts/glyphicons-halflings-regular.ttf similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.ttf rename to cim-use-examples/cim-client-web/fonts/glyphicons-halflings-regular.ttf diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff b/cim-use-examples/cim-client-web/fonts/glyphicons-halflings-regular.woff similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff rename to cim-use-examples/cim-client-web/fonts/glyphicons-halflings-regular.woff diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff2 b/cim-use-examples/cim-client-web/fonts/glyphicons-halflings-regular.woff2 similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/fonts/glyphicons-halflings-regular.woff2 rename to cim-use-examples/cim-client-web/fonts/glyphicons-halflings-regular.woff2 diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/image/icon.png b/cim-use-examples/cim-client-web/image/icon.png similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/image/icon.png rename to cim-use-examples/cim-client-web/image/icon.png diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/image/icon_loading_small.gif b/cim-use-examples/cim-client-web/image/icon_loading_small.gif similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/image/icon_loading_small.gif rename to cim-use-examples/cim-client-web/image/icon_loading_small.gif diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/image/pattern.png b/cim-use-examples/cim-client-web/image/pattern.png similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/image/pattern.png rename to cim-use-examples/cim-client-web/image/pattern.png diff --git a/cim-use-examples/cim-client-web/index.html b/cim-use-examples/cim-client-web/index.html new file mode 100644 index 0000000..e9ef0f6 --- /dev/null +++ b/cim-use-examples/cim-client-web/index.html @@ -0,0 +1,161 @@ + + + + +CIM Webclient + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/bootstrap.min.js b/cim-use-examples/cim-client-web/js/bootstrap.min.js similarity index 100% rename from cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/bootstrap.min.js rename to cim-use-examples/cim-client-web/js/bootstrap.min.js diff --git a/cim-use-examples/cim-client-web/js/cim/cim.web.sdk.js b/cim-use-examples/cim-client-web/js/cim/cim.web.sdk.js new file mode 100644 index 0000000..42d63db --- /dev/null +++ b/cim-use-examples/cim-client-web/js/cim/cim.web.sdk.js @@ -0,0 +1,215 @@ +/*CIM服务器IP*/ +var CIM_HOST = "127.0.0.1"; +/*CIM服务端口*/ +var CIM_PORT = 23456; +var CIM_URI="ws://"+CIM_HOST+":"+CIM_PORT; + +var CMD_HEARTBEAT_RESPONSE = new Uint8Array([67,82]); +var SDK_VERSION = "1.0.0"; +var SDK_CHANNEL = "browser"; +var APP_PACKAGE = "com.farsunset.cim"; +var ACTION_999 = "999";//特殊的消息类型,代表被服务端强制下线 +var DATA_HEADER_LENGTH = 3; + +var C_H_RS = 0; +var S_H_RQ = 1; +var MESSAGE = 2; +var SENTBODY = 3; +var REPLYBODY = 4; + +var socket; +var manualStop = false; +var CIMPushManager = {}; +CIMPushManager.connection = function(){ + manualStop = false; + window.localStorage.account = ''; + socket = new WebSocket(CIM_URI); + socket.binaryType = 'arraybuffer'; + socket.onopen = CIMPushManager.innerOnConnectionSuccessed; + socket.onmessage = CIMPushManager.innerOnMessageReceived; + socket.onclose = CIMPushManager.innerOnConnectionClosed; +}; + +CIMPushManager.bindAccount = function(account){ + + window.localStorage.account = account; + + var deviceId = window.localStorage.deviceIddeviceId; + if(deviceId == '' || deviceId == undefined){ + deviceId = generateUUID(); + window.localStorage.deviceId = deviceId; + } + + var browser = getBrowser(); + var body = new proto.com.farsunset.cim.sdk.web.model.SentBody(); + body.setKey("client_bind"); + body.getDataMap().set("account",account); + body.getDataMap().set("channel",SDK_CHANNEL); + body.getDataMap().set("version",SDK_VERSION); + body.getDataMap().set("osVersion", browser.version); + body.getDataMap().set("packageName", APP_PACKAGE); + body.getDataMap().set("deviceId", deviceId); + body.getDataMap().set("device", browser.name); + CIMPushManager.sendRequest(body); +}; + +CIMPushManager.stop = function(){ + manualStop = true; + socket.close(); +}; + +CIMPushManager.resume = function(){ + manualStop = false; + CIMPushManager.connection(); +}; + + +CIMPushManager.innerOnConnectionSuccessed = function(){ + var account = window.localStorage.account; + if(account == '' || account == undefined){ + onConnectionSuccessed(); + }else{ + CIMPushManager.bindAccount(account); + } +}; + + + +CIMPushManager.innerOnMessageReceived = function(e){ + var data = new Uint8Array(e.data); + + var type = data[0]; + + /** + * 收到服务端发来的心跳请求,立即回复响应,否则服务端会在10秒后断开连接 + */ + if(type == S_H_RQ){ + CIMPushManager.sendHeartbeatResponse(); + return; + } + + if(type == MESSAGE){ + var length = getContentLength(data[1],data[2]); + var data = proto.com.farsunset.cim.sdk.web.model.Message.deserializeBinary(data.subarray(DATA_HEADER_LENGTH,DATA_HEADER_LENGTH+length)); + onInterceptMessageReceived(data.toObject(false)); + return; + } + + if(type == REPLYBODY){ + var length = getContentLength(data[1],data[2]); + var data = proto.com.farsunset.cim.sdk.web.model.ReplyBody.deserializeBinary(data.subarray(DATA_HEADER_LENGTH,DATA_HEADER_LENGTH+length)); + /** + * 将proto对象转换成json对象,去除无用信息 + */ + var reply = {}; + reply.code = data.getCode(); + reply.key = data.getKey(); + reply.message = data.getMessage(); + reply.timestamp = data.getTimestamp(); + reply.data = {}; + + /** + * 注意,遍历map这里的参数 value在前key在后 + */ + data.getDataMap().forEach(function (v,k){ + reply.data[k] = v; + }); + + onReplyReceived(reply); + } +}; + +CIMPushManager.innerOnConnectionClosed = function(e){ + if(!manualStop){ + var time = Math.floor(Math.random()*(30-15+1)+15); + setTimeout(function(){ + CIMPushManager.connection(); + },time); + } +}; + +CIMPushManager.sendRequest = function(body){ + + var data = body.serializeBinary(); + var header = buildHeader(SENTBODY,data.length); + var protubuf = new Uint8Array(data.length + header.length); + protubuf.set(header,0); + protubuf.set(data,header.length); + socket.send(protubuf); +}; + +CIMPushManager.sendHeartbeatResponse = function(){ + var data = CMD_HEARTBEAT_RESPONSE; + var header = buildHeader(C_H_RS,data.length); + var protubuf = new Uint8Array(data.length + header.length); + protubuf.set(header,0); + protubuf.set(data,header.length); + socket.send(protubuf); +}; + +function getContentLength( lv, hv) { + var l = (lv & 0xff); + var h = (hv & 0xff); + return (l | (h <<= 8)); +} + +function buildHeader(type,length){ + var header = new Uint8Array(DATA_HEADER_LENGTH); + header[0] = type; + header[1] = (length & 0xff); + header[2] = ((length >> 8) & 0xff); + return header; + +} +function onInterceptMessageReceived(message){ + //被强制下线之后,不再继续连接服务端 + if(message.action == ACTION_999){ + manualStop = true; + } + //收到消息后,将消息发送给页面 + if(onMessageReceived instanceof Function){ + onMessageReceived(message); + } +} + +function getBrowser() { + var explorer = window.navigator.userAgent.toLowerCase() ; + // ie + if (explorer.indexOf("msie") >= 0) { + var ver=explorer.match(/msie ([\d.]+)/)[1]; + return {name:"IE",version:ver}; + } + // firefox + else if (explorer.indexOf("firefox") >= 0) { + var ver=explorer.match(/firefox\/([\d.]+)/)[1]; + return {name:"Firefox",version:ver}; + } + // Chrome + else if(explorer.indexOf("chrome") >= 0){ + var ver=explorer.match(/chrome\/([\d.]+)/)[1]; + return {name:"Chrome",version:ver}; + } + // Opera + else if(explorer.indexOf("opera") >= 0){ + var ver=explorer.match(/opera.([\d.]+)/)[1]; + return {name:"Opera",version:ver}; + } + // Safari + else if(explorer.indexOf("Safari") >= 0){ + var ver=explorer.match(/version\/([\d.]+)/)[1]; + return {name:"Safari",version:ver}; + } + + return {name:"Other",version:"1.0.0"}; +} + +function generateUUID() { + var d = new Date().getTime(); + var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { + var r = (d + Math.random()*16)%16 | 0; + d = Math.floor(d/16); + return (c=='x' ? r : (r&0x3|0x8)).toString(16); + }); + return uuid.replace(/-/g,''); +} + \ No newline at end of file diff --git a/cim-use-examples/cim-client-web/js/cim/message.js b/cim-use-examples/cim-client-web/js/cim/message.js new file mode 100644 index 0000000..30b942a --- /dev/null +++ b/cim-use-examples/cim-client-web/js/cim/message.js @@ -0,0 +1,2774 @@ +(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i, eg, foo.pb_default. + * For the list of reserved names please see: + * com.google.apps.jspb.JsClassTemplate.JS_RESERVED_WORDS. + * @param {boolean=} opt_includeInstance Whether to include the JSPB instance + * for transitional soy proto support: http://goto/soy-param-migration + * @return {!Object} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.toObject = function(opt_includeInstance) { + return proto.com.farsunset.cim.sdk.web.model.Message.toObject(opt_includeInstance, this); +}; + + +/** + * Static version of the {@see toObject} method. + * @param {boolean|undefined} includeInstance Whether to include the JSPB + * instance for transitional soy proto support: + * http://goto/soy-param-migration + * @param {!proto.com.farsunset.cim.sdk.web.model.Message} msg The msg instance to transform. + * @return {!Object} + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.com.farsunset.cim.sdk.web.model.Message.toObject = function(includeInstance, msg) { + var obj = { + id: jspb.Message.getFieldWithDefault(msg, 1, 0), + action: jspb.Message.getFieldWithDefault(msg, 2, ""), + content: jspb.Message.getFieldWithDefault(msg, 3, ""), + sender: jspb.Message.getFieldWithDefault(msg, 4, ""), + receiver: jspb.Message.getFieldWithDefault(msg, 5, ""), + extra: jspb.Message.getFieldWithDefault(msg, 6, ""), + title: jspb.Message.getFieldWithDefault(msg, 7, ""), + format: jspb.Message.getFieldWithDefault(msg, 8, ""), + timestamp: jspb.Message.getFieldWithDefault(msg, 9, 0) + }; + + if (includeInstance) { + obj.$jspbMessageInstance = msg; + } + return obj; +}; +} + + +/** + * Deserializes binary data (in protobuf wire format). + * @param {jspb.ByteSource} bytes The bytes to deserialize. + * @return {!proto.com.farsunset.cim.sdk.web.model.Message} + */ +proto.com.farsunset.cim.sdk.web.model.Message.deserializeBinary = function(bytes) { + var reader = new jspb.BinaryReader(bytes); + var msg = new proto.com.farsunset.cim.sdk.web.model.Message; + return proto.com.farsunset.cim.sdk.web.model.Message.deserializeBinaryFromReader(msg, reader); +}; + + +/** + * Deserializes binary data (in protobuf wire format) from the + * given reader into the given message object. + * @param {!proto.com.farsunset.cim.sdk.web.model.Message} msg The message object to deserialize into. + * @param {!jspb.BinaryReader} reader The BinaryReader to use. + * @return {!proto.com.farsunset.cim.sdk.web.model.Message} + */ +proto.com.farsunset.cim.sdk.web.model.Message.deserializeBinaryFromReader = function(msg, reader) { + while (reader.nextField()) { + if (reader.isEndGroup()) { + break; + } + var field = reader.getFieldNumber(); + switch (field) { + case 1: + var value = /** @type {number} */ (reader.readInt64()); + msg.setId(value); + break; + case 2: + var value = /** @type {string} */ (reader.readString()); + msg.setAction(value); + break; + case 3: + var value = /** @type {string} */ (reader.readString()); + msg.setContent(value); + break; + case 4: + var value = /** @type {string} */ (reader.readString()); + msg.setSender(value); + break; + case 5: + var value = /** @type {string} */ (reader.readString()); + msg.setReceiver(value); + break; + case 6: + var value = /** @type {string} */ (reader.readString()); + msg.setExtra(value); + break; + case 7: + var value = /** @type {string} */ (reader.readString()); + msg.setTitle(value); + break; + case 8: + var value = /** @type {string} */ (reader.readString()); + msg.setFormat(value); + break; + case 9: + var value = /** @type {number} */ (reader.readInt64()); + msg.setTimestamp(value); + break; + default: + reader.skipField(); + break; + } + } + return msg; +}; + + +/** + * Serializes the message to binary data (in protobuf wire format). + * @return {!Uint8Array} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.serializeBinary = function() { + var writer = new jspb.BinaryWriter(); + proto.com.farsunset.cim.sdk.web.model.Message.serializeBinaryToWriter(this, writer); + return writer.getResultBuffer(); +}; + + +/** + * Serializes the given message to binary data (in protobuf wire + * format), writing to the given BinaryWriter. + * @param {!proto.com.farsunset.cim.sdk.web.model.Message} message + * @param {!jspb.BinaryWriter} writer + * @suppress {unusedLocalVariables} f is only used for nested messages + */ +proto.com.farsunset.cim.sdk.web.model.Message.serializeBinaryToWriter = function(message, writer) { + var f = undefined; + f = message.getId(); + if (f !== 0) { + writer.writeInt64( + 1, + f + ); + } + f = message.getAction(); + if (f.length > 0) { + writer.writeString( + 2, + f + ); + } + f = message.getContent(); + if (f.length > 0) { + writer.writeString( + 3, + f + ); + } + f = message.getSender(); + if (f.length > 0) { + writer.writeString( + 4, + f + ); + } + f = message.getReceiver(); + if (f.length > 0) { + writer.writeString( + 5, + f + ); + } + f = message.getExtra(); + if (f.length > 0) { + writer.writeString( + 6, + f + ); + } + f = message.getTitle(); + if (f.length > 0) { + writer.writeString( + 7, + f + ); + } + f = message.getFormat(); + if (f.length > 0) { + writer.writeString( + 8, + f + ); + } + f = message.getTimestamp(); + if (f !== 0) { + writer.writeInt64( + 9, + f + ); + } +}; + + +/** + * optional int64 id = 1; + * @return {number} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.getId = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 1, 0)); +}; + + +/** @param {number} value */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.setId = function(value) { + jspb.Message.setProto3IntField(this, 1, value); +}; + + +/** + * optional string action = 2; + * @return {string} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.getAction = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, "")); +}; + + +/** @param {string} value */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.setAction = function(value) { + jspb.Message.setProto3StringField(this, 2, value); +}; + + +/** + * optional string content = 3; + * @return {string} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.getContent = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, "")); +}; + + +/** @param {string} value */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.setContent = function(value) { + jspb.Message.setProto3StringField(this, 3, value); +}; + + +/** + * optional string sender = 4; + * @return {string} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.getSender = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, "")); +}; + + +/** @param {string} value */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.setSender = function(value) { + jspb.Message.setProto3StringField(this, 4, value); +}; + + +/** + * optional string receiver = 5; + * @return {string} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.getReceiver = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, "")); +}; + + +/** @param {string} value */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.setReceiver = function(value) { + jspb.Message.setProto3StringField(this, 5, value); +}; + + +/** + * optional string extra = 6; + * @return {string} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.getExtra = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, "")); +}; + + +/** @param {string} value */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.setExtra = function(value) { + jspb.Message.setProto3StringField(this, 6, value); +}; + + +/** + * optional string title = 7; + * @return {string} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.getTitle = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 7, "")); +}; + + +/** @param {string} value */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.setTitle = function(value) { + jspb.Message.setProto3StringField(this, 7, value); +}; + + +/** + * optional string format = 8; + * @return {string} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.getFormat = function() { + return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 8, "")); +}; + + +/** @param {string} value */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.setFormat = function(value) { + jspb.Message.setProto3StringField(this, 8, value); +}; + + +/** + * optional int64 timestamp = 9; + * @return {number} + */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.getTimestamp = function() { + return /** @type {number} */ (jspb.Message.getFieldWithDefault(this, 9, 0)); +}; + + +/** @param {number} value */ +proto.com.farsunset.cim.sdk.web.model.Message.prototype.setTimestamp = function(value) { + jspb.Message.setProto3IntField(this, 9, value); +}; + + +goog.object.extend(exports, proto.com.farsunset.cim.sdk.web.model); + +},{"google-protobuf":3}],2:[function(require,module,exports){ +var myProto = require('./Message_pb'); + + module.exports = { + DataProto: myProto + } +},{"./Message_pb":1}],3:[function(require,module,exports){ +(function (global,Buffer){ +var $jscomp={scope:{},getGlobal:function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global?global:a}};$jscomp.global=$jscomp.getGlobal(this);$jscomp.initSymbol=function(){$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol);$jscomp.initSymbol=function(){}};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(a){return"jscomp_symbol_"+a+$jscomp.symbolCounter_++}; +$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();$jscomp.global.Symbol.iterator||($jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));$jscomp.initSymbolIterator=function(){}};$jscomp.makeIterator=function(a){$jscomp.initSymbolIterator();$jscomp.initSymbol();$jscomp.initSymbolIterator();var b=a[Symbol.iterator];if(b)return b.call(a);var c=0;return{next:function(){return cb;)--c in this?this[--a]=this[c]:delete this[a];return this};$jscomp.array.copyWithin$install=function(){$jscomp.array.installHelper_("copyWithin",$jscomp.array.copyWithin)}; +$jscomp.array.fill=function(a,b,c){var d=this.length||0;0>b&&(b=Math.max(0,d+b));if(null==c||c>d)c=d;c=Number(c);0>c&&(c=Math.max(0,d+c));for(b=Number(b||0);b>>0;if(0===a)return 32;var b=0;0===(a&4294901760)&&(a<<=16,b+=16);0===(a&4278190080)&&(a<<=8,b+=8);0===(a&4026531840)&&(a<<=4,b+=4);0===(a&3221225472)&&(a<<=2,b+=2);0===(a&2147483648)&&b++;return b};$jscomp.math.imul=function(a,b){a=Number(a);b=Number(b);var c=a&65535,d=b&65535;return c*d+((a>>>16&65535)*d+c*(b>>>16&65535)<<16>>>0)|0};$jscomp.math.sign=function(a){a=Number(a);return 0===a||isNaN(a)?a:0a&&-.25a&&-.25a?-b:b};$jscomp.math.acosh=function(a){a=Number(a);return Math.log(a+Math.sqrt(a*a-1))};$jscomp.math.asinh=function(a){a=Number(a);if(0===a)return a;var b=Math.log(Math.abs(a)+Math.sqrt(a*a+1));return 0>a?-b:b}; +$jscomp.math.atanh=function(a){a=Number(a);return($jscomp.math.log1p(a)-$jscomp.math.log1p(-a))/2};$jscomp.math.hypot=function(a,b,c){a=Number(a);b=Number(b);var d,e,f,g=Math.max(Math.abs(a),Math.abs(b));for(d=2;dg){a/=g;b/=g;f=a*a+b*b;for(d=2;da?-b:b};$jscomp.math.cbrt=function(a){if(0===a)return a;a=Number(a);var b=Math.pow(Math.abs(a),1/3);return 0>a?-b:b};$jscomp.number=$jscomp.number||{};$jscomp.number.isFinite=function(a){return"number"!==typeof a?!1:!isNaN(a)&&Infinity!==a&&-Infinity!==a};$jscomp.number.isInteger=function(a){return $jscomp.number.isFinite(a)?a===Math.floor(a):!1}; +$jscomp.number.isNaN=function(a){return"number"===typeof a&&isNaN(a)};$jscomp.number.isSafeInteger=function(a){return $jscomp.number.isInteger(a)&&Math.abs(a)<=$jscomp.number.MAX_SAFE_INTEGER};$jscomp.number.EPSILON=function(){return Math.pow(2,-52)}();$jscomp.number.MAX_SAFE_INTEGER=function(){return 9007199254740991}();$jscomp.number.MIN_SAFE_INTEGER=function(){return-9007199254740991}();$jscomp.object=$jscomp.object||{}; +$jscomp.object.assign=function(a,b){for(var c=1;cd||1114111=d?b+=String.fromCharCode(d):(d-=65536,b+=String.fromCharCode(d>>>10&1023|55296),b+=String.fromCharCode(d&1023|56320))}return b}; +$jscomp.string.repeat=function(a){var b=$jscomp.checkStringArgs(this,null,"repeat");if(0>a||1342177279>>=1)b+=b;return c};$jscomp.string.repeat$install=function(){String.prototype.repeat||(String.prototype.repeat=$jscomp.string.repeat)}; +$jscomp.string.codePointAt=function(a){var b=$jscomp.checkStringArgs(this,null,"codePointAt"),c=b.length;a=Number(a)||0;if(0<=a&&ad||56319a||57343=e}; +$jscomp.string.startsWith$install=function(){String.prototype.startsWith||(String.prototype.startsWith=$jscomp.string.startsWith)};$jscomp.string.endsWith=function(a,b){var c=$jscomp.checkStringArgs(this,a,"endsWith");a+="";void 0===b&&(b=c.length);for(var d=Math.max(0,Math.min(b|0,c.length)),e=a.length;0=e};$jscomp.string.endsWith$install=function(){String.prototype.endsWith||(String.prototype.endsWith=$jscomp.string.endsWith)}; +var COMPILED=!0,goog=goog||{};goog.global=this;goog.isDef=function(a){return void 0!==a};goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&goog.isDef(b)?c[d]=b:c=c[d]?c[d]:c[d]={}}; +goog.define=function(a,b){var c=b;COMPILED||(goog.global.CLOSURE_UNCOMPILED_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_UNCOMPILED_DEFINES,a)?c=goog.global.CLOSURE_UNCOMPILED_DEFINES[a]:goog.global.CLOSURE_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,a)&&(c=goog.global.CLOSURE_DEFINES[a]));goog.exportPath_(a,c)};goog.DEBUG=!0;goog.LOCALE="en";goog.TRUSTED_SITE=!0;goog.STRICT_MODE_COMPATIBLE=!1;goog.DISALLOW_TEST_ONLY_CODE=COMPILED&&!goog.DEBUG; +goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING=!1;goog.provide=function(a){if(!COMPILED&&goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');goog.constructNamespace_(a)};goog.constructNamespace_=function(a,b){if(!COMPILED){delete goog.implicitNamespaces_[a];for(var c=a;(c=c.substring(0,c.lastIndexOf(".")))&&!goog.getObjectByName(c);)goog.implicitNamespaces_[c]=!0}goog.exportPath_(a,b)};goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/; +goog.module=function(a){if(!goog.isString(a)||!a||-1==a.search(goog.VALID_MODULE_RE_))throw Error("Invalid module identifier");if(!goog.isInModuleLoader_())throw Error("Module "+a+" has been loaded incorrectly.");if(goog.moduleLoaderState_.moduleName)throw Error("goog.module may only be called once per module.");goog.moduleLoaderState_.moduleName=a;if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a]}};goog.module.get=function(a){return goog.module.getInternal_(a)}; +goog.module.getInternal_=function(a){if(!COMPILED)return goog.isProvided_(a)?a in goog.loadedModules_?goog.loadedModules_[a]:goog.getObjectByName(a):null};goog.moduleLoaderState_=null;goog.isInModuleLoader_=function(){return null!=goog.moduleLoaderState_}; +goog.module.declareLegacyNamespace=function(){if(!COMPILED&&!goog.isInModuleLoader_())throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module");if(!COMPILED&&!goog.moduleLoaderState_.moduleName)throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace.");goog.moduleLoaderState_.declareLegacyNamespace=!0}; +goog.setTestOnly=function(a){if(goog.DISALLOW_TEST_ONLY_CODE)throw a=a||"",Error("Importing test-only code into non-debug environment"+(a?": "+a:"."));};goog.forwardDeclare=function(a){};COMPILED||(goog.isProvided_=function(a){return a in goog.loadedModules_||!goog.implicitNamespaces_[a]&&goog.isDefAndNotNull(goog.getObjectByName(a))},goog.implicitNamespaces_={"goog.module":!0}); +goog.getObjectByName=function(a,b){for(var c=a.split("."),d=b||goog.global,e;e=c.shift();)if(goog.isDefAndNotNull(d[e]))d=d[e];else return null;return d};goog.globalize=function(a,b){var c=b||goog.global,d;for(d in a)c[d]=a[d]};goog.addDependency=function(a,b,c,d){if(goog.DEPENDENCIES_ENABLED){var e;a=a.replace(/\\/g,"/");for(var f=goog.dependencies_,g=0;e=b[g];g++)f.nameToPath[e]=a,f.pathIsModule[a]=!!d;for(d=0;b=c[d];d++)a in f.requires||(f.requires[a]={}),f.requires[a][b]=!0}}; +goog.ENABLE_DEBUG_LOADER=!0;goog.logToConsole_=function(a){goog.global.console&&goog.global.console.error(a)};goog.require=function(a){if(!COMPILED){goog.ENABLE_DEBUG_LOADER&&goog.IS_OLD_IE_&&goog.maybeProcessDeferredDep_(a);if(goog.isProvided_(a))return goog.isInModuleLoader_()?goog.module.getInternal_(a):null;if(goog.ENABLE_DEBUG_LOADER){var b=goog.getPathFromDeps_(a);if(b)return goog.writeScripts_(b),null}a="goog.require could not find: "+a;goog.logToConsole_(a);throw Error(a);}}; +goog.basePath="";goog.nullFunction=function(){};goog.abstractMethod=function(){throw Error("unimplemented abstract method");};goog.addSingletonGetter=function(a){a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[];goog.LOAD_MODULE_USING_EVAL=!0;goog.SEAL_MODULE_EXPORTS=goog.DEBUG;goog.loadedModules_={};goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER; +goog.DEPENDENCIES_ENABLED&&(goog.dependencies_={pathIsModule:{},nameToPath:{},requires:{},visited:{},written:{},deferred:{}},goog.inHtmlDocument_=function(){var a=goog.global.document;return null!=a&&"write"in a},goog.findBasePath_=function(){if(goog.isDef(goog.global.CLOSURE_BASE_PATH))goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var a=goog.global.document.getElementsByTagName("SCRIPT"),b=a.length-1;0<=b;--b){var c=a[b].src,d=c.lastIndexOf("?"),d=-1==d?c.length: +d;if("base.js"==c.substr(d-7,7)){goog.basePath=c.substr(0,d-7);break}}},goog.importScript_=function(a,b){(goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_)(a,b)&&(goog.dependencies_.written[a]=!0)},goog.IS_OLD_IE_=!(goog.global.atob||!goog.global.document||!goog.global.document.all),goog.importModule_=function(a){goog.importScript_("",'goog.retrieveAndExecModule_("'+a+'");')&&(goog.dependencies_.written[a]=!0)},goog.queuedModules_=[],goog.wrapModule_=function(a,b){return goog.LOAD_MODULE_USING_EVAL&& +goog.isDef(goog.global.JSON)?"goog.loadModule("+goog.global.JSON.stringify(b+"\n//# sourceURL="+a+"\n")+");":'goog.loadModule(function(exports) {"use strict";'+b+"\n;return exports});\n//# sourceURL="+a+"\n"},goog.loadQueuedModules_=function(){var a=goog.queuedModules_.length;if(0\x3c/script>')},goog.appendScriptSrcNode_=function(a){var b=goog.global.document, +c=b.createElement("script");c.type="text/javascript";c.src=a;c.defer=!1;c.async=!1;b.head.appendChild(c)},goog.writeScriptTag_=function(a,b){if(goog.inHtmlDocument_()){var c=goog.global.document;if(!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING&&"complete"==c.readyState){if(/\bdeps.js$/.test(a))return!1;throw Error('Cannot write "'+a+'" after document load');}var d=goog.IS_OLD_IE_;void 0===b?d?(d=" onreadystatechange='goog.onScriptLoad_(this, "+ ++goog.lastNonModuleScriptIndex_+")' ",c.write(' - - - - - - - - -<#include "/console/header.html"> -<#include "/console/nav.html"> - -
- -
-
-
- - - - - - - - - - - - - - - - - - <#list sessionList as cimsession> - - - - - - - - - - - - - - -
<@spring.message 'module.console.cimsession.account'/> <@spring.message 'module.console.cimsession.nid'/><@spring.message 'module.console.cimsession.channel'/><@spring.message 'module.console.cimsession.deviceid'/><@spring.message 'module.console.cimsession.device.model'/><@spring.message 'module.console.cimsession.app.version'/><@spring.message 'module.console.cimsession.os.version'/><@spring.message 'module.console.cimsession.online.time'/><@spring.message 'module.common.location'/><@spring.message "module.common.operation"/>
${cimsession.account! }<#if cimsession.nid??>${cimsession.nid?c}${cimsession.channel! }${cimsession.deviceId! }${cimsession.deviceModel! }${cimsession.clientVersion! }${cimsession.systemVersion! } - <@spring.messageArgs "module.console.cimsession.time.format",[((.now?long - cimsession.bindTime)/1000)?round?c] /> - ${cimsession.location!} -
- -
-
-
-
-
- - - - - diff --git a/cim_for_mina/cim-boot-server/src/main/resources/page/console/webclient/loginDialog.html b/cim_for_mina/cim-boot-server/src/main/resources/page/console/webclient/loginDialog.html deleted file mode 100644 index 9e9ab9d..0000000 --- a/cim_for_mina/cim-boot-server/src/main/resources/page/console/webclient/loginDialog.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/cim_for_mina/cim-boot-server/src/main/resources/page/console/webclient/messageDialog.html b/cim_for_mina/cim-boot-server/src/main/resources/page/console/webclient/messageDialog.html deleted file mode 100644 index df86455..0000000 --- a/cim_for_mina/cim-boot-server/src/main/resources/page/console/webclient/messageDialog.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/cim_for_mina/cim-client-android/.idea/caches/build_file_checksums.ser b/cim_for_mina/cim-client-android/.idea/caches/build_file_checksums.ser deleted file mode 100644 index a4cefff..0000000 Binary files a/cim_for_mina/cim-client-android/.idea/caches/build_file_checksums.ser and /dev/null differ diff --git a/cim_for_mina/cim-client-android/.idea/caches/gradle_models.ser b/cim_for_mina/cim-client-android/.idea/caches/gradle_models.ser deleted file mode 100644 index f6ece0f..0000000 Binary files a/cim_for_mina/cim-client-android/.idea/caches/gradle_models.ser and /dev/null differ diff --git a/cim_for_mina/cim-client-android/.idea/codeStyles/Project.xml b/cim_for_mina/cim-client-android/.idea/codeStyles/Project.xml deleted file mode 100644 index 30aa626..0000000 --- a/cim_for_mina/cim-client-android/.idea/codeStyles/Project.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/cim_for_mina/cim-client-android/gradle/wrapper/gradle-wrapper.properties b/cim_for_mina/cim-client-android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 5f130fc..0000000 --- a/cim_for_mina/cim-client-android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,6 +0,0 @@ -#Wed Apr 17 14:12:04 CST 2019 -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/cim_for_mina/cim-client-android/gradlew b/cim_for_mina/cim-client-android/gradlew deleted file mode 100644 index cccdd3d..0000000 --- a/cim_for_mina/cim-client-android/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/cim_for_mina/cim-client-android/gradlew.bat b/cim_for_mina/cim-client-android/gradlew.bat deleted file mode 100644 index f955316..0000000 --- a/cim_for_mina/cim-client-android/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/cim_for_mina/cim-java-sdk/libs/log4j.jar b/cim_for_mina/cim-java-sdk/libs/log4j.jar deleted file mode 100644 index 69b0005..0000000 Binary files a/cim_for_mina/cim-java-sdk/libs/log4j.jar and /dev/null differ diff --git a/cim_for_mina/cim-java-sdk/libs/mina-core-2.0.16.jar b/cim_for_mina/cim-java-sdk/libs/mina-core-2.0.16.jar deleted file mode 100644 index 0e6d988..0000000 Binary files a/cim_for_mina/cim-java-sdk/libs/mina-core-2.0.16.jar and /dev/null differ diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMConnectorManager.java b/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMConnectorManager.java deleted file mode 100644 index b00cfe8..0000000 --- a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMConnectorManager.java +++ /dev/null @@ -1,336 +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.sdk.client; - -import java.net.InetSocketAddress; -import java.util.Map; -import java.util.Random; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Semaphore; - -import org.apache.log4j.Logger; -import org.apache.mina.core.future.ConnectFuture; -import org.apache.mina.core.future.IoFutureListener; -import org.apache.mina.core.future.WriteFuture; -import org.apache.mina.core.service.IoHandlerAdapter; -import org.apache.mina.core.session.IdleStatus; -import org.apache.mina.core.session.IoSession; -import org.apache.mina.filter.codec.ProtocolCodecFilter; -import org.apache.mina.filter.keepalive.KeepAliveFilter; -import org.apache.mina.filter.keepalive.KeepAliveMessageFactory; -import org.apache.mina.filter.keepalive.KeepAliveRequestTimeoutHandler; -import org.apache.mina.transport.socket.nio.NioSocketConnector; - -import com.farsunset.cim.sdk.client.constant.CIMConstant; -import com.farsunset.cim.sdk.client.exception.SessionDisconnectedException; -import com.farsunset.cim.sdk.client.filter.ClientMessageCodecFactory; -import com.farsunset.cim.sdk.client.model.HeartbeatRequest; -import com.farsunset.cim.sdk.client.model.HeartbeatResponse; -import com.farsunset.cim.sdk.client.model.Intent; -import com.farsunset.cim.sdk.client.model.Message; -import com.farsunset.cim.sdk.client.model.ReplyBody; -import com.farsunset.cim.sdk.client.model.SentBody; - -/** - * 连接服务端管理,cim核心处理类,管理连接,以及消息处理 - * - * @author 3979434@qq.com - */ -class CIMConnectorManager extends IoHandlerAdapter implements KeepAliveMessageFactory { - protected final Logger logger = Logger.getLogger(CIMConnectorManager.class); - - private final int READ_BUFFER_SIZE = 2048;// bit - private final int CONNECT_TIMEOUT = 10 * 1000;// 秒 - private final int WRITE_TIMEOUT = 10 * 1000;// 秒 - - private final int READ_IDLE_TIME = 120;// 秒 - private final int HEARBEAT_TIME_OUT = (READ_IDLE_TIME + 20) * 1000;// 收到服务端心跳请求超时时间 毫秒 - private final String KEY_LAST_HEART_TIME = "KEY_LAST_HEART_TIME"; - - private NioSocketConnector connector; - private ExecutorService executor = Executors.newFixedThreadPool(1); - private Semaphore semaphore = new Semaphore(1,true); - - private static CIMConnectorManager manager; - - private CIMConnectorManager() { - connector = new NioSocketConnector(); - connector.setConnectTimeoutMillis(CONNECT_TIMEOUT); - connector.getSessionConfig().setTcpNoDelay(true); - connector.getSessionConfig().setKeepAlive(true); - connector.getSessionConfig().setReadBufferSize(READ_BUFFER_SIZE); - - KeepAliveFilter keepAliveaHandler = new KeepAliveFilter(this); - keepAliveaHandler.setRequestInterval(READ_IDLE_TIME); - keepAliveaHandler.setRequestTimeoutHandler(KeepAliveRequestTimeoutHandler.NOOP); - keepAliveaHandler.setForwardEvent(true); - - connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(new ClientMessageCodecFactory())); - connector.getFilterChain().addLast("heartbeat", keepAliveaHandler); - - connector.setHandler(this); - - } - - public synchronized static CIMConnectorManager getManager() { - if (manager == null) { - manager = new CIMConnectorManager(); - } - return manager; - - } - - - - public void connect(final String host, final int port) { - - if (isConnected() || !semaphore.tryAcquire()) { - return; - } - - executor.execute(new Runnable() { - @Override - public void run() { - - logger.info("****************CIM正在连接服务器 " + host + ":" + port + "......"); - InetSocketAddress remoteAddress = new InetSocketAddress(host, port); - CIMCacheManager.getInstance().putBoolean(CIMCacheManager.KEY_CIM_CONNECTION_STATE, false); - connector.connect(remoteAddress).addListener(new IoFutureListener() { - @Override - public void operationComplete(ConnectFuture future) { - semaphore.release(); - future.removeListener(this); - if(future.getException() != null) { - handleConnectFailure(future.getException(),remoteAddress); - } - } - }); - } - }); - - } - - private void handleConnectFailure(Throwable error,InetSocketAddress remoteAddress) { - long interval = CIMConstant.RECONN_INTERVAL_TIME - (5 * 1000 - new Random().nextInt(15 * 1000)); - - Intent intent = new Intent(); - intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED); - intent.putExtra(Exception.class.getName(), error); - intent.putExtra("interval", interval); - sendBroadcast(intent); - - logger.error("****************CIM连接服务器失败 " + remoteAddress.getHostString() + ":" + remoteAddress.getPort() + "......将在" + interval / 1000 + "秒后重新尝试连接"); - - } - - public void send(SentBody body) { - - boolean isSuccessed = false; - - Throwable exception = new SessionDisconnectedException(); - - IoSession session = getCurrentSession(); - if (session != null && session.isConnected()) { - WriteFuture wf = session.write(body); - // 消息发送超时 5秒 - wf.awaitUninterruptibly(WRITE_TIMEOUT); - isSuccessed = wf.isWritten(); - exception = wf.getException(); - } - - if (!isSuccessed) { - Intent intent = new Intent(); - intent.setAction(CIMConstant.IntentAction.ACTION_SENT_FAILED); - intent.putExtra(Exception.class.getName(), exception); - intent.putExtra(SentBody.class.getName(), body); - sendBroadcast(intent); - } - - } - - public void destroy() { - IoSession session = getCurrentSession(); - if (session != null) { - session.closeNow(); - } - - if (connector != null && !connector.isDisposed()) { - connector.dispose(); - } - - manager = null; - } - - public boolean isConnected() { - IoSession session = getCurrentSession(); - return session != null; - } - - public void closeSession() { - IoSession session = getCurrentSession(); - if (session != null) { - session.closeNow(); - } - } - - public IoSession getCurrentSession() { - Map sessions = connector.getManagedSessions(); - for (Long key : sessions.keySet()) { - IoSession session = sessions.get(key); - if (session.isConnected()) { - return session; - } - } - return null; - } - - @Override - public void sessionCreated(IoSession session) throws Exception { - - logger.info("****************CIM连接服务器成功:" + session.getLocalAddress() + " NID:" + session.getId()); - - setLastHeartbeatTime(session); - - Intent intent = new Intent(); - intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_SUCCESSED); - sendBroadcast(intent); - - } - - @Override - public void sessionClosed(IoSession session) { - - logger.error("****************CIM与服务器断开连接:" + session.getLocalAddress() + " NID:" + session.getId()); - - Intent intent = new Intent(); - intent.setAction(CIMConstant.IntentAction.ACTION_CONNECTION_CLOSED); - sendBroadcast(intent); - - } - - @Override - public void sessionIdle(IoSession session, IdleStatus status) { - logger.debug("****************CIM " + status.toString().toUpperCase() + ":" + session.getLocalAddress() - + " NID:" + session.getId() + " isConnected:" + session.isConnected()); - - /** - * 用于解决,wifi情况下。偶而路由器与服务器断开连接时,客户端并没及时收到关闭事件 导致这样的情况下当前连接无效也不会重连的问题 - * - */ - long lastHeartbeatTime = getLastHeartbeatTime(session); - if (System.currentTimeMillis() - lastHeartbeatTime >= HEARBEAT_TIME_OUT) { - session.closeNow(); - logger.error("****************CIM心跳超时 ,即将重新连接......" + " NID:" + session.getId()); - } - } - - @Override - public void exceptionCaught(IoSession session, Throwable cause) { - - logger.error("****************CIM连接出现未知异常:" + session.getLocalAddress() + " NID:" + session.getId()); - - if (cause != null && cause.getMessage() != null) { - logger.error(cause.getMessage()); - } - - Intent intent = new Intent(); - intent.setAction(CIMConstant.IntentAction.ACTION_UNCAUGHT_EXCEPTION); - intent.putExtra(Exception.class.getName(), cause); - sendBroadcast(intent); - } - - @Override - public void messageReceived(IoSession session, Object obj) { - - if (obj instanceof Message) { - - Intent intent = new Intent(); - intent.setAction(CIMConstant.IntentAction.ACTION_MESSAGE_RECEIVED); - intent.putExtra(Message.class.getName(), (Message) obj); - sendBroadcast(intent); - - } - if (obj instanceof ReplyBody) { - - Intent intent = new Intent(); - intent.setAction(CIMConstant.IntentAction.ACTION_REPLY_RECEIVED); - intent.putExtra(ReplyBody.class.getName(), (ReplyBody) obj); - sendBroadcast(intent); - } - } - - @Override - public void messageSent(IoSession session, Object message) { - if (message instanceof SentBody) { - Intent intent = new Intent(); - intent.setAction(CIMConstant.IntentAction.ACTION_SENT_SUCCESSED); - intent.putExtra(SentBody.class.getName(), (SentBody) message); - sendBroadcast(intent); - } - } - - private void setLastHeartbeatTime(IoSession session) { - session.setAttribute(KEY_LAST_HEART_TIME, System.currentTimeMillis()); - } - - private long getLastHeartbeatTime(IoSession session) { - long time = 0; - Object value = session.getAttribute(KEY_LAST_HEART_TIME); - if (value != null) { - time = Long.parseLong(value.toString()); - } - return time; - } - - @Override - public Object getRequest(IoSession arg0) { - return null; - } - - @Override - public Object getResponse(IoSession session, Object arg1) { - return HeartbeatResponse.getInstance(); - } - - @Override - public boolean isRequest(IoSession session, Object data) { - - setLastHeartbeatTime(session); - - return data instanceof HeartbeatRequest; - } - - @Override - public boolean isResponse(IoSession arg0, Object arg1) { - return false; - } - - private void sendBroadcast(final Intent intent) { - executor.execute(new Runnable() { - @Override - public void run() { - CIMEventBroadcastReceiver.getInstance().onReceive(intent); - } - }); - } -} diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMListenerManager.java b/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMListenerManager.java deleted file mode 100644 index 2900db8..0000000 --- a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/CIMListenerManager.java +++ /dev/null @@ -1,113 +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.sdk.client; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; - -import org.apache.log4j.Logger; - -import com.farsunset.cim.sdk.client.model.Message; -import com.farsunset.cim.sdk.client.model.ReplyBody; - -/** - * CIM 消息监听器管理 - */ -public class CIMListenerManager { - - private static ArrayList cimListeners = new ArrayList(); - private static CIMMessageReceiveComparator comparator = new CIMMessageReceiveComparator(); - protected static final Logger logger = Logger.getLogger(CIMListenerManager.class); - - public static void registerMessageListener(CIMEventListener listener) { - - if (!cimListeners.contains(listener)) { - cimListeners.add(listener); - Collections.sort(cimListeners, comparator); - } - } - - public static void removeMessageListener(CIMEventListener listener) { - for (int i = 0; i < cimListeners.size(); i++) { - if (listener.getClass() == cimListeners.get(i).getClass()) { - cimListeners.remove(i); - } - } - } - - public static void notifyOnConnectionSuccessed(boolean antoBind) { - for (CIMEventListener listener : cimListeners) { - listener.onConnectionSuccessed(antoBind); - } - } - - public static void notifyOnMessageReceived(Message message) { - for (CIMEventListener listener : cimListeners) { - listener.onMessageReceived(message); - } - } - - public static void notifyOnConnectionClosed() { - for (CIMEventListener listener : cimListeners) { - listener.onConnectionClosed(); - } - } - - public static void notifyOnReplyReceived(ReplyBody body) { - for (CIMEventListener listener : cimListeners) { - listener.onReplyReceived(body); - } - } - - public static void notifyOnConnectionFailed(Exception e) { - for (CIMEventListener listener : cimListeners) { - listener.onConnectionFailed(e); - } - } - - public static void destory() { - cimListeners.clear(); - } - - public static void logListenersName() { - for (CIMEventListener listener : cimListeners) { - logger.debug("#######" + listener.getClass().getName() + "#######"); - } - } - - /** - * 消息接收activity的接收顺序排序,CIM_RECEIVE_ORDER倒序 - */ - private static class CIMMessageReceiveComparator implements Comparator { - - @Override - public int compare(CIMEventListener arg1, CIMEventListener arg2) { - - int order1 = arg1.getEventDispatchOrder(); - int order2 = arg2.getEventDispatchOrder(); - return order2 - order1; - } - - } - -} diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/exception/NetworkDisconnectedException.java b/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/exception/NetworkDisconnectedException.java deleted file mode 100644 index 9403854..0000000 --- a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/exception/NetworkDisconnectedException.java +++ /dev/null @@ -1,35 +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.sdk.client.exception; - -public class NetworkDisconnectedException extends Exception { - - private static final long serialVersionUID = 1L; - - public NetworkDisconnectedException() { - super(); - } - - public NetworkDisconnectedException(String s) { - super(s); - } -} diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/exception/SessionDisconnectedException.java b/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/exception/SessionDisconnectedException.java deleted file mode 100644 index 8a0bfbb..0000000 --- a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/exception/SessionDisconnectedException.java +++ /dev/null @@ -1,35 +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.sdk.client.exception; - -public class SessionDisconnectedException extends Exception { - - private static final long serialVersionUID = 1L; - - public SessionDisconnectedException() { - super(); - } - - public SessionDisconnectedException(String s) { - super(s); - } -} diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageCodecFactory.java b/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageCodecFactory.java deleted file mode 100644 index e5ef9b7..0000000 --- a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageCodecFactory.java +++ /dev/null @@ -1,56 +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.sdk.client.filter; - -import org.apache.mina.core.session.IoSession; -import org.apache.mina.filter.codec.ProtocolCodecFactory; -import org.apache.mina.filter.codec.ProtocolDecoder; -import org.apache.mina.filter.codec.ProtocolEncoder; - -/** - * android客户端端消息 编码解码器 - */ -public class ClientMessageCodecFactory implements ProtocolCodecFactory { - - /** - * 消息编码器 - */ - private final ClientMessageEncoder encoder; - /** - * 消息解码器 - */ - private final ClientMessageDecoder decoder; - - public ClientMessageCodecFactory() { - encoder = new ClientMessageEncoder(); - decoder = new ClientMessageDecoder(); - } - - public ProtocolEncoder getEncoder(IoSession session) throws Exception { - return encoder; - } - - public ProtocolDecoder getDecoder(IoSession session) throws Exception { - return decoder; - } - -} diff --git a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageEncoder.java b/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageEncoder.java deleted file mode 100644 index 8f3625f..0000000 --- a/cim_for_mina/cim-java-sdk/src/com/farsunset/cim/sdk/client/filter/ClientMessageEncoder.java +++ /dev/null @@ -1,76 +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.sdk.client.filter; - -import org.apache.log4j.Logger; -import org.apache.mina.core.buffer.IoBuffer; -import org.apache.mina.core.session.IoSession; -import org.apache.mina.filter.codec.ProtocolEncoderAdapter; -import org.apache.mina.filter.codec.ProtocolEncoderOutput; - -import com.farsunset.cim.sdk.client.constant.CIMConstant; -import com.farsunset.cim.sdk.client.model.Protobufable; - -/** - * 客户端消息发送前进行编码 - */ -public class ClientMessageEncoder extends ProtocolEncoderAdapter { - - protected final Logger logger = Logger.getLogger(ClientMessageEncoder.class); - - @Override - public void encode(IoSession iosession, Object object, ProtocolEncoderOutput out) throws Exception { - - if (object instanceof Protobufable) { - - Protobufable data = (Protobufable) object; - byte[] byteArray = data.getByteArray(); - - IoBuffer buff = IoBuffer.allocate(byteArray.length + CIMConstant.DATA_HEADER_LENGTH).setAutoExpand(true); - - buff.put(createHeader(data.getType(), byteArray.length)); - buff.put(byteArray); - - buff.flip(); - out.write(buff); - // 打印出收到的消息 - logger.info(data.toString()); - } - - } - - /** - * 消息体最大为65535 - * - * @param type - * @param length - * @return - */ - private byte[] createHeader(byte type, int length) { - byte[] header = new byte[CIMConstant.DATA_HEADER_LENGTH]; - header[0] = type; - header[1] = (byte) (length & 0xff); - header[2] = (byte) ((length >> 8) & 0xff); - return header; - } - -} diff --git a/cim_for_mina/cim-server-sdk/libs/mina-core-2.0.16.jar b/cim_for_mina/cim-server-sdk/libs/mina-core-2.0.16.jar deleted file mode 100644 index 0e6d988..0000000 Binary files a/cim_for_mina/cim-server-sdk/libs/mina-core-2.0.16.jar and /dev/null differ diff --git a/cim_for_netty/cim-android-sdk/.classpath b/cim_for_netty/cim-android-sdk/.classpath deleted file mode 100644 index 54714c2..0000000 --- a/cim_for_netty/cim-android-sdk/.classpath +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/cim_for_netty/cim-android-sdk/.project b/cim_for_netty/cim-android-sdk/.project deleted file mode 100644 index dab9061..0000000 --- a/cim_for_netty/cim-android-sdk/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - cim-android-sdk - - - - - - org.eclipse.jdt.core.javabuilder - - - - - com.genuitec.eclipse.ast.deploy.core.DeploymentBuilder - - - - - - com.genuitec.eclipse.ast.deploy.core.deploymentnature - org.eclipse.jdt.core.javanature - - diff --git a/cim_for_netty/cim-android-sdk/libs/log4j-1.2.17.jar b/cim_for_netty/cim-android-sdk/libs/log4j-1.2.17.jar deleted file mode 100644 index 068867e..0000000 Binary files a/cim_for_netty/cim-android-sdk/libs/log4j-1.2.17.jar and /dev/null differ diff --git a/cim_for_netty/cim-android-sdk/libs/netty-buffer-4.1.9.Final.jar b/cim_for_netty/cim-android-sdk/libs/netty-buffer-4.1.9.Final.jar deleted file mode 100644 index 31d9a48..0000000 Binary files a/cim_for_netty/cim-android-sdk/libs/netty-buffer-4.1.9.Final.jar and /dev/null differ diff --git a/cim_for_netty/cim-android-sdk/libs/netty-codec-4.1.9.Final.jar b/cim_for_netty/cim-android-sdk/libs/netty-codec-4.1.9.Final.jar deleted file mode 100644 index 7c1717c..0000000 Binary files a/cim_for_netty/cim-android-sdk/libs/netty-codec-4.1.9.Final.jar and /dev/null differ diff --git a/cim_for_netty/cim-android-sdk/libs/netty-common-4.1.9.Final.jar b/cim_for_netty/cim-android-sdk/libs/netty-common-4.1.9.Final.jar deleted file mode 100644 index e38f723..0000000 Binary files a/cim_for_netty/cim-android-sdk/libs/netty-common-4.1.9.Final.jar and /dev/null differ diff --git a/cim_for_netty/cim-android-sdk/libs/netty-handler-4.1.9.Final.jar b/cim_for_netty/cim-android-sdk/libs/netty-handler-4.1.9.Final.jar deleted file mode 100644 index 1498d27..0000000 Binary files a/cim_for_netty/cim-android-sdk/libs/netty-handler-4.1.9.Final.jar and /dev/null differ diff --git a/cim_for_netty/cim-android-sdk/libs/netty-transport-4.1.9.Final.jar b/cim_for_netty/cim-android-sdk/libs/netty-transport-4.1.9.Final.jar deleted file mode 100644 index 0cc8904..0000000 Binary files a/cim_for_netty/cim-android-sdk/libs/netty-transport-4.1.9.Final.jar and /dev/null differ diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java deleted file mode 100644 index d1393b8..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheManager.java +++ /dev/null @@ -1,104 +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.sdk.android; - -import android.content.ContentResolver; -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.net.Uri; - -class CIMCacheManager { - - public static final String CIM_CONFIG_INFO = "CIM_CONFIG_INFO"; - - public static final String KEY_ACCOUNT = "KEY_ACCOUNT"; - - public static final String KEY_DEVICE_ID = "KEY_DEVICE_ID"; - - public static final String KEY_MANUAL_STOP = "KEY_MANUAL_STOP"; - - public static final String KEY_CIM_DESTROYED = "KEY_CIM_DESTROYED"; - - public static final String KEY_CIM_SERVIER_HOST = "KEY_CIM_SERVIER_HOST"; - - public static final String KEY_CIM_SERVIER_PORT = "KEY_CIM_SERVIER_PORT"; - - public static final String KEY_CIM_CONNECTION_STATE = "KEY_CIM_CONNECTION_STATE"; - - public static final String CONTENT_URI = "content://%s.cim.provider"; - - - public static void remove(Context context, String key) { - ContentResolver resolver = context.getContentResolver(); - resolver.delete(Uri.parse(String.format(CONTENT_URI,context.getPackageName())), key, null); - } - - public static void putString(Context context, String key, String value) { - - ContentResolver resolver = context.getContentResolver(); - ContentValues values = new ContentValues(); - values.put("value", value); - values.put("key", key); - resolver.insert(Uri.parse(String.format(CONTENT_URI,context.getPackageName())), values); - - } - - public static String getString(Context context, String key) { - String value = null; - ContentResolver resolver = context.getContentResolver(); - Cursor cursor = resolver.query(Uri.parse(String.format(CONTENT_URI,context.getPackageName())), new String[] { key }, null, null, null); - if (cursor != null && cursor.moveToFirst()) { - value = cursor.getString(0); - cursor.close(); - } - closeQuietly(cursor); - return value; - } - - private static void closeQuietly(Cursor cursor) { - try { - if (cursor != null) - cursor.close(); - } catch (Exception e) { - } - } - - public static void putBoolean(Context context, String key, boolean value) { - putString(context, key, Boolean.toString(value)); - } - - public static boolean getBoolean(Context context, String key) { - String value = getString(context, key); - return value == null ? false : Boolean.parseBoolean(value); - } - - public static void putInt(Context context, String key, int value) { - putString(context, key, String.valueOf(value)); - } - - public static int getInt(Context context, String key) { - String value = getString(context, key); - return value == null ? 0 : Integer.parseInt(value); - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java deleted file mode 100644 index 400ff00..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMCacheProvider.java +++ /dev/null @@ -1,71 +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.sdk.android; - -import android.content.ContentProvider; -import android.content.ContentValues; -import android.content.Context; -import android.database.Cursor; -import android.database.MatrixCursor; -import android.net.Uri; - -public class CIMCacheProvider extends ContentProvider { - static final String MODEL_KEY = "PRIVATE_CIM_CONFIG"; - - @Override - public int delete(Uri arg0, String key, String[] arg2) { - getContext().getSharedPreferences(MODEL_KEY, Context.MODE_PRIVATE).edit().remove(key).apply(); - return 0; - } - - @Override - public String getType(Uri arg0) { - return null; - } - - @Override - public Uri insert(Uri arg0, ContentValues values) { - String key = values.getAsString("key"); - String value = values.getAsString("value"); - getContext().getSharedPreferences(MODEL_KEY, Context.MODE_PRIVATE).edit().putString(key, value).apply(); - return null; - } - - @Override - public boolean onCreate() { - return true; - } - - @Override - public Cursor query(Uri arg0, String[] arg1, String key, String[] arg3, String arg4) { - MatrixCursor cursor = new MatrixCursor(new String[] { "value" }); - String value = getContext().getSharedPreferences(MODEL_KEY, Context.MODE_PRIVATE).getString(arg1[0], null); - cursor.addRow(new Object[] { value }); - return cursor; - } - - @Override - public int update(Uri arg0, ContentValues arg1, String arg2, String[] arg3) { - return 0; - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java deleted file mode 100644 index 5171c34..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMConnectorManager.java +++ /dev/null @@ -1,316 +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.sdk.android; - -import java.net.InetSocketAddress; -import java.util.Random; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.atomic.AtomicBoolean; - -import android.content.Context; -import android.content.Intent; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; -import io.netty.bootstrap.Bootstrap; -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelInboundHandlerAdapter; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.ChannelOption; -import io.netty.channel.EventLoopGroup; -import io.netty.channel.nio.NioEventLoopGroup; -import io.netty.channel.socket.SocketChannel; -import io.netty.channel.socket.nio.NioSocketChannel; -import io.netty.handler.timeout.IdleState; -import io.netty.handler.timeout.IdleStateEvent; -import io.netty.handler.timeout.IdleStateHandler; -import io.netty.util.AttributeKey; -import io.netty.util.concurrent.GenericFutureListener; -import io.netty.channel.ChannelHandler.Sharable; - -import com.farsunset.cim.sdk.android.constant.CIMConstant; -import com.farsunset.cim.sdk.android.filter.CIMLoggingHandler; -import com.farsunset.cim.sdk.android.filter.ClientMessageDecoder; -import com.farsunset.cim.sdk.android.filter.ClientMessageEncoder; -import com.farsunset.cim.sdk.android.exception.NetworkDisabledException; -import com.farsunset.cim.sdk.android.exception.SessionClosedException; -import com.farsunset.cim.sdk.android.model.HeartbeatRequest; -import com.farsunset.cim.sdk.android.model.HeartbeatResponse; -import com.farsunset.cim.sdk.android.model.Message; -import com.farsunset.cim.sdk.android.model.ReplyBody; -import com.farsunset.cim.sdk.android.model.SentBody; - -@Sharable -class CIMConnectorManager extends ChannelInboundHandlerAdapter{ - - private final int CONNECT_TIMEOUT = 10 * 1000;// 秒 - private final int WRITE_TIMEOUT = 10 * 1000;// 秒 - - private final int READ_IDLE_TIME = 120;// 秒 - private final int HEARBEAT_TIME_OUT = (READ_IDLE_TIME + 20) * 1000;// 收到服务端心跳请求超时时间 毫秒 - private final String KEY_LAST_HEART_TIME = "KEY_LAST_HEART_TIME"; - - private Bootstrap bootstrap; - private EventLoopGroup loopGroup; - private Channel channel;; - private ExecutorService executor = Executors.newFixedThreadPool(1); - private final AtomicBoolean CONNECTING_FLAG = new AtomicBoolean(false) ; - - private Context context; - - private static CIMConnectorManager manager; - - private CIMConnectorManager(Context ctx) { - context = ctx; - makeNioBootstrap(); - - } - - private void makeNioBootstrap() { - bootstrap = new Bootstrap(); - loopGroup = new NioEventLoopGroup(1); - bootstrap.group(loopGroup); - bootstrap.channel(NioSocketChannel.class); - bootstrap.option(ChannelOption.TCP_NODELAY, true); - bootstrap.option(ChannelOption.SO_KEEPALIVE, true); - bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, CONNECT_TIMEOUT); - bootstrap.handler(new ChannelInitializer() { - @Override - public void initChannel(SocketChannel ch) throws Exception { - ch.pipeline().addLast(new ClientMessageDecoder()); - ch.pipeline().addLast(new ClientMessageEncoder()); - ch.pipeline().addLast(new IdleStateHandler(READ_IDLE_TIME, 0, 0)); - ch.pipeline().addLast(CIMLoggingHandler.getLogger()); - ch.pipeline().addLast(CIMConnectorManager.this); - } - }); - } - - public synchronized static CIMConnectorManager getManager(Context context) { - if (manager == null) { - manager = new CIMConnectorManager(context); - } - return manager; - - } - - private void handleConnectFailure(Throwable error,InetSocketAddress remoteAddress) { - - long interval = CIMConstant.RECONN_INTERVAL_TIME - (5 * 1000 - new Random().nextInt(15 * 1000)); - - CIMLoggingHandler.getLogger().connectFailure(remoteAddress, interval); - - Intent intent = new Intent(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED); - intent.setPackage(context.getPackageName()); - intent.putExtra(Exception.class.getName(), error.getClass().getSimpleName()); - intent.putExtra("interval", interval); - context.sendBroadcast(intent); - - - - } - - - public void connect(final String host, final int port) { - - if (!isNetworkConnected(context)) { - - Intent intent = new Intent(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED); - intent.setPackage(context.getPackageName()); - intent.putExtra(Exception.class.getName(), NetworkDisabledException.class.getSimpleName()); - context.sendBroadcast(intent); - - return; - } - - if (CONNECTING_FLAG.get() || isConnected()) { - return; - } - - CONNECTING_FLAG.set(true); - - if (bootstrap == null || loopGroup.isShutdown()) { - makeNioBootstrap(); - } - - executor.execute(new Runnable() { - @Override - public void run() { - - final InetSocketAddress remoteAddress = new InetSocketAddress(host, port); - bootstrap.connect(remoteAddress).addListener(new GenericFutureListener() { - - @Override - public void operationComplete(ChannelFuture future) { - CONNECTING_FLAG.set(false); - future.removeListener(this); - if(!future.isSuccess() && future.cause() != null) { - handleConnectFailure(future.cause(),remoteAddress); - } - - if(future.isSuccess()) { - channel = future.channel(); - } - - } - }); - } - }); - - } - - public void send(SentBody body) { - - boolean isSuccessed = false; - - String exceptionName = SessionClosedException.class.getSimpleName(); - - if (isConnected()) { - ChannelFuture future = channel.writeAndFlush(body); - isSuccessed = future.awaitUninterruptibly(WRITE_TIMEOUT); - if (!isSuccessed && future.cause() != null) { - exceptionName = future.cause().getClass().getSimpleName(); - } - - } - - if (!isSuccessed) { - Intent intent = new Intent(CIMConstant.IntentAction.ACTION_SENT_FAILED); - intent.setPackage(context.getPackageName()); - intent.putExtra(Exception.class.getName(), exceptionName); - intent.putExtra(SentBody.class.getName(), body); - context.sendBroadcast(intent); - } else { - Intent intent = new Intent(CIMConstant.IntentAction.ACTION_SENT_SUCCESSED); - intent.setPackage(context.getPackageName()); - intent.putExtra(SentBody.class.getName(), (SentBody) body); - context.sendBroadcast(intent); - } - - } - - public void destroy() { - if (channel != null) { - channel.close(); - } - - if (loopGroup != null) { - loopGroup.shutdownGracefully(); - } - - } - - public boolean isConnected() { - return channel != null && channel.isActive(); - } - - public void closeSession() { - if (channel != null) { - channel.close(); - } - } - - @Override - public void channelActive(ChannelHandlerContext ctx) throws Exception { - - - setLastHeartbeatTime(ctx.channel()); - - Intent intent = new Intent(CIMConstant.IntentAction.ACTION_CONNECTION_SUCCESSED); - intent.setPackage(context.getPackageName()); - context.sendBroadcast(intent); - - } - - @Override - public void channelInactive(ChannelHandlerContext ctx) { - - Intent intent = new Intent(CIMConstant.IntentAction.ACTION_CONNECTION_CLOSED); - intent.setPackage(context.getPackageName()); - context.sendBroadcast(intent); - - } - - @Override - public void userEventTriggered(ChannelHandlerContext ctx, Object evt) { - - /** - * 用于解决,wifi情况下。偶而路由器与服务器断开连接时,客户端并没及时收到关闭事件 导致这样的情况下当前连接无效也不会重连的问题 - * - */ - if (evt instanceof IdleStateEvent && ((IdleStateEvent) evt).state().equals(IdleState.READER_IDLE)) { - Long lastTime = getLastHeartbeatTime(ctx.channel()); - if (lastTime != null && System.currentTimeMillis() - lastTime > HEARBEAT_TIME_OUT) { - channel.close(); - } - } - - } - - @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { - if (msg instanceof Message) { - - Intent intent = new Intent(CIMConstant.IntentAction.ACTION_MESSAGE_RECEIVED); - intent.setPackage(context.getPackageName()); - intent.putExtra(Message.class.getName(), (Message) msg); - context.sendBroadcast(intent); - - } - if (msg instanceof ReplyBody) { - - Intent intent = new Intent(CIMConstant.IntentAction.ACTION_REPLY_RECEIVED); - intent.setPackage(context.getPackageName()); - intent.putExtra(ReplyBody.class.getName(), (ReplyBody) msg); - context.sendBroadcast(intent); - } - - // 收到服务端发来的心跳请求命令,则马上回应服务器 - if (msg instanceof HeartbeatRequest) { - ctx.writeAndFlush(HeartbeatResponse.getInstance()); - setLastHeartbeatTime(ctx.channel()); - } - - } - - private void setLastHeartbeatTime(Channel channel) { - channel.attr(AttributeKey.valueOf(KEY_LAST_HEART_TIME)).set(System.currentTimeMillis()); - } - - private Long getLastHeartbeatTime(Channel channel) { - return (Long) channel.attr(AttributeKey.valueOf(KEY_LAST_HEART_TIME)).get(); - } - - public static boolean isNetworkConnected(Context context) { - try { - ConnectivityManager nw = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); - NetworkInfo networkInfo = nw.getActiveNetworkInfo(); - return networkInfo != null; - } catch (Exception e) { - } - - return false; - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java deleted file mode 100644 index ebd3cde..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventBroadcastReceiver.java +++ /dev/null @@ -1,217 +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.sdk.android; - -import com.farsunset.cim.sdk.android.constant.CIMConstant; -import com.farsunset.cim.sdk.android.exception.SessionClosedException; -import com.farsunset.cim.sdk.android.model.Message; -import com.farsunset.cim.sdk.android.model.ReplyBody; -import com.farsunset.cim.sdk.android.model.SentBody; - -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.net.ConnectivityManager; -import android.net.NetworkInfo; - -/** - * 消息入口,所有消息都会经过这里 - */ -public abstract class CIMEventBroadcastReceiver extends BroadcastReceiver { - - protected Context context; - - @Override - public void onReceive(Context ctx, Intent intent) { - - context = ctx; - - /* - * 操作事件广播,用于提高service存活率 - */ - if (intent.getAction().equals(Intent.ACTION_USER_PRESENT) - || intent.getAction().equals(Intent.ACTION_POWER_CONNECTED) - || intent.getAction().equals(Intent.ACTION_POWER_DISCONNECTED)) { - startPushService(); - } - - /* - * 设备网络状态变化事件 - */ - if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_NETWORK_CHANGED) - ||intent.getAction().equals(ConnectivityManager.CONNECTIVITY_ACTION)) { - ConnectivityManager connectivityManager = (ConnectivityManager) context - .getSystemService(Context.CONNECTIVITY_SERVICE); - onDevicesNetworkChanged(connectivityManager.getActiveNetworkInfo()); - } - - /* - * cim断开服务器事件 - */ - if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_CONNECTION_CLOSED)) { - onInnerConnectionClosed(); - } - - /* - * cim连接服务器失败事件 - */ - if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_CONNECTION_FAILED)) { - long interval = intent.getLongExtra("interval", CIMConstant.RECONN_INTERVAL_TIME); - String exceptionName = intent.getStringExtra(Exception.class.getName()); - onConnectionFailed(exceptionName, interval); - } - - /* - * cim连接服务器成功事件 - */ - if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_CONNECTION_SUCCESSED)) { - onInnerConnectionSuccessed(); - } - - /* - * 收到推送消息事件 - */ - if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_MESSAGE_RECEIVED)) { - onInnerMessageReceived((Message) intent.getSerializableExtra(Message.class.getName()), intent); - } - - /* - * 获取收到replybody成功事件 - */ - if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_REPLY_RECEIVED)) { - onReplyReceived((ReplyBody) intent.getSerializableExtra(ReplyBody.class.getName())); - } - - /* - * 获取sendbody发送失败事件 - */ - if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_SENT_FAILED)) { - String exceptionName = intent.getStringExtra(Exception.class.getName()); - SentBody sentBody = (SentBody) intent.getSerializableExtra(SentBody.class.getName()); - onSentFailed(exceptionName, sentBody); - } - - /* - * 获取sendbody发送成功事件 - */ - if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_SENT_SUCCESSED)) { - onSentSucceed((SentBody) intent.getSerializableExtra(SentBody.class.getName())); - } - - /* - * 重新连接,如果断开的话 - */ - if (intent.getAction().equals(CIMConstant.IntentAction.ACTION_CONNECTION_RECOVERY)) { - CIMPushManager.connect(context, 0); - } - } - - private void startPushService() { - Intent intent = new Intent(context, CIMPushService.class); - intent.setAction(CIMPushManager.ACTION_ACTIVATE_PUSH_SERVICE); - context.startService(intent); - } - - private void onInnerConnectionClosed() { - CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_CIM_CONNECTION_STATE, false); - if (CIMConnectorManager.isNetworkConnected(context)) { - CIMPushManager.connect(context, 0); - } - - onConnectionClosed(); - } - - private void onConnectionFailed(String exceptionName, long reinterval) { - - if (CIMConnectorManager.isNetworkConnected(context)) { - onConnectionFailed(); - - CIMPushManager.connect(context, reinterval); - } - } - - private void onInnerConnectionSuccessed() { - CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_CIM_CONNECTION_STATE, true); - - boolean autoBind = CIMPushManager.autoBindAccount(context); - onConnectionSuccessed(autoBind); - } - - private void onDevicesNetworkChanged(NetworkInfo info) { - - if (info != null) { - CIMPushManager.connect(context, 0); - } - - onNetworkChanged(info); - } - - private void onInnerMessageReceived(com.farsunset.cim.sdk.android.model.Message message, Intent intent) { - if (isForceOfflineMessage(message.getAction())) { - CIMPushManager.stop(context); - } - - onMessageReceived(message, intent); - } - - private boolean isForceOfflineMessage(String action) { - return CIMConstant.MessageAction.ACTION_999.equals(action); - } - - private void onSentFailed(String exceptionName, SentBody body) { - - // 与服务端端开链接,重新连接 - if (SessionClosedException.class.getSimpleName().equals(exceptionName)) { - CIMPushManager.connect(context, 0); - } else { - // 发送失败 重新发送 - CIMPushManager.sendRequest(context, body); - } - - } - - public abstract void onMessageReceived(com.farsunset.cim.sdk.android.model.Message message, Intent intent); - - public void onNetworkChanged(NetworkInfo info) { - CIMListenerManager.notifyOnNetworkChanged(info); - } - - public void onConnectionSuccessed(boolean hasAutoBind) { - CIMListenerManager.notifyOnConnectionSuccessed(hasAutoBind); - } - - public void onConnectionClosed() { - CIMListenerManager.notifyOnConnectionClosed(); - } - - public void onConnectionFailed() { - CIMListenerManager.notifyOnConnectionFailed(); - } - - public void onReplyReceived(ReplyBody body) { - CIMListenerManager.notifyOnReplyReceived(body); - } - - public void onSentSucceed(SentBody body) { - CIMListenerManager.notifyOnSentSucceed(body); - } -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java deleted file mode 100644 index b904f54..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMEventListener.java +++ /dev/null @@ -1,87 +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.sdk.android; - -import android.net.NetworkInfo; - -import com.farsunset.cim.sdk.android.model.Message; -import com.farsunset.cim.sdk.android.model.ReplyBody; -import com.farsunset.cim.sdk.android.model.SentBody; - -/** - * CIM 主要事件接口 - */ -public interface CIMEventListener { - - /** - * 当收到服务端推送过来的消息时调用 - * - * @param message - */ - void onMessageReceived(Message message); - - /** - * 当调用CIMPushManager.sendRequest()向服务端发送请求,获得相应时调用 - * - * @param replybody - */ - void onReplyReceived(ReplyBody replybody); - - /** - * 当调用CIMPushManager.sendRequest()向服务端发送请求成功时 - * - * @param body - */ - void onSentSuccessed(SentBody body); - - /** - * 当手机网络发生变化时调用 - * - * @param networkinfo - */ - void onNetworkChanged(NetworkInfo networkinfo); - - /** - * 当连接服务器成功时回调 - * - * @param hasAutoBind - * : true 已经自动绑定账号到服务器了,不需要再手动调用bindAccount - */ - void onConnectionSuccessed(boolean hasAutoBind); - - /** - * 当断开服务器连接的时候回调 - * - */ - void onConnectionClosed(); - - /** - * 当连接服务器失败的时候回调 - * - */ - void onConnectionFailed(); - - /** - * 监听器在容器里面的排序。值越大则越先接收 - */ - int getEventDispatchOrder(); -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java deleted file mode 100644 index b5b18b0..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMListenerManager.java +++ /dev/null @@ -1,126 +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.sdk.android; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; - -import com.farsunset.cim.sdk.android.model.Message; -import com.farsunset.cim.sdk.android.model.ReplyBody; -import com.farsunset.cim.sdk.android.model.SentBody; - -import android.net.NetworkInfo; -import android.util.Log; - -/** - * CIM 消息监听器管理 - */ -public class CIMListenerManager { - - private static ArrayList cimListeners = new ArrayList(); - private static CIMMessageReceiveComparator comparator = new CIMMessageReceiveComparator(); - - public static void registerMessageListener(CIMEventListener listener) { - - if (!cimListeners.contains(listener)) { - cimListeners.add(listener); - Collections.sort(cimListeners, comparator); - } - } - - public static void removeMessageListener(CIMEventListener listener) { - for (int i = 0; i < cimListeners.size(); i++) { - if (listener.getClass() == cimListeners.get(i).getClass()) { - cimListeners.remove(i); - } - } - } - - public static void notifyOnNetworkChanged(NetworkInfo info) { - for (CIMEventListener listener : cimListeners) { - listener.onNetworkChanged(info); - } - } - - public static void notifyOnConnectionSuccessed(boolean hasAutoBind) { - for (CIMEventListener listener : cimListeners) { - listener.onConnectionSuccessed(hasAutoBind); - } - } - - public static void notifyOnMessageReceived(Message message) { - for (CIMEventListener listener : cimListeners) { - listener.onMessageReceived(message); - } - } - - public static void notifyOnConnectionClosed() { - for (CIMEventListener listener : cimListeners) { - listener.onConnectionClosed(); - } - } - - public static void notifyOnConnectionFailed() { - for (CIMEventListener listener : cimListeners) { - listener.onConnectionFailed(); - } - } - - public static void notifyOnReplyReceived(ReplyBody body) { - for (CIMEventListener listener : cimListeners) { - listener.onReplyReceived(body); - } - } - - public static void notifyOnSentSucceed(SentBody body) { - for (CIMEventListener listener : cimListeners) { - listener.onSentSuccessed(body); - } - } - - public static void destory() { - cimListeners.clear(); - } - - public static void logListenersName() { - for (CIMEventListener listener : cimListeners) { - Log.i(CIMEventListener.class.getSimpleName(), "#######" + listener.getClass().getName() + "#######"); - } - } - - /** - * 消息接收activity的接收顺序排序,CIM_RECEIVE_ORDER倒序 - */ - private static class CIMMessageReceiveComparator implements Comparator { - - @Override - public int compare(CIMEventListener arg1, CIMEventListener arg2) { - - int order1 = arg1.getEventDispatchOrder(); - int order2 = arg2.getEventDispatchOrder(); - return order2 - order1; - } - - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java deleted file mode 100644 index 545ea87..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushManager.java +++ /dev/null @@ -1,261 +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.sdk.android; - -import java.util.UUID; - -import android.content.Context; -import android.content.Intent; -import android.content.pm.PackageInfo; -import android.content.pm.PackageManager.NameNotFoundException; -import android.os.Build; -import android.text.TextUtils; - -import com.farsunset.cim.sdk.android.constant.CIMConstant; -import com.farsunset.cim.sdk.android.model.SentBody; - -/** - * CIM 功能接口 - */ -public class CIMPushManager { - - static String ACTION_ACTIVATE_PUSH_SERVICE = "ACTION_ACTIVATE_PUSH_SERVICE"; - - static String ACTION_CREATE_CIM_CONNECTION = "ACTION_CREATE_CIM_CONNECTION"; - - static String ACTION_SEND_REQUEST_BODY = "ACTION_SEND_REQUEST_BODY"; - - static String ACTION_CLOSE_CIM_CONNECTION = "ACTION_CLOSE_CIM_CONNECTION"; - - static String ACTION_SET_LOGGER_EANABLE = "ACTION_SET_LOGGER_EANABLE"; - - static String ACTION_DESTORY = "ACTION_DESTORY"; - - static String KEY_SEND_BODY = "KEY_SEND_BODY"; - - static String KEY_CIM_CONNECTION_STATUS = "KEY_CIM_CONNECTION_STATUS"; - - /** - * 初始化,连接服务端,在程序启动页或者 在Application里调用 - * - * @param context - * @param ip - * @param port - */ - public static void connect(Context context, String host, int port) { - - connect(context, host, port, false, 0); - - } - - private static void connect(Context context, String ip, int port, boolean autoBind, long delayedTime) { - - CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_CIM_DESTROYED, false); - CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_MANUAL_STOP, false); - - CIMCacheManager.putString(context, CIMCacheManager.KEY_CIM_SERVIER_HOST, ip); - CIMCacheManager.putInt(context, CIMCacheManager.KEY_CIM_SERVIER_PORT, port); - - if (!autoBind) { - CIMCacheManager.remove(context, CIMCacheManager.KEY_ACCOUNT); - } - - Intent serviceIntent = new Intent(context, CIMPushService.class); - serviceIntent.putExtra(CIMCacheManager.KEY_CIM_SERVIER_HOST, ip); - serviceIntent.putExtra(CIMCacheManager.KEY_CIM_SERVIER_PORT, port); - serviceIntent.putExtra(CIMPushService.KEY_DELAYED_TIME, delayedTime); - serviceIntent.setAction(ACTION_CREATE_CIM_CONNECTION); - startServiceCompat(context,serviceIntent); - } - - public static void setLoggerEnable(Context context,boolean enable) { - Intent serviceIntent = new Intent(context, CIMPushService.class); - serviceIntent.putExtra(CIMPushService.KEY_LOGGER_ENABLE, enable); - serviceIntent.setAction(ACTION_SET_LOGGER_EANABLE); - startServiceCompat(context,serviceIntent); - } - - protected static void connect(Context context, long delayedTime) { - - boolean isManualStop = CIMCacheManager.getBoolean(context, CIMCacheManager.KEY_MANUAL_STOP); - boolean isManualDestory = CIMCacheManager.getBoolean(context, CIMCacheManager.KEY_CIM_DESTROYED); - - if (isManualStop || isManualDestory) { - return; - } - - String host = CIMCacheManager.getString(context, CIMCacheManager.KEY_CIM_SERVIER_HOST); - int port = CIMCacheManager.getInt(context, CIMCacheManager.KEY_CIM_SERVIER_PORT); - - connect(context, host, port, true, delayedTime); - - } - - /** - * 设置一个账号登录到服务端 - * - * @param account - * 用户唯一ID - */ - public static void bindAccount(Context context, String account) { - - boolean isManualDestory = CIMCacheManager.getBoolean(context, CIMCacheManager.KEY_CIM_DESTROYED); - if (isManualDestory || account == null || account.trim().length() == 0) { - return; - } - - sendBindRequest(context, account); - - } - - private static void sendBindRequest(Context context, String account) { - - CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_MANUAL_STOP, false); - CIMCacheManager.putString(context, CIMCacheManager.KEY_ACCOUNT, account); - - String deviceId = CIMCacheManager.getString(context, CIMCacheManager.KEY_DEVICE_ID); - if (TextUtils.isEmpty(deviceId)) { - deviceId = UUID.randomUUID().toString().replaceAll("-", ""); - CIMCacheManager.putString(context, CIMCacheManager.KEY_DEVICE_ID, deviceId); - } - - SentBody sent = new SentBody(); - sent.setKey(CIMConstant.RequestKey.CLIENT_BIND); - sent.put("account", account); - sent.put("deviceId", deviceId); - sent.put("channel", "android"); - sent.put("device", android.os.Build.MODEL); - sent.put("version", getVersionName(context)); - sent.put("osVersion", android.os.Build.VERSION.RELEASE); - sent.put("packageName", context.getPackageName()); - sendRequest(context, sent); - } - - protected static boolean autoBindAccount(Context context) { - - String account = CIMCacheManager.getString(context, CIMCacheManager.KEY_ACCOUNT); - boolean isManualDestory = CIMCacheManager.getBoolean(context, CIMCacheManager.KEY_CIM_DESTROYED); - if (account == null || account.trim().length() == 0 || isManualDestory) { - return false; - } - - sendBindRequest(context, account); - - return true; - } - - /** - * 发送一个CIM请求 - * - * @param context - * @body - */ - public static void sendRequest(Context context, SentBody body) { - - boolean isManualStop = CIMCacheManager.getBoolean(context, CIMCacheManager.KEY_MANUAL_STOP); - boolean isManualDestory = CIMCacheManager.getBoolean(context, CIMCacheManager.KEY_CIM_DESTROYED); - - if (isManualStop || isManualDestory) { - return; - } - - Intent serviceIntent = new Intent(context, CIMPushService.class); - serviceIntent.putExtra(KEY_SEND_BODY, body); - serviceIntent.setAction(ACTION_SEND_REQUEST_BODY); - startServiceCompat(context,serviceIntent); - - } - - /** - * 停止接受推送,将会退出当前账号登录,端口与服务端的连接 - * - * @param context - */ - public static void stop(Context context) { - - boolean isManualDestory = CIMCacheManager.getBoolean(context, CIMCacheManager.KEY_CIM_DESTROYED); - if (isManualDestory) { - return; - } - - CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_MANUAL_STOP, true); - - Intent serviceIntent = new Intent(context, CIMPushService.class); - serviceIntent.setAction(ACTION_CLOSE_CIM_CONNECTION); - startServiceCompat(context,serviceIntent); - - } - - /** - * 完全销毁CIM,一般用于完全退出程序,调用resume将不能恢复 - * - * @param context - */ - public static void destroy(Context context) { - - CIMCacheManager.putBoolean(context, CIMCacheManager.KEY_CIM_DESTROYED, true); - CIMCacheManager.putString(context, CIMCacheManager.KEY_ACCOUNT, null); - - Intent serviceIntent = new Intent(context, CIMPushService.class); - serviceIntent.setAction(ACTION_DESTORY); - startServiceCompat(context,serviceIntent); - - } - - /** - * 重新恢复接收推送,重新连接服务端,并登录当前账号 - * - * @param context - */ - public static void resume(Context context) { - - boolean isManualDestory = CIMCacheManager.getBoolean(context, CIMCacheManager.KEY_CIM_DESTROYED); - if (isManualDestory) { - return; - } - - autoBindAccount(context); - } - - public static boolean isConnected(Context context) { - return CIMCacheManager.getBoolean(context, CIMCacheManager.KEY_CIM_CONNECTION_STATE); - } - - private static String getVersionName(Context context) { - String versionName = null; - try { - PackageInfo mPackageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); - versionName = mPackageInfo.versionName; - } catch (NameNotFoundException e) { - } - return versionName; - } - - private static void startServiceCompat(Context context,Intent intent) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - context.startForegroundService(intent); - } else { - context.startService(intent); - } - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java deleted file mode 100644 index e98fcbb..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/CIMPushService.java +++ /dev/null @@ -1,223 +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.sdk.android; - -import android.app.Notification; -import android.app.NotificationChannel; -import android.app.NotificationManager; -import android.app.Service; -import android.content.BroadcastReceiver; -import android.content.Context; -import android.content.Intent; -import android.content.IntentFilter; -import android.net.ConnectivityManager; -import android.net.Network; -import android.os.Build; -import android.os.Handler; -import android.os.IBinder; -import android.os.Message; - -import java.util.concurrent.Semaphore; - -import com.farsunset.cim.sdk.android.constant.CIMConstant; -import com.farsunset.cim.sdk.android.filter.CIMLoggingHandler; -import com.farsunset.cim.sdk.android.model.SentBody; - -/** - * 与服务端连接服务 - * - * @author 3979434 - * - */ -public class CIMPushService extends Service { - public final static String KEY_DELAYED_TIME = "KEY_DELAYED_TIME"; - public final static String KEY_LOGGER_ENABLE = "KEY_LOGGER_ENABLE"; - - private CIMConnectorManager manager; - private KeepAliveBroadcastReceiver keepAliveReceiver; - private Semaphore semaphore = new Semaphore(1,true); - - @Override - public void onCreate() { - manager = CIMConnectorManager.getManager(this.getApplicationContext()); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O){ - keepAliveReceiver = new KeepAliveBroadcastReceiver(); - registerReceiver(keepAliveReceiver, keepAliveReceiver.getIntentFilter()); - - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { - - ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); - connectivityManager.registerDefaultNetworkCallback(new ConnectivityManager.NetworkCallback() { - @Override - public void onAvailable(Network network) { - Intent intent = new Intent(); - intent.setPackage(getPackageName()); - intent.setAction(CIMConstant.IntentAction.ACTION_NETWORK_CHANGED); - sendBroadcast(intent); - } - @Override - public void onUnavailable() { - Intent intent = new Intent(); - intent.setPackage(getPackageName()); - intent.setAction(CIMConstant.IntentAction.ACTION_NETWORK_CHANGED); - sendBroadcast(intent); - } - - }); - - } - } - - Handler connectionHandler = new Handler() { - @Override - public void handleMessage(android.os.Message message) { - - String host = message.getData().getString(CIMCacheManager.KEY_CIM_SERVIER_HOST); - int port = message.getData().getInt(CIMCacheManager.KEY_CIM_SERVIER_PORT, 0); - manager.connect(host, port); - semaphore.release(); - } - }; - - @Override - public int onStartCommand(Intent intent, int flags, int startId) { - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE); - NotificationChannel channel = new NotificationChannel(getClass().getSimpleName(),getClass().getSimpleName(), NotificationManager.IMPORTANCE_LOW); - channel.enableLights(false); - channel.enableVibration(false); - notificationManager.createNotificationChannel(channel); - Notification notification = new Notification.Builder(this, channel.getId()).build(); - startForeground(this.hashCode(),notification); - } - - intent = (intent == null ? new Intent(CIMPushManager.ACTION_ACTIVATE_PUSH_SERVICE) : intent); - - String action = intent.getAction(); - - if (CIMPushManager.ACTION_CREATE_CIM_CONNECTION.equals(action)) { - handleConnection(intent); - } - - if (CIMPushManager.ACTION_SEND_REQUEST_BODY.equals(action)) { - manager.send((SentBody) intent.getSerializableExtra(CIMPushManager.KEY_SEND_BODY)); - } - - if (CIMPushManager.ACTION_CLOSE_CIM_CONNECTION.equals(action)) { - manager.closeSession(); - } - - if (CIMPushManager.ACTION_DESTORY.equals(action)) { - manager.destroy(); - this.stopSelf(); - } - - if (CIMPushManager.ACTION_ACTIVATE_PUSH_SERVICE.equals(action)) { - handleKeepAlive(); - } - - if (CIMPushManager.ACTION_SET_LOGGER_EANABLE.equals(action)) { - boolean enable = intent.getBooleanExtra(KEY_LOGGER_ENABLE, true); - CIMLoggingHandler.getLogger().debugMode(enable); - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - stopForeground(true); - } - - return super.onStartCommand(intent, flags, startId); - } - - private void handleConnection(Intent intent) { - - long delayMillis = intent.getLongExtra(KEY_DELAYED_TIME, 0); - - if (delayMillis <= 0) { - String host = intent.getStringExtra(CIMCacheManager.KEY_CIM_SERVIER_HOST); - int port = intent.getIntExtra(CIMCacheManager.KEY_CIM_SERVIER_PORT, 0); - manager.connect(host, port); - return; - } - - if(!semaphore.tryAcquire()) { - return; - } - - - Message msg = connectionHandler.obtainMessage(); - msg.what = 0; - msg.setData(intent.getExtras()); - connectionHandler.sendMessageDelayed(msg, delayMillis); - } - - private void handleKeepAlive() { - if (manager.isConnected()) { - CIMLoggingHandler.getLogger().connectState(true); - return; - } - - boolean isManualStop = CIMCacheManager.getBoolean(getApplicationContext(),CIMCacheManager.KEY_MANUAL_STOP); - boolean isDestroyed = CIMCacheManager.getBoolean(getApplicationContext(),CIMCacheManager.KEY_CIM_DESTROYED); - - CIMLoggingHandler.getLogger().connectState(false, isManualStop, isDestroyed); - - CIMPushManager.connect(this, 0); - - } - - @Override - public IBinder onBind(Intent arg0) { - - return null; - } - @Override - public void onDestroy() { - super.onDestroy(); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - unregisterReceiver(keepAliveReceiver); - } - } - - public class KeepAliveBroadcastReceiver extends BroadcastReceiver{ - - @Override - public void onReceive(Context arg0, Intent arg1) { - handleKeepAlive(); - } - - public IntentFilter getIntentFilter() { - IntentFilter intentFilter = new IntentFilter(); - intentFilter.addAction(Intent.ACTION_POWER_CONNECTED); - intentFilter.addAction(Intent.ACTION_POWER_DISCONNECTED); - intentFilter.addAction(Intent.ACTION_SCREEN_ON); - intentFilter.addAction(Intent.ACTION_USER_PRESENT); - - return intentFilter; - } - - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java deleted file mode 100644 index 9bf94b8..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/constant/CIMConstant.java +++ /dev/null @@ -1,106 +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.sdk.android.constant; - -/** - * 常量 - */ -public interface CIMConstant { - - long RECONN_INTERVAL_TIME = 30 * 1000; - - // 消息头长度为3个字节,第一个字节为消息类型,第二,第三字节 转换int后为消息长度 - int DATA_HEADER_LENGTH = 3; - - public static interface ReturnCode { - - String CODE_404 = "404"; - - String CODE_403 = "403"; - - String CODE_405 = "405"; - - String CODE_200 = "200"; - - String CODE_206 = "206"; - - String CODE_500 = "500"; - - } - - public static interface ProtobufType { - byte C_H_RS = 0; - byte S_H_RQ = 1; - byte MESSAGE = 2; - byte SENTBODY = 3; - byte REPLYBODY = 4; - } - - public static interface RequestKey { - - String CLIENT_BIND = "client_bind"; - - String CLIENT_LOGOUT = "client_logout"; - - @Deprecated - String CLIENT_PULL_MESSAGE = "client_pull_message"; - - } - - public static interface MessageAction { - - // 被其他设备登录挤下线消息 - String ACTION_999 = "999"; - } - - public static interface IntentAction { - - // 消息广播action - String ACTION_MESSAGE_RECEIVED = "com.farsunset.cim.MESSAGE_RECEIVED"; - - // 发送sendbody失败广播 - String ACTION_SENT_FAILED = "com.farsunset.cim.SENT_FAILED"; - - // 发送sendbody成功广播 - String ACTION_SENT_SUCCESSED = "com.farsunset.cim.SENT_SUCCESSED"; - - // 链接意外关闭广播 - String ACTION_CONNECTION_CLOSED = "com.farsunset.cim.CONNECTION_CLOSED"; - - // 链接失败广播 - String ACTION_CONNECTION_FAILED = "com.farsunset.cim.CONNECTION_FAILED"; - - // 链接成功广播 - String ACTION_CONNECTION_SUCCESSED = "com.farsunset.cim.CONNECTION_SUCCESSED"; - - // 发送sendbody成功后获得replaybody回应广播 - String ACTION_REPLY_RECEIVED = "com.farsunset.cim.REPLY_RECEIVED"; - - // 网络变化广播 - String ACTION_NETWORK_CHANGED = "com.farsunset.cim.NETWORK_CHANGED"; - - - // 重试连接 - String ACTION_CONNECTION_RECOVERY = "com.farsunset.cim.CONNECTION_RECOVERY"; - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisabledException.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisabledException.java deleted file mode 100644 index 6ad7146..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/exception/NetworkDisabledException.java +++ /dev/null @@ -1,37 +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.sdk.android.exception; - -import java.io.Serializable; - -public class NetworkDisabledException extends Exception implements Serializable { - - private static final long serialVersionUID = 1L; - - public NetworkDisabledException() { - super(); - } - - public NetworkDisabledException(String s) { - super(s); - } -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/CIMLoggingHandler.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/CIMLoggingHandler.java deleted file mode 100644 index cf089b8..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/CIMLoggingHandler.java +++ /dev/null @@ -1,200 +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.sdk.android.filter; - -import java.net.InetSocketAddress; -import java.net.SocketAddress; - - -import android.util.Log; -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler.Sharable; -import io.netty.channel.ChannelDuplexHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.channel.ChannelPromise; -import io.netty.handler.timeout.IdleStateEvent; -@Sharable -public class CIMLoggingHandler extends ChannelDuplexHandler{ - - private final static String TAG = "CIM"; - private boolean debug = true; - - public static CIMLoggingHandler getLogger() { - return LoggerHolder.logger; - } - - private CIMLoggingHandler() { - - } - - private static class LoggerHolder{ - private static CIMLoggingHandler logger = new CIMLoggingHandler(); - } - - public void debugMode(boolean mode) { - debug = mode; - } - - @Override - public void channelRegistered(ChannelHandlerContext ctx) { - ctx.fireChannelRegistered(); - } - - @Override - public void channelUnregistered(ChannelHandlerContext ctx) { - ctx.fireChannelUnregistered(); - } - - @Override - public void channelActive(ChannelHandlerContext ctx) throws Exception { - if(debug) { - Log.i(TAG,"OPENED" + getSessionInfo(ctx.channel())); - } - ctx.fireChannelActive(); - } - - @Override - public void channelInactive(ChannelHandlerContext ctx) throws Exception { - if(debug) { - Log.i(TAG,"CLOSED" + getSessionInfo(ctx.channel())); - } - ctx.fireChannelInactive(); - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - - if(debug) { - Log.d(TAG,String.format("EXCEPTION" + getSessionInfo(ctx.channel()) + "\n%s", cause.getClass().getName() + ":" + cause.getMessage())); - } - - ctx.channel().close(); - } - - public void connectFailure(InetSocketAddress remoteAddress,long interval) { - if(debug) { - Log.d(TAG,"CONNECT FAILURE TRY RECONNECT AFTER " + interval +"ms"); - } - } - - - @Override - public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { - if(debug && evt instanceof IdleStateEvent) { - Log.d(TAG,String.format("IDLE %s" + getSessionInfo(ctx.channel()) , ((IdleStateEvent)evt).state().toString())); - } - ctx.fireUserEventTriggered(evt); - } - - @Override - public void bind(ChannelHandlerContext ctx, SocketAddress localAddress, ChannelPromise promise) throws Exception { - ctx.bind(localAddress, promise); - } - - @Override - public void connect(ChannelHandlerContext ctx,SocketAddress remoteAddress, SocketAddress localAddress, ChannelPromise promise) throws Exception { - if(debug) { - Log.d(TAG,"START CONNECT REMOTE HOST: " + remoteAddress.toString()); - } - ctx.connect(remoteAddress, localAddress, promise); - } - - @Override - public void disconnect(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { - - ctx.disconnect(promise); - } - - @Override - public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { - ctx.close(promise); - } - - @Override - public void deregister(ChannelHandlerContext ctx, ChannelPromise promise) throws Exception { - ctx.deregister(promise); - } - - @Override - public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { - ctx.fireChannelReadComplete(); - } - - @Override - public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { - if(debug) { - Log.i(TAG,String.format("RECEIVED" + getSessionInfo(ctx.channel()) + "\n%s", msg.toString())); - } - ctx.fireChannelRead(msg); - } - - @Override - public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise) throws Exception { - if(debug) { - Log.i(TAG,String.format("SENT" + getSessionInfo(ctx.channel()) + "\n%s", msg.toString())); - } - ctx.write(msg, promise); - } - - @Override - public void channelWritabilityChanged(ChannelHandlerContext ctx) throws Exception { - ctx.fireChannelWritabilityChanged(); - } - - @Override - public void flush(ChannelHandlerContext ctx) throws Exception { - ctx.flush(); - } - - private String getSessionInfo(Channel session) { - StringBuilder builder = new StringBuilder(); - if (session == null) { - return ""; - } - builder.append(" ["); - builder.append("id:").append(session.id().asShortText()); - - if (session.localAddress() != null) { - builder.append(" L:").append(session.localAddress().toString()); - } - - - if (session.remoteAddress() != null) { - builder.append(" R:").append(session.remoteAddress().toString()); - } - builder.append("]"); - return builder.toString(); - } - - - public void connectState(boolean isConnected) { - if(debug) { - Log.i(TAG,"CONNECTED:" + isConnected); - } - } - - public void connectState(boolean isConnected,boolean isManualStop,boolean isDestroyed) { - if(debug) { - Log.i(TAG,"CONNECTED:" + isConnected + " STOPED:"+isManualStop+ " DESTROYED:"+isDestroyed); - } - } -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageDecoder.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageDecoder.java deleted file mode 100644 index eea4b95..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/filter/ClientMessageDecoder.java +++ /dev/null @@ -1,131 +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.sdk.android.filter; - -import java.util.List; - -import com.farsunset.cim.sdk.android.constant.CIMConstant; -import com.farsunset.cim.sdk.android.model.HeartbeatRequest; -import com.farsunset.cim.sdk.android.model.Message; -import com.farsunset.cim.sdk.android.model.ReplyBody; -import com.farsunset.cim.sdk.android.model.proto.MessageProto; -import com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto; -import com.google.protobuf.InvalidProtocolBufferException; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageDecoder; - -/** - * 客户端消息解码 - */ -public class ClientMessageDecoder extends ByteToMessageDecoder { - - @Override - protected void decode(ChannelHandlerContext arg0, ByteBuf buffer, List queue) throws Exception { - - /** - * 消息头3位 - */ - if (buffer.readableBytes() < CIMConstant.DATA_HEADER_LENGTH) { - return; - } - - buffer.markReaderIndex(); - - buffer.markReaderIndex(); - - byte conetnType = buffer.readByte(); - - byte lv = buffer.readByte();// int 低位 - byte hv = buffer.readByte();// int 高位 - - int conetnLength = getContentLength(lv, hv); - - // 如果消息体没有接收完整,则重置读取,等待下一次重新读取 - if (conetnLength > buffer.readableBytes()) { - buffer.resetReaderIndex(); - return; - } - - byte[] dataBytes = new byte[conetnLength]; - buffer.readBytes(dataBytes); - - Object message = mappingMessageObject(dataBytes, conetnType); - - if (message != null) { - queue.add(message); - } - - } - - private Object mappingMessageObject(byte[] bytes, byte type) throws InvalidProtocolBufferException { - - if (CIMConstant.ProtobufType.S_H_RQ == type) { - HeartbeatRequest request = HeartbeatRequest.getInstance(); - return request; - } - - if (CIMConstant.ProtobufType.REPLYBODY == type) { - ReplyBodyProto.Model bodyProto = ReplyBodyProto.Model.parseFrom(bytes); - ReplyBody body = new ReplyBody(); - body.setKey(bodyProto.getKey()); - body.setTimestamp(bodyProto.getTimestamp()); - body.putAll(bodyProto.getDataMap()); - body.setCode(bodyProto.getCode()); - body.setMessage(bodyProto.getMessage()); - return body; - } - - if (CIMConstant.ProtobufType.MESSAGE == type) { - MessageProto.Model bodyProto = MessageProto.Model.parseFrom(bytes); - Message message = new Message(); - message.setId(bodyProto.getId()); - message.setAction(bodyProto.getAction()); - message.setContent(bodyProto.getContent()); - message.setSender(bodyProto.getSender()); - message.setReceiver(bodyProto.getReceiver()); - message.setTitle(bodyProto.getTitle()); - message.setExtra(bodyProto.getExtra()); - message.setTimestamp(bodyProto.getTimestamp()); - message.setFormat(bodyProto.getFormat()); - return message; - } - - return null; - - } - - /** - * 解析消息体长度 - * - * @param type - * @param length - * @return - */ - private int getContentLength(byte lv, byte hv) { - int l = (lv & 0xff); - int h = (hv & 0xff); - return (l | (h <<= 8)); - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java deleted file mode 100644 index 70303aa..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatRequest.java +++ /dev/null @@ -1,62 +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.sdk.android.model; - -import java.io.Serializable; - -import com.farsunset.cim.sdk.android.constant.CIMConstant; - -/** - * 服务端心跳请求 - * - */ -public class HeartbeatRequest implements Serializable, Protobufable { - - private static final long serialVersionUID = 1L; - private static final String TAG = "SERVER_HEARTBEAT_REQUEST"; - private static final String CMD_HEARTBEAT_RESPONSE = "SR"; - - private static HeartbeatRequest object = new HeartbeatRequest(); - - private HeartbeatRequest() { - - } - - public static HeartbeatRequest getInstance() { - return object; - } - - @Override - public byte[] getByteArray() { - return CMD_HEARTBEAT_RESPONSE.getBytes(); - } - - public String toString() { - return TAG; - } - - @Override - public byte getType() { - return CIMConstant.ProtobufType.S_H_RQ; - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java deleted file mode 100644 index 2920b92..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/HeartbeatResponse.java +++ /dev/null @@ -1,61 +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.sdk.android.model; - -import java.io.Serializable; - -import com.farsunset.cim.sdk.android.constant.CIMConstant; - -/** - * 客户端心跳响应 - */ -public class HeartbeatResponse implements Serializable, Protobufable { - - private static final long serialVersionUID = 1L; - private static final String TAG = "CLIENT_HEARTBEAT_RESPONSE"; - private static final String CMD_HEARTBEAT_RESPONSE = "CR"; - - private static HeartbeatResponse object = new HeartbeatResponse(); - - private HeartbeatResponse() { - - } - - public static HeartbeatResponse getInstance() { - return object; - } - - @Override - public byte[] getByteArray() { - return CMD_HEARTBEAT_RESPONSE.getBytes(); - } - - public String toString() { - return TAG; - } - - @Override - public byte getType() { - return CIMConstant.ProtobufType.C_H_RS; - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java deleted file mode 100644 index fcbca5f..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Message.java +++ /dev/null @@ -1,169 +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.sdk.android.model; - -import java.io.Serializable; - -/** - * 消息对象 - */ -public class Message implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * 消息类型,用户自定义消息类别 - */ - private long id; - - /** - * 消息类型,用户自定义消息类别 - */ - private String action; - /** - * 消息标题 - */ - private String title; - /** - * 消息类容,于action 组合为任何类型消息,content 根据 format 可表示为 text,json ,xml数据格式 - */ - private String content; - - /** - * 消息发送者账号 - */ - private String sender; - /** - * 消息发送者接收者 - */ - private String receiver; - - /** - * content 内容格式 - */ - private String format; - - /** - * 附加内容 内容 - */ - private String extra; - - private long timestamp; - - public Message() { - timestamp = System.currentTimeMillis(); - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getSender() { - return sender; - } - - public void setSender(String sender) { - this.sender = sender; - } - - public String getReceiver() { - return receiver; - } - - public void setReceiver(String receiver) { - this.receiver = receiver; - } - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - - public String getExtra() { - return extra; - } - - public void setExtra(String extra) { - this.extra = extra; - } - - public String toString() { - - StringBuffer buffer = new StringBuffer(); - buffer.append("#Message#").append("\n"); - buffer.append("id:").append(id).append("\n"); - buffer.append("action:").append(action).append("\n"); - buffer.append("title:").append(title).append("\n"); - buffer.append("content:").append(content).append("\n"); - buffer.append("extra:").append(extra).append("\n"); - buffer.append("sender:").append(sender).append("\n"); - buffer.append("receiver:").append(receiver).append("\n"); - buffer.append("format:").append(format).append("\n"); - buffer.append("timestamp:").append(timestamp); - return buffer.toString(); - } - - - public long getId() { - return id; - } - - public void setId(long id) { - this.id = id; - } - - public boolean isNotEmpty(String txt) { - return txt != null && txt.trim().length() != 0; - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java deleted file mode 100644 index 9970e4b..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/Protobufable.java +++ /dev/null @@ -1,32 +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.sdk.android.model; - -/** - * 需要向另一端发送的结构体 - */ -public interface Protobufable { - - byte[] getByteArray(); - - byte getType(); -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java deleted file mode 100644 index d8838b8..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/ReplyBody.java +++ /dev/null @@ -1,129 +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.sdk.android.model; - -import java.io.Serializable; -import java.util.Hashtable; -import java.util.Map; -import java.util.Set; - -/** - * 请求应答对象 - * - */ -public class ReplyBody implements Serializable { - - private static final long serialVersionUID = 1L; - - /** - * 请求key - */ - private String key; - - /** - * 返回码 - */ - private String code; - - /** - * 返回说明 - */ - private String message; - - private long timestamp; - - /** - * 返回数据集合 - */ - private Hashtable data = new Hashtable(); - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public void put(String k, String v) { - data.put(k, v); - } - - public String get(String k) { - return data.get(k); - } - - public void remove(String k) { - data.remove(k); - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - public void putAll(Map map) { - data.putAll(map); - } - - public Set getKeySet() { - return data.keySet(); - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("#ReplyBody#").append("\n"); - buffer.append("key:").append(this.getKey()).append("\n"); - buffer.append("timestamp:").append(timestamp).append("\n"); - buffer.append("code:").append(code).append("\n"); - - if (!data.isEmpty()) { - buffer.append("data{").append("\n"); - for (String key : getKeySet()) { - buffer.append(key).append(":").append(this.get(key)).append("\n"); - } - buffer.append("}"); - } - - return buffer.toString(); - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java deleted file mode 100644 index 2b4a581..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/SentBody.java +++ /dev/null @@ -1,117 +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.sdk.android.model; - -import java.io.Serializable; -import java.util.Hashtable; -import java.util.Set; - -import com.farsunset.cim.sdk.android.constant.CIMConstant; -import com.farsunset.cim.sdk.android.model.proto.SentBodyProto; - -/** - * java |android 客户端请求结构 - * - */ -public class SentBody implements Serializable, Protobufable { - - private static final long serialVersionUID = 1L; - - private String key; - - private Hashtable data = new Hashtable();; - - private long timestamp; - - public SentBody() { - timestamp = System.currentTimeMillis(); - } - - public String getKey() { - return key; - } - - public String get(String k) { - return data.get(k); - } - - public long getTimestamp() { - return timestamp; - } - - public void setTimestamp(long timestamp) { - this.timestamp = timestamp; - } - - public void setKey(String key) { - this.key = key; - } - - public void put(String k, String v) { - if (k == null || v == null) { - return; - } - data.put(k, v); - } - - public Set getKeySet() { - return data.keySet(); - } - - public void remove(String k) { - data.remove(k); - } - - @Override - public String toString() { - StringBuffer buffer = new StringBuffer(); - buffer.append("#SentBody#").append("\n"); - ; - buffer.append("key:").append(key).append("\n"); - buffer.append("timestamp:").append(timestamp).append("\n"); - if (!data.isEmpty()) { - buffer.append("data{").append("\n"); - for (String key : getKeySet()) { - buffer.append(key).append(":").append(this.get(key)).append("\n"); - } - buffer.append("}"); - } - return buffer.toString(); - } - - @Override - public byte[] getByteArray() { - SentBodyProto.Model.Builder builder = SentBodyProto.Model.newBuilder(); - builder.setKey(key); - builder.setTimestamp(timestamp); - if (!data.isEmpty()) { - builder.putAllData(data); - } - return builder.build().toByteArray(); - } - - @Override - public byte getType() { - return CIMConstant.ProtobufType.SENTBODY; - } - -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/Message.proto b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/Message.proto deleted file mode 100644 index aee4268..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/Message.proto +++ /dev/null @@ -1,15 +0,0 @@ -syntax = "proto3"; -package com.farsunset.cim.sdk.android.model.proto; -option java_outer_classname="MessageProto"; -message Model { - int64 id = 1; - string action = 2; - string content = 3; - string sender = 4; - string receiver = 5; - string extra = 6; - string title = 7; - string format = 8; - int64 timestamp = 9; -} - \ No newline at end of file diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java deleted file mode 100644 index 9f00868..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/MessageProto.java +++ /dev/null @@ -1,1556 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Message.proto - -package com.farsunset.cim.sdk.android.model.proto; - -public final class MessageProto { - private MessageProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - public interface ModelOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.farsunset.cim.sdk.android.model.proto.Model) - com.google.protobuf.MessageOrBuilder { - - /** - * int64 id = 1; - */ - long getId(); - - /** - * string action = 2; - */ - java.lang.String getAction(); - /** - * string action = 2; - */ - com.google.protobuf.ByteString - getActionBytes(); - - /** - * string content = 3; - */ - java.lang.String getContent(); - /** - * string content = 3; - */ - com.google.protobuf.ByteString - getContentBytes(); - - /** - * string sender = 4; - */ - java.lang.String getSender(); - /** - * string sender = 4; - */ - com.google.protobuf.ByteString - getSenderBytes(); - - /** - * string receiver = 5; - */ - java.lang.String getReceiver(); - /** - * string receiver = 5; - */ - com.google.protobuf.ByteString - getReceiverBytes(); - - /** - * string extra = 6; - */ - java.lang.String getExtra(); - /** - * string extra = 6; - */ - com.google.protobuf.ByteString - getExtraBytes(); - - /** - * string title = 7; - */ - java.lang.String getTitle(); - /** - * string title = 7; - */ - com.google.protobuf.ByteString - getTitleBytes(); - - /** - * string format = 8; - */ - java.lang.String getFormat(); - /** - * string format = 8; - */ - com.google.protobuf.ByteString - getFormatBytes(); - - /** - * int64 timestamp = 9; - */ - long getTimestamp(); - } - /** - * Protobuf type {@code com.farsunset.cim.sdk.android.model.proto.Model} - */ - public static final class Model extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:com.farsunset.cim.sdk.android.model.proto.Model) - ModelOrBuilder { - private static final long serialVersionUID = 0L; - // Use Model.newBuilder() to construct. - private Model(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private Model() { - action_ = ""; - content_ = ""; - sender_ = ""; - receiver_ = ""; - extra_ = ""; - title_ = ""; - format_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Model( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 8: { - - id_ = input.readInt64(); - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - action_ = s; - break; - } - case 26: { - java.lang.String s = input.readStringRequireUtf8(); - - content_ = s; - break; - } - case 34: { - java.lang.String s = input.readStringRequireUtf8(); - - sender_ = s; - break; - } - case 42: { - java.lang.String s = input.readStringRequireUtf8(); - - receiver_ = s; - break; - } - case 50: { - java.lang.String s = input.readStringRequireUtf8(); - - extra_ = s; - break; - } - case 58: { - java.lang.String s = input.readStringRequireUtf8(); - - title_ = s; - break; - } - case 66: { - java.lang.String s = input.readStringRequireUtf8(); - - format_ = s; - break; - } - case 72: { - - timestamp_ = input.readInt64(); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.farsunset.cim.sdk.android.model.proto.MessageProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.farsunset.cim.sdk.android.model.proto.MessageProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.farsunset.cim.sdk.android.model.proto.MessageProto.Model.class, com.farsunset.cim.sdk.android.model.proto.MessageProto.Model.Builder.class); - } - - public static final int ID_FIELD_NUMBER = 1; - private long id_; - /** - * int64 id = 1; - */ - public long getId() { - return id_; - } - - public static final int ACTION_FIELD_NUMBER = 2; - private volatile java.lang.Object action_; - /** - * string action = 2; - */ - public java.lang.String getAction() { - java.lang.Object ref = action_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - action_ = s; - return s; - } - } - /** - * string action = 2; - */ - public com.google.protobuf.ByteString - getActionBytes() { - java.lang.Object ref = action_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - action_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int CONTENT_FIELD_NUMBER = 3; - private volatile java.lang.Object content_; - /** - * string content = 3; - */ - public java.lang.String getContent() { - java.lang.Object ref = content_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - content_ = s; - return s; - } - } - /** - * string content = 3; - */ - public com.google.protobuf.ByteString - getContentBytes() { - java.lang.Object ref = content_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - content_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int SENDER_FIELD_NUMBER = 4; - private volatile java.lang.Object sender_; - /** - * string sender = 4; - */ - public java.lang.String getSender() { - java.lang.Object ref = sender_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - sender_ = s; - return s; - } - } - /** - * string sender = 4; - */ - public com.google.protobuf.ByteString - getSenderBytes() { - java.lang.Object ref = sender_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - sender_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int RECEIVER_FIELD_NUMBER = 5; - private volatile java.lang.Object receiver_; - /** - * string receiver = 5; - */ - public java.lang.String getReceiver() { - java.lang.Object ref = receiver_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - receiver_ = s; - return s; - } - } - /** - * string receiver = 5; - */ - public com.google.protobuf.ByteString - getReceiverBytes() { - java.lang.Object ref = receiver_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - receiver_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int EXTRA_FIELD_NUMBER = 6; - private volatile java.lang.Object extra_; - /** - * string extra = 6; - */ - public java.lang.String getExtra() { - java.lang.Object ref = extra_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - extra_ = s; - return s; - } - } - /** - * string extra = 6; - */ - public com.google.protobuf.ByteString - getExtraBytes() { - java.lang.Object ref = extra_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - extra_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TITLE_FIELD_NUMBER = 7; - private volatile java.lang.Object title_; - /** - * string title = 7; - */ - public java.lang.String getTitle() { - java.lang.Object ref = title_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - title_ = s; - return s; - } - } - /** - * string title = 7; - */ - public com.google.protobuf.ByteString - getTitleBytes() { - java.lang.Object ref = title_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - title_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int FORMAT_FIELD_NUMBER = 8; - private volatile java.lang.Object format_; - /** - * string format = 8; - */ - public java.lang.String getFormat() { - java.lang.Object ref = format_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - format_ = s; - return s; - } - } - /** - * string format = 8; - */ - public com.google.protobuf.ByteString - getFormatBytes() { - java.lang.Object ref = format_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - format_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TIMESTAMP_FIELD_NUMBER = 9; - private long timestamp_; - /** - * int64 timestamp = 9; - */ - public long getTimestamp() { - return timestamp_; - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (id_ != 0L) { - output.writeInt64(1, id_); - } - if (!getActionBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, action_); - } - if (!getContentBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, content_); - } - if (!getSenderBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 4, sender_); - } - if (!getReceiverBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 5, receiver_); - } - if (!getExtraBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 6, extra_); - } - if (!getTitleBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 7, title_); - } - if (!getFormatBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 8, format_); - } - if (timestamp_ != 0L) { - output.writeInt64(9, timestamp_); - } - unknownFields.writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (id_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(1, id_); - } - if (!getActionBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, action_); - } - if (!getContentBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, content_); - } - if (!getSenderBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, sender_); - } - if (!getReceiverBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, receiver_); - } - if (!getExtraBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(6, extra_); - } - if (!getTitleBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(7, title_); - } - if (!getFormatBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, format_); - } - if (timestamp_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(9, timestamp_); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.farsunset.cim.sdk.android.model.proto.MessageProto.Model)) { - return super.equals(obj); - } - com.farsunset.cim.sdk.android.model.proto.MessageProto.Model other = (com.farsunset.cim.sdk.android.model.proto.MessageProto.Model) obj; - - if (getId() - != other.getId()) return false; - if (!getAction() - .equals(other.getAction())) return false; - if (!getContent() - .equals(other.getContent())) return false; - if (!getSender() - .equals(other.getSender())) return false; - if (!getReceiver() - .equals(other.getReceiver())) return false; - if (!getExtra() - .equals(other.getExtra())) return false; - if (!getTitle() - .equals(other.getTitle())) return false; - if (!getFormat() - .equals(other.getFormat())) return false; - if (getTimestamp() - != other.getTimestamp()) return false; - if (!unknownFields.equals(other.unknownFields)) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + ID_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getId()); - hash = (37 * hash) + ACTION_FIELD_NUMBER; - hash = (53 * hash) + getAction().hashCode(); - hash = (37 * hash) + CONTENT_FIELD_NUMBER; - hash = (53 * hash) + getContent().hashCode(); - hash = (37 * hash) + SENDER_FIELD_NUMBER; - hash = (53 * hash) + getSender().hashCode(); - hash = (37 * hash) + RECEIVER_FIELD_NUMBER; - hash = (53 * hash) + getReceiver().hashCode(); - hash = (37 * hash) + EXTRA_FIELD_NUMBER; - hash = (53 * hash) + getExtra().hashCode(); - hash = (37 * hash) + TITLE_FIELD_NUMBER; - hash = (53 * hash) + getTitle().hashCode(); - hash = (37 * hash) + FORMAT_FIELD_NUMBER; - hash = (53 * hash) + getFormat().hashCode(); - hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getTimestamp()); - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.farsunset.cim.sdk.android.model.proto.MessageProto.Model prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code com.farsunset.cim.sdk.android.model.proto.Model} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.farsunset.cim.sdk.android.model.proto.Model) - com.farsunset.cim.sdk.android.model.proto.MessageProto.ModelOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.farsunset.cim.sdk.android.model.proto.MessageProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.farsunset.cim.sdk.android.model.proto.MessageProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.farsunset.cim.sdk.android.model.proto.MessageProto.Model.class, com.farsunset.cim.sdk.android.model.proto.MessageProto.Model.Builder.class); - } - - // Construct using com.farsunset.cim.sdk.android.model.proto.MessageProto.Model.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - @java.lang.Override - public Builder clear() { - super.clear(); - id_ = 0L; - - action_ = ""; - - content_ = ""; - - sender_ = ""; - - receiver_ = ""; - - extra_ = ""; - - title_ = ""; - - format_ = ""; - - timestamp_ = 0L; - - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.farsunset.cim.sdk.android.model.proto.MessageProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.MessageProto.Model getDefaultInstanceForType() { - return com.farsunset.cim.sdk.android.model.proto.MessageProto.Model.getDefaultInstance(); - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.MessageProto.Model build() { - com.farsunset.cim.sdk.android.model.proto.MessageProto.Model result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.MessageProto.Model buildPartial() { - com.farsunset.cim.sdk.android.model.proto.MessageProto.Model result = new com.farsunset.cim.sdk.android.model.proto.MessageProto.Model(this); - result.id_ = id_; - result.action_ = action_; - result.content_ = content_; - result.sender_ = sender_; - result.receiver_ = receiver_; - result.extra_ = extra_; - result.title_ = title_; - result.format_ = format_; - result.timestamp_ = timestamp_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.farsunset.cim.sdk.android.model.proto.MessageProto.Model) { - return mergeFrom((com.farsunset.cim.sdk.android.model.proto.MessageProto.Model)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.farsunset.cim.sdk.android.model.proto.MessageProto.Model other) { - if (other == com.farsunset.cim.sdk.android.model.proto.MessageProto.Model.getDefaultInstance()) return this; - if (other.getId() != 0L) { - setId(other.getId()); - } - if (!other.getAction().isEmpty()) { - action_ = other.action_; - onChanged(); - } - if (!other.getContent().isEmpty()) { - content_ = other.content_; - onChanged(); - } - if (!other.getSender().isEmpty()) { - sender_ = other.sender_; - onChanged(); - } - if (!other.getReceiver().isEmpty()) { - receiver_ = other.receiver_; - onChanged(); - } - if (!other.getExtra().isEmpty()) { - extra_ = other.extra_; - onChanged(); - } - if (!other.getTitle().isEmpty()) { - title_ = other.title_; - onChanged(); - } - if (!other.getFormat().isEmpty()) { - format_ = other.format_; - onChanged(); - } - if (other.getTimestamp() != 0L) { - setTimestamp(other.getTimestamp()); - } - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.farsunset.cim.sdk.android.model.proto.MessageProto.Model parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.farsunset.cim.sdk.android.model.proto.MessageProto.Model) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - - private long id_ ; - /** - * int64 id = 1; - */ - public long getId() { - return id_; - } - /** - * int64 id = 1; - */ - public Builder setId(long value) { - - id_ = value; - onChanged(); - return this; - } - /** - * int64 id = 1; - */ - public Builder clearId() { - - id_ = 0L; - onChanged(); - return this; - } - - private java.lang.Object action_ = ""; - /** - * string action = 2; - */ - public java.lang.String getAction() { - java.lang.Object ref = action_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - action_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string action = 2; - */ - public com.google.protobuf.ByteString - getActionBytes() { - java.lang.Object ref = action_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - action_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string action = 2; - */ - public Builder setAction( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - action_ = value; - onChanged(); - return this; - } - /** - * string action = 2; - */ - public Builder clearAction() { - - action_ = getDefaultInstance().getAction(); - onChanged(); - return this; - } - /** - * string action = 2; - */ - public Builder setActionBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - action_ = value; - onChanged(); - return this; - } - - private java.lang.Object content_ = ""; - /** - * string content = 3; - */ - public java.lang.String getContent() { - java.lang.Object ref = content_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - content_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string content = 3; - */ - public com.google.protobuf.ByteString - getContentBytes() { - java.lang.Object ref = content_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - content_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string content = 3; - */ - public Builder setContent( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - content_ = value; - onChanged(); - return this; - } - /** - * string content = 3; - */ - public Builder clearContent() { - - content_ = getDefaultInstance().getContent(); - onChanged(); - return this; - } - /** - * string content = 3; - */ - public Builder setContentBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - content_ = value; - onChanged(); - return this; - } - - private java.lang.Object sender_ = ""; - /** - * string sender = 4; - */ - public java.lang.String getSender() { - java.lang.Object ref = sender_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - sender_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string sender = 4; - */ - public com.google.protobuf.ByteString - getSenderBytes() { - java.lang.Object ref = sender_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - sender_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string sender = 4; - */ - public Builder setSender( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - sender_ = value; - onChanged(); - return this; - } - /** - * string sender = 4; - */ - public Builder clearSender() { - - sender_ = getDefaultInstance().getSender(); - onChanged(); - return this; - } - /** - * string sender = 4; - */ - public Builder setSenderBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - sender_ = value; - onChanged(); - return this; - } - - private java.lang.Object receiver_ = ""; - /** - * string receiver = 5; - */ - public java.lang.String getReceiver() { - java.lang.Object ref = receiver_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - receiver_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string receiver = 5; - */ - public com.google.protobuf.ByteString - getReceiverBytes() { - java.lang.Object ref = receiver_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - receiver_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string receiver = 5; - */ - public Builder setReceiver( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - receiver_ = value; - onChanged(); - return this; - } - /** - * string receiver = 5; - */ - public Builder clearReceiver() { - - receiver_ = getDefaultInstance().getReceiver(); - onChanged(); - return this; - } - /** - * string receiver = 5; - */ - public Builder setReceiverBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - receiver_ = value; - onChanged(); - return this; - } - - private java.lang.Object extra_ = ""; - /** - * string extra = 6; - */ - public java.lang.String getExtra() { - java.lang.Object ref = extra_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - extra_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string extra = 6; - */ - public com.google.protobuf.ByteString - getExtraBytes() { - java.lang.Object ref = extra_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - extra_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string extra = 6; - */ - public Builder setExtra( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - extra_ = value; - onChanged(); - return this; - } - /** - * string extra = 6; - */ - public Builder clearExtra() { - - extra_ = getDefaultInstance().getExtra(); - onChanged(); - return this; - } - /** - * string extra = 6; - */ - public Builder setExtraBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - extra_ = value; - onChanged(); - return this; - } - - private java.lang.Object title_ = ""; - /** - * string title = 7; - */ - public java.lang.String getTitle() { - java.lang.Object ref = title_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - title_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string title = 7; - */ - public com.google.protobuf.ByteString - getTitleBytes() { - java.lang.Object ref = title_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - title_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string title = 7; - */ - public Builder setTitle( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - title_ = value; - onChanged(); - return this; - } - /** - * string title = 7; - */ - public Builder clearTitle() { - - title_ = getDefaultInstance().getTitle(); - onChanged(); - return this; - } - /** - * string title = 7; - */ - public Builder setTitleBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - title_ = value; - onChanged(); - return this; - } - - private java.lang.Object format_ = ""; - /** - * string format = 8; - */ - public java.lang.String getFormat() { - java.lang.Object ref = format_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - format_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string format = 8; - */ - public com.google.protobuf.ByteString - getFormatBytes() { - java.lang.Object ref = format_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - format_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string format = 8; - */ - public Builder setFormat( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - format_ = value; - onChanged(); - return this; - } - /** - * string format = 8; - */ - public Builder clearFormat() { - - format_ = getDefaultInstance().getFormat(); - onChanged(); - return this; - } - /** - * string format = 8; - */ - public Builder setFormatBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - format_ = value; - onChanged(); - return this; - } - - private long timestamp_ ; - /** - * int64 timestamp = 9; - */ - public long getTimestamp() { - return timestamp_; - } - /** - * int64 timestamp = 9; - */ - public Builder setTimestamp(long value) { - - timestamp_ = value; - onChanged(); - return this; - } - /** - * int64 timestamp = 9; - */ - public Builder clearTimestamp() { - - timestamp_ = 0L; - onChanged(); - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:com.farsunset.cim.sdk.android.model.proto.Model) - } - - // @@protoc_insertion_point(class_scope:com.farsunset.cim.sdk.android.model.proto.Model) - private static final com.farsunset.cim.sdk.android.model.proto.MessageProto.Model DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.farsunset.cim.sdk.android.model.proto.MessageProto.Model(); - } - - public static com.farsunset.cim.sdk.android.model.proto.MessageProto.Model getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public Model parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Model(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.MessageProto.Model getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\rMessage.proto\022)com.farsunset.cim.sdk.a" + - "ndroid.model.proto\"\227\001\n\005Model\022\n\n\002id\030\001 \001(\003" + - "\022\016\n\006action\030\002 \001(\t\022\017\n\007content\030\003 \001(\t\022\016\n\006sen" + - "der\030\004 \001(\t\022\020\n\010receiver\030\005 \001(\t\022\r\n\005extra\030\006 \001" + - "(\t\022\r\n\005title\030\007 \001(\t\022\016\n\006format\030\010 \001(\t\022\021\n\ttim" + - "estamp\030\t \001(\003B\016B\014MessageProtob\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor, - new java.lang.String[] { "Id", "Action", "Content", "Sender", "Receiver", "Extra", "Title", "Format", "Timestamp", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBody.proto b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBody.proto deleted file mode 100644 index db92900..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBody.proto +++ /dev/null @@ -1,13 +0,0 @@ -syntax = "proto3"; -package com.farsunset.cim.sdk.android.model.proto; -option java_outer_classname="ReplyBodyProto"; - -message Model { - string key = 1; - string code = 2; - string message = 3; - int64 timestamp =4; - map data =5; - -} - \ No newline at end of file diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java deleted file mode 100644 index 14116c9..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/ReplyBodyProto.java +++ /dev/null @@ -1,1269 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: ReplyBody.proto - -package com.farsunset.cim.sdk.android.model.proto; - -public final class ReplyBodyProto { - private ReplyBodyProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - public interface ModelOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.farsunset.cim.sdk.android.model.proto.Model) - com.google.protobuf.MessageOrBuilder { - - /** - * string key = 1; - */ - java.lang.String getKey(); - /** - * string key = 1; - */ - com.google.protobuf.ByteString - getKeyBytes(); - - /** - * string code = 2; - */ - java.lang.String getCode(); - /** - * string code = 2; - */ - com.google.protobuf.ByteString - getCodeBytes(); - - /** - * string message = 3; - */ - java.lang.String getMessage(); - /** - * string message = 3; - */ - com.google.protobuf.ByteString - getMessageBytes(); - - /** - * int64 timestamp = 4; - */ - long getTimestamp(); - - /** - * map<string, string> data = 5; - */ - int getDataCount(); - /** - * map<string, string> data = 5; - */ - boolean containsData( - java.lang.String key); - /** - * Use {@link #getDataMap()} instead. - */ - @java.lang.Deprecated - java.util.Map - getData(); - /** - * map<string, string> data = 5; - */ - java.util.Map - getDataMap(); - /** - * map<string, string> data = 5; - */ - - java.lang.String getDataOrDefault( - java.lang.String key, - java.lang.String defaultValue); - /** - * map<string, string> data = 5; - */ - - java.lang.String getDataOrThrow( - java.lang.String key); - } - /** - * Protobuf type {@code com.farsunset.cim.sdk.android.model.proto.Model} - */ - public static final class Model extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:com.farsunset.cim.sdk.android.model.proto.Model) - ModelOrBuilder { - private static final long serialVersionUID = 0L; - // Use Model.newBuilder() to construct. - private Model(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private Model() { - key_ = ""; - code_ = ""; - message_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Model( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - key_ = s; - break; - } - case 18: { - java.lang.String s = input.readStringRequireUtf8(); - - code_ = s; - break; - } - case 26: { - java.lang.String s = input.readStringRequireUtf8(); - - message_ = s; - break; - } - case 32: { - - timestamp_ = input.readInt64(); - break; - } - case 42: { - if (!((mutable_bitField0_ & 0x00000010) != 0)) { - data_ = com.google.protobuf.MapField.newMapField( - DataDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000010; - } - com.google.protobuf.MapEntry - data__ = input.readMessage( - DataDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - data_.getMutableMap().put( - data__.getKey(), data__.getValue()); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 5: - return internalGetData(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model.class, com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model.Builder.class); - } - - private int bitField0_; - public static final int KEY_FIELD_NUMBER = 1; - private volatile java.lang.Object key_; - /** - * string key = 1; - */ - public java.lang.String getKey() { - java.lang.Object ref = key_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - key_ = s; - return s; - } - } - /** - * string key = 1; - */ - public com.google.protobuf.ByteString - getKeyBytes() { - java.lang.Object ref = key_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int CODE_FIELD_NUMBER = 2; - private volatile java.lang.Object code_; - /** - * string code = 2; - */ - public java.lang.String getCode() { - java.lang.Object ref = code_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - code_ = s; - return s; - } - } - /** - * string code = 2; - */ - public com.google.protobuf.ByteString - getCodeBytes() { - java.lang.Object ref = code_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - code_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int MESSAGE_FIELD_NUMBER = 3; - private volatile java.lang.Object message_; - /** - * string message = 3; - */ - public java.lang.String getMessage() { - java.lang.Object ref = message_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - message_ = s; - return s; - } - } - /** - * string message = 3; - */ - public com.google.protobuf.ByteString - getMessageBytes() { - java.lang.Object ref = message_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - message_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TIMESTAMP_FIELD_NUMBER = 4; - private long timestamp_; - /** - * int64 timestamp = 4; - */ - public long getTimestamp() { - return timestamp_; - } - - public static final int DATA_FIELD_NUMBER = 5; - private static final class DataDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, java.lang.String> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.STRING, - ""); - } - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> data_; - private com.google.protobuf.MapField - internalGetData() { - if (data_ == null) { - return com.google.protobuf.MapField.emptyMapField( - DataDefaultEntryHolder.defaultEntry); - } - return data_; - } - - public int getDataCount() { - return internalGetData().getMap().size(); - } - /** - * map<string, string> data = 5; - */ - - public boolean containsData( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - return internalGetData().getMap().containsKey(key); - } - /** - * Use {@link #getDataMap()} instead. - */ - @java.lang.Deprecated - public java.util.Map getData() { - return getDataMap(); - } - /** - * map<string, string> data = 5; - */ - - public java.util.Map getDataMap() { - return internalGetData().getMap(); - } - /** - * map<string, string> data = 5; - */ - - public java.lang.String getDataOrDefault( - java.lang.String key, - java.lang.String defaultValue) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetData().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, string> data = 5; - */ - - public java.lang.String getDataOrThrow( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetData().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getKeyBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, key_); - } - if (!getCodeBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, code_); - } - if (!getMessageBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 3, message_); - } - if (timestamp_ != 0L) { - output.writeInt64(4, timestamp_); - } - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo( - output, - internalGetData(), - DataDefaultEntryHolder.defaultEntry, - 5); - unknownFields.writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getKeyBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, key_); - } - if (!getCodeBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, code_); - } - if (!getMessageBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, message_); - } - if (timestamp_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(4, timestamp_); - } - for (java.util.Map.Entry entry - : internalGetData().getMap().entrySet()) { - com.google.protobuf.MapEntry - data__ = DataDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(5, data__); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model)) { - return super.equals(obj); - } - com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model other = (com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model) obj; - - if (!getKey() - .equals(other.getKey())) return false; - if (!getCode() - .equals(other.getCode())) return false; - if (!getMessage() - .equals(other.getMessage())) return false; - if (getTimestamp() - != other.getTimestamp()) return false; - if (!internalGetData().equals( - other.internalGetData())) return false; - if (!unknownFields.equals(other.unknownFields)) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + KEY_FIELD_NUMBER; - hash = (53 * hash) + getKey().hashCode(); - hash = (37 * hash) + CODE_FIELD_NUMBER; - hash = (53 * hash) + getCode().hashCode(); - hash = (37 * hash) + MESSAGE_FIELD_NUMBER; - hash = (53 * hash) + getMessage().hashCode(); - hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getTimestamp()); - if (!internalGetData().getMap().isEmpty()) { - hash = (37 * hash) + DATA_FIELD_NUMBER; - hash = (53 * hash) + internalGetData().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code com.farsunset.cim.sdk.android.model.proto.Model} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.farsunset.cim.sdk.android.model.proto.Model) - com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.ModelOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 5: - return internalGetData(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField( - int number) { - switch (number) { - case 5: - return internalGetMutableData(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model.class, com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model.Builder.class); - } - - // Construct using com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - @java.lang.Override - public Builder clear() { - super.clear(); - key_ = ""; - - code_ = ""; - - message_ = ""; - - timestamp_ = 0L; - - internalGetMutableData().clear(); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model getDefaultInstanceForType() { - return com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model.getDefaultInstance(); - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model build() { - com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model buildPartial() { - com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model result = new com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.key_ = key_; - result.code_ = code_; - result.message_ = message_; - result.timestamp_ = timestamp_; - result.data_ = internalGetData(); - result.data_.makeImmutable(); - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model) { - return mergeFrom((com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model other) { - if (other == com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model.getDefaultInstance()) return this; - if (!other.getKey().isEmpty()) { - key_ = other.key_; - onChanged(); - } - if (!other.getCode().isEmpty()) { - code_ = other.code_; - onChanged(); - } - if (!other.getMessage().isEmpty()) { - message_ = other.message_; - onChanged(); - } - if (other.getTimestamp() != 0L) { - setTimestamp(other.getTimestamp()); - } - internalGetMutableData().mergeFrom( - other.internalGetData()); - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object key_ = ""; - /** - * string key = 1; - */ - public java.lang.String getKey() { - java.lang.Object ref = key_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - key_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string key = 1; - */ - public com.google.protobuf.ByteString - getKeyBytes() { - java.lang.Object ref = key_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string key = 1; - */ - public Builder setKey( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - key_ = value; - onChanged(); - return this; - } - /** - * string key = 1; - */ - public Builder clearKey() { - - key_ = getDefaultInstance().getKey(); - onChanged(); - return this; - } - /** - * string key = 1; - */ - public Builder setKeyBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - key_ = value; - onChanged(); - return this; - } - - private java.lang.Object code_ = ""; - /** - * string code = 2; - */ - public java.lang.String getCode() { - java.lang.Object ref = code_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - code_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string code = 2; - */ - public com.google.protobuf.ByteString - getCodeBytes() { - java.lang.Object ref = code_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - code_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string code = 2; - */ - public Builder setCode( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - code_ = value; - onChanged(); - return this; - } - /** - * string code = 2; - */ - public Builder clearCode() { - - code_ = getDefaultInstance().getCode(); - onChanged(); - return this; - } - /** - * string code = 2; - */ - public Builder setCodeBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - code_ = value; - onChanged(); - return this; - } - - private java.lang.Object message_ = ""; - /** - * string message = 3; - */ - public java.lang.String getMessage() { - java.lang.Object ref = message_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - message_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string message = 3; - */ - public com.google.protobuf.ByteString - getMessageBytes() { - java.lang.Object ref = message_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - message_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string message = 3; - */ - public Builder setMessage( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - message_ = value; - onChanged(); - return this; - } - /** - * string message = 3; - */ - public Builder clearMessage() { - - message_ = getDefaultInstance().getMessage(); - onChanged(); - return this; - } - /** - * string message = 3; - */ - public Builder setMessageBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - message_ = value; - onChanged(); - return this; - } - - private long timestamp_ ; - /** - * int64 timestamp = 4; - */ - public long getTimestamp() { - return timestamp_; - } - /** - * int64 timestamp = 4; - */ - public Builder setTimestamp(long value) { - - timestamp_ = value; - onChanged(); - return this; - } - /** - * int64 timestamp = 4; - */ - public Builder clearTimestamp() { - - timestamp_ = 0L; - onChanged(); - return this; - } - - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> data_; - private com.google.protobuf.MapField - internalGetData() { - if (data_ == null) { - return com.google.protobuf.MapField.emptyMapField( - DataDefaultEntryHolder.defaultEntry); - } - return data_; - } - private com.google.protobuf.MapField - internalGetMutableData() { - onChanged();; - if (data_ == null) { - data_ = com.google.protobuf.MapField.newMapField( - DataDefaultEntryHolder.defaultEntry); - } - if (!data_.isMutable()) { - data_ = data_.copy(); - } - return data_; - } - - public int getDataCount() { - return internalGetData().getMap().size(); - } - /** - * map<string, string> data = 5; - */ - - public boolean containsData( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - return internalGetData().getMap().containsKey(key); - } - /** - * Use {@link #getDataMap()} instead. - */ - @java.lang.Deprecated - public java.util.Map getData() { - return getDataMap(); - } - /** - * map<string, string> data = 5; - */ - - public java.util.Map getDataMap() { - return internalGetData().getMap(); - } - /** - * map<string, string> data = 5; - */ - - public java.lang.String getDataOrDefault( - java.lang.String key, - java.lang.String defaultValue) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetData().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, string> data = 5; - */ - - public java.lang.String getDataOrThrow( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetData().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public Builder clearData() { - internalGetMutableData().getMutableMap() - .clear(); - return this; - } - /** - * map<string, string> data = 5; - */ - - public Builder removeData( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - internalGetMutableData().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @java.lang.Deprecated - public java.util.Map - getMutableData() { - return internalGetMutableData().getMutableMap(); - } - /** - * map<string, string> data = 5; - */ - public Builder putData( - java.lang.String key, - java.lang.String value) { - if (key == null) { throw new java.lang.NullPointerException(); } - if (value == null) { throw new java.lang.NullPointerException(); } - internalGetMutableData().getMutableMap() - .put(key, value); - return this; - } - /** - * map<string, string> data = 5; - */ - - public Builder putAllData( - java.util.Map values) { - internalGetMutableData().getMutableMap() - .putAll(values); - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:com.farsunset.cim.sdk.android.model.proto.Model) - } - - // @@protoc_insertion_point(class_scope:com.farsunset.cim.sdk.android.model.proto.Model) - private static final com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model(); - } - - public static com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public Model parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Model(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.ReplyBodyProto.Model getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\017ReplyBody.proto\022)com.farsunset.cim.sdk" + - ".android.model.proto\"\275\001\n\005Model\022\013\n\003key\030\001 " + - "\001(\t\022\014\n\004code\030\002 \001(\t\022\017\n\007message\030\003 \001(\t\022\021\n\tti" + - "mestamp\030\004 \001(\003\022H\n\004data\030\005 \003(\0132:.com.farsun" + - "set.cim.sdk.android.model.proto.Model.Da" + - "taEntry\032+\n\tDataEntry\022\013\n\003key\030\001 \001(\t\022\r\n\005val" + - "ue\030\002 \001(\t:\0028\001B\020B\016ReplyBodyProtob\006proto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor, - new java.lang.String[] { "Key", "Code", "Message", "Timestamp", "Data", }); - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_descriptor = - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor.getNestedTypes().get(0); - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBody.proto b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBody.proto deleted file mode 100644 index 20f0534..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBody.proto +++ /dev/null @@ -1,11 +0,0 @@ -syntax = "proto3"; -package com.farsunset.cim.sdk.android.model.proto; -option java_outer_classname="SentBodyProto"; - -message Model { - string key = 1; - int64 timestamp =2; - map data =3; - -} - \ No newline at end of file diff --git a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java b/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java deleted file mode 100644 index f37e9c8..0000000 --- a/cim_for_netty/cim-android-sdk/src/com/farsunset/cim/sdk/android/model/proto/SentBodyProto.java +++ /dev/null @@ -1,995 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: SentBody.proto - -package com.farsunset.cim.sdk.android.model.proto; - -public final class SentBodyProto { - private SentBodyProto() {} - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions( - com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions( - (com.google.protobuf.ExtensionRegistryLite) registry); - } - public interface ModelOrBuilder extends - // @@protoc_insertion_point(interface_extends:com.farsunset.cim.sdk.android.model.proto.Model) - com.google.protobuf.MessageOrBuilder { - - /** - * string key = 1; - */ - java.lang.String getKey(); - /** - * string key = 1; - */ - com.google.protobuf.ByteString - getKeyBytes(); - - /** - * int64 timestamp = 2; - */ - long getTimestamp(); - - /** - * map<string, string> data = 3; - */ - int getDataCount(); - /** - * map<string, string> data = 3; - */ - boolean containsData( - java.lang.String key); - /** - * Use {@link #getDataMap()} instead. - */ - @java.lang.Deprecated - java.util.Map - getData(); - /** - * map<string, string> data = 3; - */ - java.util.Map - getDataMap(); - /** - * map<string, string> data = 3; - */ - - java.lang.String getDataOrDefault( - java.lang.String key, - java.lang.String defaultValue); - /** - * map<string, string> data = 3; - */ - - java.lang.String getDataOrThrow( - java.lang.String key); - } - /** - * Protobuf type {@code com.farsunset.cim.sdk.android.model.proto.Model} - */ - public static final class Model extends - com.google.protobuf.GeneratedMessageV3 implements - // @@protoc_insertion_point(message_implements:com.farsunset.cim.sdk.android.model.proto.Model) - ModelOrBuilder { - private static final long serialVersionUID = 0L; - // Use Model.newBuilder() to construct. - private Model(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - private Model() { - key_ = ""; - } - - @java.lang.Override - public final com.google.protobuf.UnknownFieldSet - getUnknownFields() { - return this.unknownFields; - } - private Model( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - this(); - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - int mutable_bitField0_ = 0; - com.google.protobuf.UnknownFieldSet.Builder unknownFields = - com.google.protobuf.UnknownFieldSet.newBuilder(); - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch (tag) { - case 0: - done = true; - break; - case 10: { - java.lang.String s = input.readStringRequireUtf8(); - - key_ = s; - break; - } - case 16: { - - timestamp_ = input.readInt64(); - break; - } - case 26: { - if (!((mutable_bitField0_ & 0x00000004) != 0)) { - data_ = com.google.protobuf.MapField.newMapField( - DataDefaultEntryHolder.defaultEntry); - mutable_bitField0_ |= 0x00000004; - } - com.google.protobuf.MapEntry - data__ = input.readMessage( - DataDefaultEntryHolder.defaultEntry.getParserForType(), extensionRegistry); - data_.getMutableMap().put( - data__.getKey(), data__.getValue()); - break; - } - default: { - if (!parseUnknownField( - input, unknownFields, extensionRegistry, tag)) { - done = true; - } - break; - } - } - } - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(this); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException( - e).setUnfinishedMessage(this); - } finally { - this.unknownFields = unknownFields.build(); - makeExtensionsImmutable(); - } - } - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.farsunset.cim.sdk.android.model.proto.SentBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - @java.lang.Override - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 3: - return internalGetData(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.farsunset.cim.sdk.android.model.proto.SentBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model.class, com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model.Builder.class); - } - - private int bitField0_; - public static final int KEY_FIELD_NUMBER = 1; - private volatile java.lang.Object key_; - /** - * string key = 1; - */ - public java.lang.String getKey() { - java.lang.Object ref = key_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - key_ = s; - return s; - } - } - /** - * string key = 1; - */ - public com.google.protobuf.ByteString - getKeyBytes() { - java.lang.Object ref = key_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - - public static final int TIMESTAMP_FIELD_NUMBER = 2; - private long timestamp_; - /** - * int64 timestamp = 2; - */ - public long getTimestamp() { - return timestamp_; - } - - public static final int DATA_FIELD_NUMBER = 3; - private static final class DataDefaultEntryHolder { - static final com.google.protobuf.MapEntry< - java.lang.String, java.lang.String> defaultEntry = - com.google.protobuf.MapEntry - .newDefaultInstance( - com.farsunset.cim.sdk.android.model.proto.SentBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_descriptor, - com.google.protobuf.WireFormat.FieldType.STRING, - "", - com.google.protobuf.WireFormat.FieldType.STRING, - ""); - } - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> data_; - private com.google.protobuf.MapField - internalGetData() { - if (data_ == null) { - return com.google.protobuf.MapField.emptyMapField( - DataDefaultEntryHolder.defaultEntry); - } - return data_; - } - - public int getDataCount() { - return internalGetData().getMap().size(); - } - /** - * map<string, string> data = 3; - */ - - public boolean containsData( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - return internalGetData().getMap().containsKey(key); - } - /** - * Use {@link #getDataMap()} instead. - */ - @java.lang.Deprecated - public java.util.Map getData() { - return getDataMap(); - } - /** - * map<string, string> data = 3; - */ - - public java.util.Map getDataMap() { - return internalGetData().getMap(); - } - /** - * map<string, string> data = 3; - */ - - public java.lang.String getDataOrDefault( - java.lang.String key, - java.lang.String defaultValue) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetData().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, string> data = 3; - */ - - public java.lang.String getDataOrThrow( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetData().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - private byte memoizedIsInitialized = -1; - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) return true; - if (isInitialized == 0) return false; - - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) - throws java.io.IOException { - if (!getKeyBytes().isEmpty()) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 1, key_); - } - if (timestamp_ != 0L) { - output.writeInt64(2, timestamp_); - } - com.google.protobuf.GeneratedMessageV3 - .serializeStringMapTo( - output, - internalGetData(), - DataDefaultEntryHolder.defaultEntry, - 3); - unknownFields.writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) return size; - - size = 0; - if (!getKeyBytes().isEmpty()) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, key_); - } - if (timestamp_ != 0L) { - size += com.google.protobuf.CodedOutputStream - .computeInt64Size(2, timestamp_); - } - for (java.util.Map.Entry entry - : internalGetData().getMap().entrySet()) { - com.google.protobuf.MapEntry - data__ = DataDefaultEntryHolder.defaultEntry.newBuilderForType() - .setKey(entry.getKey()) - .setValue(entry.getValue()) - .build(); - size += com.google.protobuf.CodedOutputStream - .computeMessageSize(3, data__); - } - size += unknownFields.getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model)) { - return super.equals(obj); - } - com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model other = (com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model) obj; - - if (!getKey() - .equals(other.getKey())) return false; - if (getTimestamp() - != other.getTimestamp()) return false; - if (!internalGetData().equals( - other.internalGetData())) return false; - if (!unknownFields.equals(other.unknownFields)) return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + KEY_FIELD_NUMBER; - hash = (53 * hash) + getKey().hashCode(); - hash = (37 * hash) + TIMESTAMP_FIELD_NUMBER; - hash = (53 * hash) + com.google.protobuf.Internal.hashLong( - getTimestamp()); - if (!internalGetData().getMap().isEmpty()) { - hash = (37 * hash) + DATA_FIELD_NUMBER; - hash = (53 * hash) + internalGetData().hashCode(); - } - hash = (29 * hash) + unknownFields.hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseFrom( - java.nio.ByteBuffer data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseFrom( - java.nio.ByteBuffer data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseFrom( - com.google.protobuf.ByteString data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseFrom( - com.google.protobuf.ByteString data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseFrom(byte[] data) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseFrom( - byte[] data, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseDelimitedFrom(java.io.InputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseDelimitedFrom( - java.io.InputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseFrom( - com.google.protobuf.CodedInputStream input) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input); - } - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parseFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3 - .parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { return newBuilder(); } - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - public static Builder newBuilder(com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE - ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - /** - * Protobuf type {@code com.farsunset.cim.sdk.android.model.proto.Model} - */ - public static final class Builder extends - com.google.protobuf.GeneratedMessageV3.Builder implements - // @@protoc_insertion_point(builder_implements:com.farsunset.cim.sdk.android.model.proto.Model) - com.farsunset.cim.sdk.android.model.proto.SentBodyProto.ModelOrBuilder { - public static final com.google.protobuf.Descriptors.Descriptor - getDescriptor() { - return com.farsunset.cim.sdk.android.model.proto.SentBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - } - - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMapField( - int number) { - switch (number) { - case 3: - return internalGetData(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @SuppressWarnings({"rawtypes"}) - protected com.google.protobuf.MapField internalGetMutableMapField( - int number) { - switch (number) { - case 3: - return internalGetMutableData(); - default: - throw new RuntimeException( - "Invalid map field number: " + number); - } - } - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internalGetFieldAccessorTable() { - return com.farsunset.cim.sdk.android.model.proto.SentBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable - .ensureFieldAccessorsInitialized( - com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model.class, com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model.Builder.class); - } - - // Construct using com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model.newBuilder() - private Builder() { - maybeForceBuilderInitialization(); - } - - private Builder( - com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - maybeForceBuilderInitialization(); - } - private void maybeForceBuilderInitialization() { - if (com.google.protobuf.GeneratedMessageV3 - .alwaysUseFieldBuilders) { - } - } - @java.lang.Override - public Builder clear() { - super.clear(); - key_ = ""; - - timestamp_ = 0L; - - internalGetMutableData().clear(); - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor - getDescriptorForType() { - return com.farsunset.cim.sdk.android.model.proto.SentBodyProto.internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model getDefaultInstanceForType() { - return com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model.getDefaultInstance(); - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model build() { - com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model buildPartial() { - com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model result = new com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model(this); - int from_bitField0_ = bitField0_; - int to_bitField0_ = 0; - result.key_ = key_; - result.timestamp_ = timestamp_; - result.data_ = internalGetData(); - result.data_.makeImmutable(); - result.bitField0_ = to_bitField0_; - onBuilt(); - return result; - } - - @java.lang.Override - public Builder clone() { - return super.clone(); - } - @java.lang.Override - public Builder setField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.setField(field, value); - } - @java.lang.Override - public Builder clearField( - com.google.protobuf.Descriptors.FieldDescriptor field) { - return super.clearField(field); - } - @java.lang.Override - public Builder clearOneof( - com.google.protobuf.Descriptors.OneofDescriptor oneof) { - return super.clearOneof(oneof); - } - @java.lang.Override - public Builder setRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - int index, java.lang.Object value) { - return super.setRepeatedField(field, index, value); - } - @java.lang.Override - public Builder addRepeatedField( - com.google.protobuf.Descriptors.FieldDescriptor field, - java.lang.Object value) { - return super.addRepeatedField(field, value); - } - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model) { - return mergeFrom((com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model)other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model other) { - if (other == com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model.getDefaultInstance()) return this; - if (!other.getKey().isEmpty()) { - key_ = other.key_; - onChanged(); - } - if (other.getTimestamp() != 0L) { - setTimestamp(other.getTimestamp()); - } - internalGetMutableData().mergeFrom( - other.internalGetData()); - this.mergeUnknownFields(other.unknownFields); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws java.io.IOException { - com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model parsedMessage = null; - try { - parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - parsedMessage = (com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model) e.getUnfinishedMessage(); - throw e.unwrapIOException(); - } finally { - if (parsedMessage != null) { - mergeFrom(parsedMessage); - } - } - return this; - } - private int bitField0_; - - private java.lang.Object key_ = ""; - /** - * string key = 1; - */ - public java.lang.String getKey() { - java.lang.Object ref = key_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = - (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - key_ = s; - return s; - } else { - return (java.lang.String) ref; - } - } - /** - * string key = 1; - */ - public com.google.protobuf.ByteString - getKeyBytes() { - java.lang.Object ref = key_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = - com.google.protobuf.ByteString.copyFromUtf8( - (java.lang.String) ref); - key_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } - } - /** - * string key = 1; - */ - public Builder setKey( - java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - - key_ = value; - onChanged(); - return this; - } - /** - * string key = 1; - */ - public Builder clearKey() { - - key_ = getDefaultInstance().getKey(); - onChanged(); - return this; - } - /** - * string key = 1; - */ - public Builder setKeyBytes( - com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); - } - checkByteStringIsUtf8(value); - - key_ = value; - onChanged(); - return this; - } - - private long timestamp_ ; - /** - * int64 timestamp = 2; - */ - public long getTimestamp() { - return timestamp_; - } - /** - * int64 timestamp = 2; - */ - public Builder setTimestamp(long value) { - - timestamp_ = value; - onChanged(); - return this; - } - /** - * int64 timestamp = 2; - */ - public Builder clearTimestamp() { - - timestamp_ = 0L; - onChanged(); - return this; - } - - private com.google.protobuf.MapField< - java.lang.String, java.lang.String> data_; - private com.google.protobuf.MapField - internalGetData() { - if (data_ == null) { - return com.google.protobuf.MapField.emptyMapField( - DataDefaultEntryHolder.defaultEntry); - } - return data_; - } - private com.google.protobuf.MapField - internalGetMutableData() { - onChanged();; - if (data_ == null) { - data_ = com.google.protobuf.MapField.newMapField( - DataDefaultEntryHolder.defaultEntry); - } - if (!data_.isMutable()) { - data_ = data_.copy(); - } - return data_; - } - - public int getDataCount() { - return internalGetData().getMap().size(); - } - /** - * map<string, string> data = 3; - */ - - public boolean containsData( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - return internalGetData().getMap().containsKey(key); - } - /** - * Use {@link #getDataMap()} instead. - */ - @java.lang.Deprecated - public java.util.Map getData() { - return getDataMap(); - } - /** - * map<string, string> data = 3; - */ - - public java.util.Map getDataMap() { - return internalGetData().getMap(); - } - /** - * map<string, string> data = 3; - */ - - public java.lang.String getDataOrDefault( - java.lang.String key, - java.lang.String defaultValue) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetData().getMap(); - return map.containsKey(key) ? map.get(key) : defaultValue; - } - /** - * map<string, string> data = 3; - */ - - public java.lang.String getDataOrThrow( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - java.util.Map map = - internalGetData().getMap(); - if (!map.containsKey(key)) { - throw new java.lang.IllegalArgumentException(); - } - return map.get(key); - } - - public Builder clearData() { - internalGetMutableData().getMutableMap() - .clear(); - return this; - } - /** - * map<string, string> data = 3; - */ - - public Builder removeData( - java.lang.String key) { - if (key == null) { throw new java.lang.NullPointerException(); } - internalGetMutableData().getMutableMap() - .remove(key); - return this; - } - /** - * Use alternate mutation accessors instead. - */ - @java.lang.Deprecated - public java.util.Map - getMutableData() { - return internalGetMutableData().getMutableMap(); - } - /** - * map<string, string> data = 3; - */ - public Builder putData( - java.lang.String key, - java.lang.String value) { - if (key == null) { throw new java.lang.NullPointerException(); } - if (value == null) { throw new java.lang.NullPointerException(); } - internalGetMutableData().getMutableMap() - .put(key, value); - return this; - } - /** - * map<string, string> data = 3; - */ - - public Builder putAllData( - java.util.Map values) { - internalGetMutableData().getMutableMap() - .putAll(values); - return this; - } - @java.lang.Override - public final Builder setUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields( - final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - - - // @@protoc_insertion_point(builder_scope:com.farsunset.cim.sdk.android.model.proto.Model) - } - - // @@protoc_insertion_point(class_scope:com.farsunset.cim.sdk.android.model.proto.Model) - private static final com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model DEFAULT_INSTANCE; - static { - DEFAULT_INSTANCE = new com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model(); - } - - public static com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser - PARSER = new com.google.protobuf.AbstractParser() { - @java.lang.Override - public Model parsePartialFrom( - com.google.protobuf.CodedInputStream input, - com.google.protobuf.ExtensionRegistryLite extensionRegistry) - throws com.google.protobuf.InvalidProtocolBufferException { - return new Model(input, extensionRegistry); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public com.farsunset.cim.sdk.android.model.proto.SentBodyProto.Model getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - - } - - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_descriptor; - private static final - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor - getDescriptor() { - return descriptor; - } - private static com.google.protobuf.Descriptors.FileDescriptor - descriptor; - static { - java.lang.String[] descriptorData = { - "\n\016SentBody.proto\022)com.farsunset.cim.sdk." + - "android.model.proto\"\236\001\n\005Model\022\013\n\003key\030\001 \001" + - "(\t\022\021\n\ttimestamp\030\002 \001(\003\022H\n\004data\030\003 \003(\0132:.co" + - "m.farsunset.cim.sdk.android.model.proto." + - "Model.DataEntry\032+\n\tDataEntry\022\013\n\003key\030\001 \001(" + - "\t\022\r\n\005value\030\002 \001(\t:\0028\001B\017B\rSentBodyProtob\006p" + - "roto3" - }; - com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner = - new com.google.protobuf.Descriptors.FileDescriptor. InternalDescriptorAssigner() { - public com.google.protobuf.ExtensionRegistry assignDescriptors( - com.google.protobuf.Descriptors.FileDescriptor root) { - descriptor = root; - return null; - } - }; - com.google.protobuf.Descriptors.FileDescriptor - .internalBuildGeneratedFileFrom(descriptorData, - new com.google.protobuf.Descriptors.FileDescriptor[] { - }, assigner); - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor = - getDescriptor().getMessageTypes().get(0); - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor, - new java.lang.String[] { "Key", "Timestamp", "Data", }); - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_descriptor = - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_descriptor.getNestedTypes().get(0); - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_fieldAccessorTable = new - com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( - internal_static_com_farsunset_cim_sdk_android_model_proto_Model_DataEntry_descriptor, - new java.lang.String[] { "Key", "Value", }); - } - - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/cim_for_netty/cim-boot-server/.classpath b/cim_for_netty/cim-boot-server/.classpath deleted file mode 100644 index 467ef2f..0000000 --- a/cim_for_netty/cim-boot-server/.classpath +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/cim_for_netty/cim-boot-server/.gitignore b/cim_for_netty/cim-boot-server/.gitignore deleted file mode 100644 index da88288..0000000 --- a/cim_for_netty/cim-boot-server/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/.gradle/ diff --git a/cim_for_netty/cim-boot-server/.project b/cim_for_netty/cim-boot-server/.project deleted file mode 100644 index 67a0e0b..0000000 --- a/cim_for_netty/cim-boot-server/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - cim-boot-server - Project cim-boot-server created by Buildship. - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.buildship.core.gradleprojectbuilder - - - - - org.springframework.ide.eclipse.boot.validation.springbootbuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.buildship.core.gradleprojectnature - - diff --git a/cim_for_netty/cim-boot-server/.settings/org.eclipse.buildship.core.prefs b/cim_for_netty/cim-boot-server/.settings/org.eclipse.buildship.core.prefs deleted file mode 100644 index e889521..0000000 --- a/cim_for_netty/cim-boot-server/.settings/org.eclipse.buildship.core.prefs +++ /dev/null @@ -1,2 +0,0 @@ -connection.project.dir= -eclipse.preferences.version=1 diff --git a/cim_for_netty/cim-boot-server/.settings/org.springframework.ide.eclipse.prefs b/cim_for_netty/cim-boot-server/.settings/org.springframework.ide.eclipse.prefs deleted file mode 100644 index a12794d..0000000 --- a/cim_for_netty/cim-boot-server/.settings/org.springframework.ide.eclipse.prefs +++ /dev/null @@ -1,2 +0,0 @@ -boot.validation.initialized=true -eclipse.preferences.version=1 diff --git a/cim_for_netty/cim-boot-server/build.gradle b/cim_for_netty/cim-boot-server/build.gradle deleted file mode 100644 index 9589635..0000000 --- a/cim_for_netty/cim-boot-server/build.gradle +++ /dev/null @@ -1,45 +0,0 @@ -buildscript { - repositories { - jcenter() - } - dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:2.1.4.RELEASE") - } -} - -apply plugin: 'java' -apply plugin: 'org.springframework.boot' - -//生成的jar包包名和版本 -jar { - baseName = 'lvxin-server' - version = '1.0.0' -} - -repositories { - jcenter() - -} - -dependencies { - compile fileTree(dir: 'libs', include: '*.jar') - compile 'org.springframework.boot:spring-boot-starter-web:2.1.4.RELEASE' - compile 'org.springframework.boot:spring-boot-starter-freemarker:2.1.4.RELEASE' - compile 'com.google.protobuf:protobuf-java:3.7.0' - compile 'com.google.code.gson:gson:2.8.5' - compile 'commons-io:commons-io:2.6' - compile 'org.apache.commons:commons-lang3:3.5' - compile 'com.squareup.okhttp3:okhttp:3.10.0' - compile 'cn.teaey.apns4j:apns4j:1.1.4' - - compile 'io.netty:netty-handler:4.1.35.Final' - compile 'io.netty:netty-buffer:4.1.35.Final' - compile 'io.netty:netty-codec:4.1.35.Final' - compile 'io.netty:netty-codec-http:4.1.35.Final' - compile 'io.netty:netty-common:4.1.35.Final' - compile 'io.netty:netty-transport:4.1.35.Final' - - - -} - \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/gradle/wrapper/gradle-wrapper.jar b/cim_for_netty/cim-boot-server/gradle/wrapper/gradle-wrapper.jar deleted file mode 100644 index a5fe1cb..0000000 Binary files a/cim_for_netty/cim-boot-server/gradle/wrapper/gradle-wrapper.jar and /dev/null differ diff --git a/cim_for_netty/cim-boot-server/gradle/wrapper/gradle-wrapper.properties b/cim_for_netty/cim-boot-server/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index be280be..0000000 --- a/cim_for_netty/cim-boot-server/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-bin.zip diff --git a/cim_for_netty/cim-boot-server/gradlew b/cim_for_netty/cim-boot-server/gradlew deleted file mode 100644 index cccdd3d..0000000 --- a/cim_for_netty/cim-boot-server/gradlew +++ /dev/null @@ -1,172 +0,0 @@ -#!/usr/bin/env sh - -############################################################################## -## -## Gradle start up script for UN*X -## -############################################################################## - -# Attempt to set APP_HOME -# Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi -done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null - -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS="" - -# Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" - -warn () { - echo "$*" -} - -die () { - echo - echo "$*" - echo - exit 1 -} - -# OS specific support (must be 'true' or 'false'). -cygwin=false -msys=false -darwin=false -nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; -esac - -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar - -# Determine the Java command to use to start the JVM. -if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - if [ ! -x "$JAVACMD" ] ; then - die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." - fi -else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. - -Please set the JAVA_HOME variable in your environment to match the -location of your Java installation." -fi - -# Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi -fi - -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi - # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" - fi - i=$((i+1)) - done - case $i in - (0) set -- ;; - (1) set -- "$args0" ;; - (2) set -- "$args0" "$args1" ;; - (3) set -- "$args0" "$args1" "$args2" ;; - (4) set -- "$args0" "$args1" "$args2" "$args3" ;; - (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac -fi - -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=$(save "$@") - -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" - -# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong -if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then - cd "$(dirname "$0")" -fi - -exec "$JAVACMD" "$@" diff --git a/cim_for_netty/cim-boot-server/gradlew.bat b/cim_for_netty/cim-boot-server/gradlew.bat deleted file mode 100644 index f955316..0000000 --- a/cim_for_netty/cim-boot-server/gradlew.bat +++ /dev/null @@ -1,84 +0,0 @@ -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS= - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega diff --git a/cim_for_netty/cim-boot-server/settings.gradle b/cim_for_netty/cim-boot-server/settings.gradle deleted file mode 100644 index 0b2b2dc..0000000 --- a/cim_for_netty/cim-boot-server/settings.gradle +++ /dev/null @@ -1,10 +0,0 @@ -/* - * This file was generated by the Gradle 'init' task. - * - * The settings file is used to specify which projects to include in your build. - * - * Detailed information about configuring a multi-project build in Gradle can be found - * in the user guide at https://docs.gradle.org/4.5/userguide/multi_project_builds.html - */ - -rootProject.name = 'cim-boot-server' diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/CIMConfig.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/CIMConfig.java deleted file mode 100644 index 28d36b9..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/CIMConfig.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.farsunset.cim; - -import java.io.IOException; -import java.util.HashMap; - -import javax.annotation.PostConstruct; -import javax.annotation.Resource; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.ApplicationContext; -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.sdk.server.model.CIMSession; - -@Configuration -public class CIMConfig implements CIMRequestHandler { - @Value("${cim.server.port}") - private int port; - - @Resource - private BindHandler bindHandler; - - @Resource - private SessionClosedHandler closedHandler; - - @Resource - private ApplicationContext applicationContext; - - private HashMap> appHandlerMap = new HashMap<>(); - - @PostConstruct - private void initHandler() { - /* - * 账号绑定handler - */ - appHandlerMap.put("client_bind", BindHandler.class); - /* - * 连接关闭handler - */ - appHandlerMap.put("client_closed", SessionClosedHandler.class); - } - - @Bean - public CIMNioSocketAcceptor getNioSocketAcceptor() throws IOException { - CIMNioSocketAcceptor nioSocketAcceptor = new CIMNioSocketAcceptor(); - nioSocketAcceptor.setPort(port); - nioSocketAcceptor.setAppSentBodyHandler(this); - nioSocketAcceptor.bind(); - return nioSocketAcceptor; - } - - @Override - public void process(CIMSession session, SentBody body) { - - CIMRequestHandler handler = findHandlerByKey(body.getKey()); - - if(handler == null) {return ;} - - handler.process(session, body); - - } - - private CIMRequestHandler findHandlerByKey(String key){ - Class handlerClass = appHandlerMap.get(key); - if (handlerClass==null){ - return null; - } - return applicationContext.getBean(handlerClass); - } - - -} \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/SessionController.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/SessionController.java deleted file mode 100644 index 74b1c00..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/SessionController.java +++ /dev/null @@ -1,44 +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.admin.controller; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.RequestMapping; - -import com.farsunset.cim.service.CIMSessionService; - -@Controller -@RequestMapping("/console/session") -public class SessionController { - - @Resource - private CIMSessionService memorySessionService; - - @RequestMapping(value = "/list.action") - public String list(Model model) { - model.addAttribute("sessionList", memorySessionService.list()); - return "console/session/manage"; - } -} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/MessageController.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/MessageController.java deleted file mode 100644 index c42ed85..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/MessageController.java +++ /dev/null @@ -1,78 +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.api.controller; - -import javax.annotation.Resource; - -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; - - -@RestController -@RequestMapping("/api/message") -public class MessageController { - - - - @Resource - private SystemMessagePusher systemMessagePusher; - - @Resource - private DefaultMessagePusher defaultMessagePusher; - - - /** - * 此方法仅仅在集群时,通过服务器调用 - * - * @param message - * @return - */ - @RequestMapping(value = "/dispatch",method=RequestMethod.POST) - public MessageResult dispatchSend(Message message) { - return send(message); - } - - - @RequestMapping(value = "/send",method=RequestMethod.POST) - public MessageResult send(Message message) { - - MessageResult result = new MessageResult(); - - message.setId(System.currentTimeMillis()); - if (Constants.MessageType.TYPE_2.equals(message.getAction())) { - systemMessagePusher.push(message); - } else { - defaultMessagePusher.push(message); - } - result.id = message.getId(); - result.timestamp = message.getTimestamp(); - return result; - } - -} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/BaseResult.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/BaseResult.java deleted file mode 100644 index 02b8198..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/BaseResult.java +++ /dev/null @@ -1,34 +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.api.controller.dto; - -import java.util.List; - -import org.springframework.http.HttpStatus; - - -public class BaseResult { - public int code = HttpStatus.OK.value(); - public String message; - public Object data; - public List dataList; -} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/MessageResult.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/MessageResult.java deleted file mode 100644 index 3e84d51..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/MessageResult.java +++ /dev/null @@ -1,27 +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.api.controller.dto; - -public class MessageResult extends BaseResult { - public long timestamp; - public long id; -} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/CIMMessagePusher.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/CIMMessagePusher.java deleted file mode 100644 index 8b0c411..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/CIMMessagePusher.java +++ /dev/null @@ -1,39 +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.push; - -import com.farsunset.cim.sdk.server.model.Message; - -/** - * 消息发送实接口 - * - */ -public interface CIMMessagePusher { - - /** - * 向用户发送消息 - * - * @param msg - */ - public void push(Message msg); - -} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/SystemMessagePusher.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/SystemMessagePusher.java deleted file mode 100644 index f1fe1cb..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/SystemMessagePusher.java +++ /dev/null @@ -1,38 +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.push; - -import org.springframework.stereotype.Component; - -import com.farsunset.cim.sdk.server.model.Message; - -@Component -public class SystemMessagePusher extends DefaultMessagePusher { - - @Override - public void push(Message message) { - - message.setSender("system"); - super.push(message); - - } -} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/CIMSessionService.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/CIMSessionService.java deleted file mode 100644 index 45fb9c8..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/CIMSessionService.java +++ /dev/null @@ -1,43 +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; - -import java.util.List; - -import com.farsunset.cim.sdk.server.model.CIMSession; - - -/** - * 集群 session管理实现示例, 各位可以自行实现 AbstractSessionManager接口来实现自己的 session管理 服务器集群时 - * 须要将CIMSession 信息存入数据库或者redis中 等 第三方存储空间中,便于所有服务器都可以访问 - */ -public interface CIMSessionService { - - void save(CIMSession session); - - CIMSession get(String account); - - List list(); - - void remove(String account); - -} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/ClusterSessionServiceImpl.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/ClusterSessionServiceImpl.java deleted file mode 100644 index 6dacf53..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/ClusterSessionServiceImpl.java +++ /dev/null @@ -1,72 +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.List; - -import javax.annotation.Resource; - -import org.springframework.stereotype.Service; - -import com.farsunset.cim.sdk.server.handler.CIMNioSocketAcceptor; -import com.farsunset.cim.sdk.server.model.CIMSession; -import com.farsunset.cim.service.CIMSessionService; - - -/** - * 集群情况下,数据库或者redis存储实现 - * 自行实现存储管理 - * - */ -@Service("clusterSessionService") -public class ClusterSessionServiceImpl implements CIMSessionService { - - @Resource - private CIMNioSocketAcceptor nioSocketAcceptor; - - @Override - public void save(CIMSession session) { - } - - @Override - public CIMSession get(String account) { - - /* - * CIMSession session = database.getSession(account); - * session.setIoSession(nioSocketAcceptor.getManagedChannel().get(session.getNid())); - * return session; - */ - - return null; - } - - @Override - public void remove(String account) { - } - - @Override - public List list() { - return null; - } - -} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/JavaApnsServiceImpl.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/JavaApnsServiceImpl.java deleted file mode 100644 index d82f591..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/JavaApnsServiceImpl.java +++ /dev/null @@ -1,86 +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.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; - -@Service -public class JavaApnsServiceImpl implements ApnsService { - private final Logger logger = Logger.getLogger(JavaApnsServiceImpl.class.getName()); - @Value("${apple.apns.p12.password}") - private String password; - @Value("${apple.apns.p12.file}") - private String p12Path; - @Value("${apple.apns.debug}") - private boolean isDebug; - - @SuppressWarnings("deprecation") - @Override - public void push(Message message, String deviceToken) { - - if(StringUtils.isBlank(deviceToken)) { - return ; - } - - InputStream stream = getClass().getResourceAsStream(p12Path); - ApnsChannelFactory apnsChannelFactory = Apns4j.newChannelFactoryBuilder() - .keyStoreMeta(stream) - .keyStorePwd(password) - .apnsGateway(isDebug ? ApnsGateway.DEVELOPMENT : ApnsGateway.PRODUCTION) - .build(); - - ApnsChannel apnsChannel = apnsChannelFactory.newChannel(); - - try { - ApnsPayloadCompat apnsPayload = new ApnsPayloadCompat(); - apnsPayload.setAction(message.getAction()); - apnsPayload.setContent(message.getContent()); - apnsPayload.setSender(message.getSender()); - 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()); - }finally { - apnsChannel.close(); - IOUtils.closeQuietly(stream); - } - } -} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/util/ApnsPayloadCompat.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/util/ApnsPayloadCompat.java deleted file mode 100644 index 2cb6566..0000000 --- a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/util/ApnsPayloadCompat.java +++ /dev/null @@ -1,80 +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 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 String action; - private String content; - private String sender; - private String format; - private String receiver; - - - public String getReceiver() { - return receiver; - } - - public void setReceiver(String receiver) { - this.receiver = receiver; - } - - public String getAction() { - return action; - } - - public void setAction(String action) { - this.action = action; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getSender() { - return sender; - } - - public void setSender(String sender) { - this.sender = sender; - } - - public String getFormat() { - return format; - } - - public void setFormat(String format) { - this.format = format; - } - - public String toJsonString() { - return String.format(DATA, action, content, sender,receiver,format); - } -} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/util/Constants.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/util/Constants.java deleted file mode 100644 index 76fe196..0000000 --- a/cim_for_netty/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_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/util/StringUtil.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/util/StringUtil.java deleted file mode 100644 index fdd07b9..0000000 --- a/cim_for_netty/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_for_netty/cim-boot-server/src/main/resources/application.properties b/cim_for_netty/cim-boot-server/src/main/resources/application.properties deleted file mode 100644 index 6986fb9..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/application.properties +++ /dev/null @@ -1,34 +0,0 @@ -server.port=8080 -server.host=192.168.1.100 -################################################################## -# Freemarker Config # -################################################################## -spring.freemarker.suffix=.html -spring.freemarker.charset=utf-8 -spring.freemarker.content-type=text/html -spring.freemarker.cache=false -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 # -################################################################## -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 - - -################################################################## -# System Config # -################################################################## -sys.message.dispatch.url = http://%1$s:${server.port}/api/message/dispatch \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/resources/i18n/messages.properties b/cim_for_netty/cim-boot-server/src/main/resources/i18n/messages.properties deleted file mode 100644 index 831c109..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/i18n/messages.properties +++ /dev/null @@ -1,67 +0,0 @@ -module.common.html.title = CIM\u7BA1\u7406\u7CFB\u7EDF -module.common.account = \u5e10\u53f7 -module.common.password = \u5bc6\u7801 -module.common.save = \u4fdd\u5b58 -module.common.id = ID -module.common.type =\u7c7b\u578b -module.common.name =\u540d\u79f0 -module.common.time =\u65f6\u95f4 -module.common.operation =\u64cd\u4f5c -module.common.query =\u67e5\u8be2 -module.common.look =\u67e5\u770b -module.common.preview =\u9884\u89c8 -module.common.send =\u53d1\u9001 -module.common.saveing = \u6b63\u5728\u4fdd\u5b58,\u8bf7\u7a0d\u5019...... -module.common.add = \u6dfb\u52a0 -module.common.update = \u4fee\u6539 -module.common.delete = \u5220\u9664 -module.common.save.success = \u4fdd\u5b58\u6210\u529f -module.common.delete.success = \u5220\u9664\u6210\u529f -module.common.delete.loading =\u6b63\u5728\u5220\u9664,\u8bf7\u7a0d\u5019...... -module.common.loading = \u52a0\u8f7d\u4e2d,\u8bf7\u7a0d\u5019...... -module.common.description = \u8bf4\u660e -module.common.state = \u72b6\u6001 -module.common.content = \u5185\u5bb9 -module.common.location = \u4f4d\u7f6e -module.common.longitude = \u7ecf\u5ea6 -module.common.latitude = \u7eac\u5ea6 -module.common.sort = \u6392\u5e8f -module.common.code = \u7f16\u53f7 -module.common.import = \u5bfc\u5165 -module.common.headlogo = \u5934\u50cf -module.common.homepage = \u4e3b\u9875 -module.common.website = \u7f51\u5740 -module.common.text = \u6587\u5b57 - -module.global.error.500.hint = \u670d\u52a1\u7a0b\u5e8f\u53d1\u751f\u5185\u90e8\u9519\u8bef -module.global.error.400.hint = \u8bf7\u6c42\u53c2\u6570\u7c7b\u578b\u4e0d\u6b63\u786e -module.global.error.404.hint = \u8bbf\u95ee\u7684\u8d44\u6e90\u4e0d\u5b58\u5728 -module.global.pager.next = \u4e0b\u4e00\u9875 -module.global.pager.previou = \u4e0a\u4e00\u9875 -module.global.pager.description = \u5171{0}\u6761\u8bb0\u5f55,{1}\u9875 - -module.console.about = \u5173\u4e8e -module.console.about.version = v3.5.0 -module.console.about.author = \u4f5c\u8005: \u8fdc\u65b9\u5915\u9633 -module.console.about.author.wechat = \u5fae\u4fe1: 3979434 -module.console.about.author.qq = Q Q: 3979434 -module.console.about.copyright = \u57FA\u4E8EJava\u670D\u52A1\u7AEF\u7684\u5373\u65F6\u901A\u4FE1\u89E3\u51B3\u65B9\u6848,\u4E0Eandroid \u5BA2\u6237\u7AEF\u5B8C\u7F8E\u7ED3\u5408\uFF0C\u540C\u65F6\u652F\u6301\u5176\u4ED6\u8BED\u8A00\u7684\u79FB\u52A8\u5E94\u7528\uFF0C\u7269\u8054\u7F51\uFF0C\u667A\u80FD\u5BB6\u5C45\uFF0C\u684C\u9762\u5E94\u7528\uFF0CWEB\u5E94\u7528\u4EE5\u53CA\u540E\u53F0\u7CFB\u7EDF\u4E4B\u95F4\u7684\u5373\u65F6\u6D88\u4EA4\u4E92\uFF0C\u4E3A\u4F60\u89E3\u51B3\u4E86\u957F\u8FDE\u63A5\u5404\u79CD\u6D88\u606F\u4E8B\u4EF6\uFF0C\u65AD\u7EBF\u91CD\u8FDE\u7B49\u7E41\u7410\u7684\u5904\u7406\uFF0C\u4F7F\u7528\u65B9\u4FBF\u6613\u4E8E\u96C6\u6210\u3002
https://gitee.com/farsunset/cim -module.console.menu.onlineuser = \u5728\u7ebf\u7528\u6237 - -module.console.cimsession.sending = \u6b63\u5728\u53d1\u9001\uff0c\u8bf7\u7a0d\u5019...... -module.console.cimsession.send.success = \u53d1\u9001\u6210\u529f -module.console.cimsession.logo =\u5934\u50cf -module.console.cimsession.account =\u5e10\u53f7 -module.console.cimsession.nid = \u8fde\u63a5ID -module.console.cimsession.channel = \u7ec8\u7aef -module.console.cimsession.app.version =\u5e94\u7528\u7248\u672c -module.console.cimsession.os.version =\u7cfb\u7edf\u7248\u672c -module.console.cimsession.deviceid =\u8bbe\u5907\u7f16\u53f7 -module.console.cimsession.device.model =\u7ec8\u7aef\u578b\u53f7 -module.console.cimsession.online.time =\u5728\u7ebf\u65f6\u957f(\u79d2) -module.console.cimsession.time.format ={0}\u79d2 - -module.console.cimsession.send.message =\u53d1\u9001\u6d88\u606f -module.console.cimsession.receiver = \u63a5\u6536\u5e10\u53f7 -module.console.cimsession.message = \u6d88\u606f\u5185\u5bb9 - diff --git a/cim_for_netty/cim-boot-server/src/main/resources/page/console/header.html b/cim_for_netty/cim-boot-server/src/main/resources/page/console/header.html deleted file mode 100644 index 9c09aa0..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/page/console/header.html +++ /dev/null @@ -1,44 +0,0 @@ - -
-

CIM体验页面

-
- -
-
-
- - - - - diff --git a/cim_for_netty/cim-boot-server/src/main/resources/page/console/index.html b/cim_for_netty/cim-boot-server/src/main/resources/page/console/index.html deleted file mode 100644 index 3710786..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/page/console/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - <@spring.message "module.common.html.title"/> - - - - - - - - - - <#include "/console/header.html"> - <#include "/console/nav.html"> -
-
- - - - - diff --git a/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/loginDialog.html b/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/loginDialog.html deleted file mode 100644 index 9e9ab9d..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/loginDialog.html +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/main.html b/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/main.html deleted file mode 100644 index e2086b4..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/main.html +++ /dev/null @@ -1,103 +0,0 @@ - - - - -CIM Webclient - - - - - - - - - - - - - - - - - -<#include "loginDialog.html"> -<#include "messageDialog.html"> - - \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/messageDialog.html b/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/messageDialog.html deleted file mode 100644 index df86455..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/messageDialog.html +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/resources/page/ftl/spring.ftl b/cim_for_netty/cim-boot-server/src/main/resources/page/ftl/spring.ftl deleted file mode 100644 index 00ef2e1..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/page/ftl/spring.ftl +++ /dev/null @@ -1,384 +0,0 @@ -<#ftl strip_whitespace=true> -<#-- - * spring.ftl - * - * This file consists of a collection of FreeMarker macros aimed at easing - * some of the common requirements of web applications - in particular - * handling of forms. - * - * Spring's FreeMarker support will automatically make this file and therefore - * all macros within it available to any application using Spring's - * FreeMarkerConfigurer. - * - * To take advantage of these macros, the "exposeSpringMacroHelpers" property - * of the FreeMarker class needs to be set to "true". This will expose a - * RequestContext under the name "springMacroRequestContext", as needed by - * the macros in this library. - * - * @author Darren Davison - * @author Juergen Hoeller - * @since 1.1 - --> - -<#-- - * message - * - * Macro to translate a message code into a message. - --> -<#macro message code>${springMacroRequestContext.getMessage(code)} - -<#-- - * messageText - * - * Macro to translate a message code into a message, - * using the given default text if no message found. - --> -<#macro messageText code, text>${springMacroRequestContext.getMessage(code, text)} - -<#-- - * messageArgs - * - * Macro to translate a message code with arguments into a message. - --> -<#macro messageArgs code, args>${springMacroRequestContext.getMessage(code, args)} - -<#-- - * messageArgsText - * - * Macro to translate a message code with arguments into a message, - * using the given default text if no message found. - --> -<#macro messageArgsText code, args, text>${springMacroRequestContext.getMessage(code, args, text)} - -<#-- - * theme - * - * Macro to translate a theme message code into a message. - --> -<#macro theme code>${springMacroRequestContext.getThemeMessage(code)} - -<#-- - * themeText - * - * Macro to translate a theme message code into a message, - * using the given default text if no message found. - --> -<#macro themeText code, text>${springMacroRequestContext.getThemeMessage(code, text)} - -<#-- - * themeArgs - * - * Macro to translate a theme message code with arguments into a message. - --> -<#macro themeArgs code, args>${springMacroRequestContext.getThemeMessage(code, args)} - -<#-- - * themeArgsText - * - * Macro to translate a theme message code with arguments into a message, - * using the given default text if no message found. - --> -<#macro themeArgsText code, args, text>${springMacroRequestContext.getThemeMessage(code, args, text)} - -<#-- - * url - * - * Takes a relative URL and makes it absolute from the server root by - * adding the context root for the web application. - --> -<#macro url relativeUrl extra...><#if extra?? && extra?size!=0>${springMacroRequestContext.getContextUrl(relativeUrl,extra)}<#else>${springMacroRequestContext.getContextUrl(relativeUrl)} - -<#-- - * bind - * - * Exposes a BindStatus object for the given bind path, which can be - * a bean (e.g. "person") to get global errors, or a bean property - * (e.g. "person.name") to get field errors. Can be called multiple times - * within a form to bind to multiple command objects and/or field names. - * - * This macro will participate in the default HTML escape setting for the given - * RequestContext. This can be customized by calling "setDefaultHtmlEscape" - * on the "springMacroRequestContext" context variable, or via the - * "defaultHtmlEscape" context-param in web.xml (same as for the JSP bind tag). - * Also regards a "htmlEscape" variable in the namespace of this library. - * - * Producing no output, the following context variable will be available - * each time this macro is referenced (assuming you import this library in - * your templates with the namespace 'spring'): - * - * spring.status : a BindStatus instance holding the command object name, - * expression, value, and error messages and codes for the path supplied - * - * @param path : the path (string value) of the value required to bind to. - * Spring defaults to a command name of "command" but this can be overridden - * by user config. - --> -<#macro bind path> - <#if htmlEscape?exists> - <#assign status = springMacroRequestContext.getBindStatus(path, htmlEscape)> - <#else> - <#assign status = springMacroRequestContext.getBindStatus(path)> - - <#-- assign a temporary value, forcing a string representation for any - kind of variable. This temp value is only used in this macro lib --> - <#if status.value?exists && status.value?is_boolean> - <#assign stringStatusValue=status.value?string> - <#else> - <#assign stringStatusValue=status.value?default("")> - - - -<#-- - * bindEscaped - * - * Similar to spring:bind, but takes an explicit HTML escape flag rather - * than relying on the default HTML escape setting. - --> -<#macro bindEscaped path, htmlEscape> - <#assign status = springMacroRequestContext.getBindStatus(path, htmlEscape)> - <#-- assign a temporary value, forcing a string representation for any - kind of variable. This temp value is only used in this macro lib --> - <#if status.value?exists && status.value?is_boolean> - <#assign stringStatusValue=status.value?string> - <#else> - <#assign stringStatusValue=status.value?default("")> - - - -<#-- - * formInput - * - * Display a form input field of type 'text' and bind it to an attribute - * of a command or bean. - * - * @param path the name of the field to bind to - * @param attributes any additional attributes for the element (such as class - * or CSS styles or size - --> -<#macro formInput path attributes="" fieldType="text"> - <@bind path/> - ${stringStatusValue}" ${attributes}<@closeTag/> - - -<#-- - * formPasswordInput - * - * Display a form input field of type 'password' and bind it to an attribute - * of a command or bean. No value will ever be displayed. This functionality - * can also be obtained by calling the formInput macro with a 'type' parameter - * of 'password'. - * - * @param path the name of the field to bind to - * @param attributes any additional attributes for the element (such as class - * or CSS styles or size - --> -<#macro formPasswordInput path attributes=""> - <@formInput path, attributes, "password"/> - - -<#-- - * formHiddenInput - * - * Generate a form input field of type 'hidden' and bind it to an attribute - * of a command or bean. This functionality can also be obtained by calling - * the formInput macro with a 'type' parameter of 'hidden'. - * - * @param path the name of the field to bind to - * @param attributes any additional attributes for the element (such as class - * or CSS styles or size - --> -<#macro formHiddenInput path attributes=""> - <@formInput path, attributes, "hidden"/> - - -<#-- - * formTextarea - * - * Display a text area and bind it to an attribute of a command or bean. - * - * @param path the name of the field to bind to - * @param attributes any additional attributes for the element (such as class - * or CSS styles or size - --> -<#macro formTextarea path attributes=""> - <@bind path/> - - - -<#-- - * formSingleSelect - * - * Show a selectbox (dropdown) input element allowing a single value to be chosen - * from a list of options. - * - * @param path the name of the field to bind to - * @param options a map (value=label) of all the available options - * @param attributes any additional attributes for the element (such as class - * or CSS styles or size ---> -<#macro formSingleSelect path options attributes=""> - <@bind path/> - - - -<#-- - * formMultiSelect - * - * Show a listbox of options allowing the user to make 0 or more choices from - * the list of options. - * - * @param path the name of the field to bind to - * @param options a map (value=label) of all the available options - * @param attributes any additional attributes for the element (such as class - * or CSS styles or size ---> -<#macro formMultiSelect path options attributes=""> - <@bind path/> - - - -<#-- - * formRadioButtons - * - * Show radio buttons. - * - * @param path the name of the field to bind to - * @param options a map (value=label) of all the available options - * @param separator the html tag or other character list that should be used to - * separate each option. Typically ' ' or '
' - * @param attributes any additional attributes for the element (such as class - * or CSS styles or size ---> -<#macro formRadioButtons path options separator attributes=""> - <@bind path/> - <#list options?keys as value> - <#assign id="${status.expression?replace('[','')?replace(']','')}${value_index}"> - checked="checked" ${attributes}<@closeTag/> - ${separator} - - - -<#-- - * formCheckboxes - * - * Show checkboxes. - * - * @param path the name of the field to bind to - * @param options a map (value=label) of all the available options - * @param separator the html tag or other character list that should be used to - * separate each option. Typically ' ' or '
' - * @param attributes any additional attributes for the element (such as class - * or CSS styles or size ---> -<#macro formCheckboxes path options separator attributes=""> - <@bind path/> - <#list options?keys as value> - <#assign id="${status.expression?replace('[','')?replace(']','')}${value_index}"> - <#assign isSelected = contains(status.actualValue?default([""]), value)> - checked="checked" ${attributes}<@closeTag/> - ${separator} - - - - -<#-- - * formCheckbox - * - * Show a single checkbox. - * - * @param path the name of the field to bind to - * @param attributes any additional attributes for the element (such as class - * or CSS styles or size ---> -<#macro formCheckbox path attributes=""> - <@bind path /> - <#assign id="${status.expression?replace('[','')?replace(']','')}"> - <#assign isSelected = status.value?? && status.value?string=="true"> - - checked="checked" ${attributes}/> - - -<#-- - * showErrors - * - * Show validation errors for the currently bound field, with - * optional style attributes. - * - * @param separator the html tag or other character list that should be used to - * separate each option. Typically '
'. - * @param classOrStyle either the name of a CSS class element (which is defined in - * the template or an external CSS file) or an inline style. If the value passed in here - * contains a colon (:) then a 'style=' attribute will be used, else a 'class=' attribute - * will be used. ---> -<#macro showErrors separator classOrStyle=""> - <#list status.errorMessages as error> - <#if classOrStyle == ""> - ${error} - <#else> - <#if classOrStyle?index_of(":") == -1><#assign attr="class"><#else><#assign attr="style"> - ${error} - - <#if error_has_next>${separator} - - - -<#-- - * checkSelected - * - * Check a value in a list to see if it is the currently selected value. - * If so, add the 'selected="selected"' text to the output. - * Handles values of numeric and string types. - * This function is used internally but can be accessed by user code if required. - * - * @param value the current value in a list iteration ---> -<#macro checkSelected value> - <#if stringStatusValue?is_number && stringStatusValue == value?number>selected="selected" - <#if stringStatusValue?is_string && stringStatusValue == value>selected="selected" - - -<#-- - * contains - * - * Macro to return true if the list contains the scalar, false if not. - * Surprisingly not a FreeMarker builtin. - * This function is used internally but can be accessed by user code if required. - * - * @param list the list to search for the item - * @param item the item to search for in the list - * @return true if item is found in the list, false otherwise ---> -<#function contains list item> - <#list list as nextInList> - <#if nextInList == item><#return true> - - <#return false> - - -<#-- - * closeTag - * - * Simple macro to close an HTML tag that has no body with '>' or '/>', - * depending on the value of a 'xhtmlCompliant' variable in the namespace - * of this library. ---> -<#macro closeTag> - <#if xhtmlCompliant?exists && xhtmlCompliant>/><#else>> - diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/npm.js b/cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/npm.js deleted file mode 100644 index f5825e7..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/static/bootstrap-3.3.7-dist/js/npm.js +++ /dev/null @@ -1,13 +0,0 @@ -// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment. -require('../../js/transition.js'); -require('../../js/alert.js'); -require('../../js/button.js'); -require('../../js/carousel.js'); -require('../../js/collapse.js'); -require('../../js/dropdown.js'); -require('../../js/modal.js'); -require('../../js/tooltip.js'); -require('../../js/popover.js'); -require('../../js/scrollspy.js'); -require('../../js/tab.js'); -require('../../js/affix.js'); \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/css/common.css b/cim_for_netty/cim-boot-server/src/main/resources/static/css/common.css deleted file mode 100644 index 2e70f3c..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/static/css/common.css +++ /dev/null @@ -1 +0,0 @@ -@CHARSET "UTF-8";html,body{height:100%;font-family:微软雅黑;background:url(/image/pattern.png) repeat,linear-gradient(#e1e4e7,#f3f4f5);}.header{position:fixed;height:100px;background:#2b345d;width:100%;z-index:999;line-height:100px;-webkit-box-shadow:0 0 12px 0 #0d1e33;box-shadow:0 0 12px 0 #0d1e33;}.header_liner{position:fixed;height:5px;top:95px;width:100%;z-index:998;background:linear-gradient(to right,#ff4444,#99cc00,#33b5e5,#aa66cc,#ffbb33);}#mainWrapper{width:auto;margin-left:180px;min-height:600px;padding-bottom:50px;padding-top:100px;}ul,ol{margin:0;padding:0;list-style:none;}.tip_blue{zoom:1;background:#3391D7;color:#FFFFFF;text-align:center;line-height:50px;height:50px;font-family:楷体;min-width:300px;position:absolute;z-index:9999;font-size:16px;font-weight:bold;padding:0 15px;border-radius:3px;border:1px solid rgba(0,0,0,.2);-webkit-box-shadow:0 3px 9px rgba(0,0,0,.4);box-shadow:0 3px 5px rgba(0,0,0,.4);}.tip_red{zoom:1;background:#DF3D3D;color:#FFFFFF;text-align:center;font-family:楷体;line-height:50px;height:50px;min-width:300px;position:absolute;z-index:9999;font-size:16px;font-weight:bold;padding:0 15px;border-radius:3px;border:1px solid rgba(0,0,0,.2);-webkit-box-shadow:0 3px 9px rgba(0,0,0,.4);box-shadow:0 3px 5px rgba(0,0,0,.4);}.tip_green{zoom:1;background:#54ad18;color:#ffffff;text-align:center;font-family:楷体;line-height:50px;height:50px;min-width:300px;position:absolute;z-index:9999;font-size:16px;font-weight:bold;padding:0 15px;border-radius:3px;border:1px solid rgba(0,0,0,.2);-webkit-box-shadow:0 3px 9px rgba(0,0,0,.4);box-shadow:0 3px 5px rgba(0,0,0,.4);}.tip_process{zoom:1;color:#394A5E;text-align:center;line-height:50px;height:50px;font-family:楷体;background-color:white;min-width:300px;position:absolute;z-index:9999;border-radius:4px;border:1px solid rgba(0,0,0,.2);-webkit-box-shadow:0 3px 9px rgba(0,0,0,.5);box-shadow:0 3px 9px rgba(0,0,0,.5);}.icon_loading_small{background:url(/image/icon_loading_small.gif) no-repeat;width:22px;height:22px;left:20px;top:15px;position:absolute;}.form-group label{width:70px;text-align:right;}.lay-main-toolbar{height:60px;border-radius:0px;border-right:1px solid #B5BBBF;border-bottom:#c8c8c8 solid 1px;background:white;box-shadow:rgba(0,0,0,0.15) 0px 1px 8px;position:relative;width:100%;padding:8px;}.nav-menu-divider{box-shadow:#e9eaeb 0px 1px 0px;border-bottom:#c4c6c7 solid 1px;}.btn i{font-size:17px;margin-right:2px;font-weight:bold;font-style:normal;line-height:17px;}.modal-dialog{margin:150px auto;}.dialog_close:hover,.dialog_close:focus{opacity:.6;filter:alpha(opacity=60);}.gdialog .modal-header{cursor:move;}.ui-vnav{position:fixed;top:100px;left:0;width:180px;min-height:560px;height:960px;_overflow:hidden;background:#ffffff;z-index:88;box-shadow:1px 0 4px rgba(0,0,0,.3);}.ui-vnav .ui-bar{height:20px;overflow:hidden;}.ui-vnav .ui-bd{display:block;margin:9px 0;width:100%;height:0px;line-height:0px;border-top:1px solid #afb1b2;border-bottom:1px solid #eaeaea;}.ui-vnav .ui-item{height:45px;line-height:45px;padding:0 10px;text-align:center;cursor:pointer;border-bottom:1px #e4e5e6 solid;}.ui-vnav .ui-item:hover{color:white;background-color:#F3F3F3;}.ui-vnav .current,.ui-vnav .current:hover{background-color:#FFFFFF;border-left:6px #44b549 solid;padding-left:4px;}.ui-vnav .ui-item a{position:relative;display:block;height:45px;line-height:45px;font-size:16px;color:#666;text-decoration:none;}.ui-vnav .ui-shd{position:absolute;right:0;top:0;width:4px;height:100%;overflow:hidden;border-right:1px solid #b5b5b6;background-image:-webkit-linear-gradient(left,transparent,rgba(0,0,0,.1));background-image:-moz-linear-gradient(left,transparent,rgba(0,0,0,.1));background-image:-o-linear-gradient(left,transparent,rgba(0,0,0,.1));background-image:linear-gradient(top right,transparent,#c9cacb);filter:progid:DXImageTransform.Microsoft.gradient(startColorStr='#00DBDCDD',EndColorStr='#B5B5B6',gradientType=1);}.utable{border-collapse:collapse;border-spacing:0;text-align:center;font-size:12px;background:#ffffff;word-break:break-all;table-layout:fixed;margin-right:10px;}.utable tr th{background-color:#eff1f9;border-right:solid 1px #D4D4D4;border-left:solid 1px #D4D4D4;border-bottom:solid 1px #D4D4D4;color:#463E5E;line-height:40px;font-size:14px;text-align:center;}.utable tr:hover{background-color:#f5f6f9;}.utable tr td{border-right:solid 1px #D4D4D4;border-bottom:solid 1px #D4D4D4;color:#666;max-height:80px;line-height:35px;height:35px;padding-left:5px;padding-right:5px;word-break:keep-all;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}.datarecord{text-align:center;line-height:30px;background-color:#14A7D5;margin-right:10px;}.input-pagenumber{width:50px;display:inline;height:31px;margin-left:20px;border-top-left-radius:4px;border-bottom-left-radius:4px;border-top-right-radius:0px;border-bottom-right-radius:0px;}textarea{resize:none;}.modal-header{border-bottom:#c8c8c8 solid 1px;box-shadow:rgba(0,0,0,0.15) 0px 1px 8px;height:50px;}.modal-open .modal{overflow-y:hidden;}.btn:focus,button:focus{outline:none;}.bar-button{color:#222222;background-color:#ffffff;border-color:#7d7d7d;}.input-required{border-color:#e91e63;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(204,42,79,.6);box-shadow:inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(204,42,79,.6);} \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/image/favicon.ico b/cim_for_netty/cim-boot-server/src/main/resources/static/image/favicon.ico deleted file mode 100644 index 905729b..0000000 Binary files a/cim_for_netty/cim-boot-server/src/main/resources/static/image/favicon.ico and /dev/null differ diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/image/icon/online.svg b/cim_for_netty/cim-boot-server/src/main/resources/static/image/icon/online.svg deleted file mode 100644 index e0be61f..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/static/image/icon/online.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/image/logo.svg b/cim_for_netty/cim-boot-server/src/main/resources/static/image/logo.svg deleted file mode 100644 index a75c7fc..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/static/image/logo.svg +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/cim_for_netty/cim-boot-server/src/main/resources/static/js/jquery-ui.min.js b/cim_for_netty/cim-boot-server/src/main/resources/static/js/jquery-ui.min.js deleted file mode 100644 index 5824d12..0000000 --- a/cim_for_netty/cim-boot-server/src/main/resources/static/js/jquery-ui.min.js +++ /dev/null @@ -1,13 +0,0 @@ -/*! jQuery UI - v1.11.4 - 2015-03-11 -* http://jqueryui.com -* Includes: core.js, widget.js, mouse.js, position.js, accordion.js, autocomplete.js, button.js, datepicker.js, dialog.js, draggable.js, droppable.js, effect.js, effect-blind.js, effect-bounce.js, effect-clip.js, effect-drop.js, effect-explode.js, effect-fade.js, effect-fold.js, effect-highlight.js, effect-puff.js, effect-pulsate.js, effect-scale.js, effect-shake.js, effect-size.js, effect-slide.js, effect-transfer.js, menu.js, progressbar.js, resizable.js, selectable.js, selectmenu.js, slider.js, sortable.js, spinner.js, tabs.js, tooltip.js -* Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */ - -(function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)})(function(e){function t(t,s){var n,a,o,r=t.nodeName.toLowerCase();return"area"===r?(n=t.parentNode,a=n.name,t.href&&a&&"map"===n.nodeName.toLowerCase()?(o=e("img[usemap='#"+a+"']")[0],!!o&&i(o)):!1):(/^(input|select|textarea|button|object)$/.test(r)?!t.disabled:"a"===r?t.href||s:s)&&i(t)}function i(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}function s(e){for(var t,i;e.length&&e[0]!==document;){if(t=e.css("position"),("absolute"===t||"relative"===t||"fixed"===t)&&(i=parseInt(e.css("zIndex"),10),!isNaN(i)&&0!==i))return i;e=e.parent()}return 0}function n(){this._curInst=null,this._keyEvent=!1,this._disabledInputs=[],this._datepickerShowing=!1,this._inDialog=!1,this._mainDivId="ui-datepicker-div",this._inlineClass="ui-datepicker-inline",this._appendClass="ui-datepicker-append",this._triggerClass="ui-datepicker-trigger",this._dialogClass="ui-datepicker-dialog",this._disableClass="ui-datepicker-disabled",this._unselectableClass="ui-datepicker-unselectable",this._currentClass="ui-datepicker-current-day",this._dayOverClass="ui-datepicker-days-cell-over",this.regional=[],this.regional[""]={closeText:"Done",prevText:"Prev",nextText:"Next",currentText:"Today",monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],weekHeader:"Wk",dateFormat:"mm/dd/yy",firstDay:0,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""},this._defaults={showOn:"focus",showAnim:"fadeIn",showOptions:{},defaultDate:null,appendText:"",buttonText:"...",buttonImage:"",buttonImageOnly:!1,hideIfNoPrevNext:!1,navigationAsDateFormat:!1,gotoCurrent:!1,changeMonth:!1,changeYear:!1,yearRange:"c-10:c+10",showOtherMonths:!1,selectOtherMonths:!1,showWeek:!1,calculateWeek:this.iso8601Week,shortYearCutoff:"+10",minDate:null,maxDate:null,duration:"fast",beforeShowDay:null,beforeShow:null,onSelect:null,onChangeMonthYear:null,onClose:null,numberOfMonths:1,showCurrentAtPos:0,stepMonths:1,stepBigMonths:12,altField:"",altFormat:"",constrainInput:!0,showButtonPanel:!1,autoSize:!1,disabled:!1},e.extend(this._defaults,this.regional[""]),this.regional.en=e.extend(!0,{},this.regional[""]),this.regional["en-US"]=e.extend(!0,{},this.regional.en),this.dpDiv=a(e("
"))}function a(t){var i="button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";return t.delegate(i,"mouseout",function(){e(this).removeClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&e(this).removeClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&e(this).removeClass("ui-datepicker-next-hover")}).delegate(i,"mouseover",o)}function o(){e.datepicker._isDisabledDatepicker(v.inline?v.dpDiv.parent()[0]:v.input[0])||(e(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"),e(this).addClass("ui-state-hover"),-1!==this.className.indexOf("ui-datepicker-prev")&&e(this).addClass("ui-datepicker-prev-hover"),-1!==this.className.indexOf("ui-datepicker-next")&&e(this).addClass("ui-datepicker-next-hover"))}function r(t,i){e.extend(t,i);for(var s in i)null==i[s]&&(t[s]=i[s]);return t}function h(e){return function(){var t=this.element.val();e.apply(this,arguments),this._refresh(),t!==this.element.val()&&this._trigger("change")}}e.ui=e.ui||{},e.extend(e.ui,{version:"1.11.4",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({scrollParent:function(t){var i=this.css("position"),s="absolute"===i,n=t?/(auto|scroll|hidden)/:/(auto|scroll)/,a=this.parents().filter(function(){var t=e(this);return s&&"static"===t.css("position")?!1:n.test(t.css("overflow")+t.css("overflow-y")+t.css("overflow-x"))}).eq(0);return"fixed"!==i&&a.length?a:e(this[0].ownerDocument||document)},uniqueId:function(){var e=0;return function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++e)})}}(),removeUniqueId:function(){return this.each(function(){/^ui-id-\d+$/.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,s){return!!e.data(t,s[3])},focusable:function(i){return t(i,!isNaN(e.attr(i,"tabindex")))},tabbable:function(i){var s=e.attr(i,"tabindex"),n=isNaN(s);return(n||s>=0)&&t(i,!n)}}),e("").outerWidth(1).jquery||e.each(["Width","Height"],function(t,i){function s(t,i,s,a){return e.each(n,function(){i-=parseFloat(e.css(t,"padding"+this))||0,s&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),a&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var n="Width"===i?["Left","Right"]:["Top","Bottom"],a=i.toLowerCase(),o={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+i]=function(t){return void 0===t?o["inner"+i].call(this):this.each(function(){e(this).css(a,s(this,t)+"px")})},e.fn["outer"+i]=function(t,n){return"number"!=typeof t?o["outer"+i].call(this,t):this.each(function(){e(this).css(a,s(this,t,!0,n)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.fn.extend({focus:function(t){return function(i,s){return"number"==typeof i?this.each(function(){var t=this;setTimeout(function(){e(t).focus(),s&&s.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),disableSelection:function(){var e="onselectstart"in document.createElement("div")?"selectstart":"mousedown";return function(){return this.bind(e+".ui-disableSelection",function(e){e.preventDefault()})}}(),enableSelection:function(){return this.unbind(".ui-disableSelection")},zIndex:function(t){if(void 0!==t)return this.css("zIndex",t);if(this.length)for(var i,s,n=e(this[0]);n.length&&n[0]!==document;){if(i=n.css("position"),("absolute"===i||"relative"===i||"fixed"===i)&&(s=parseInt(n.css("zIndex"),10),!isNaN(s)&&0!==s))return s;n=n.parent()}return 0}}),e.ui.plugin={add:function(t,i,s){var n,a=e.ui[t].prototype;for(n in s)a.plugins[n]=a.plugins[n]||[],a.plugins[n].push([i,s[n]])},call:function(e,t,i,s){var n,a=e.plugins[t];if(a&&(s||e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType))for(n=0;a.length>n;n++)e.options[a[n][0]]&&a[n][1].apply(e.element,i)}};var l=0,u=Array.prototype.slice;e.cleanData=function(t){return function(i){var s,n,a;for(a=0;null!=(n=i[a]);a++)try{s=e._data(n,"events"),s&&s.remove&&e(n).triggerHandler("remove")}catch(o){}t(i)}}(e.cleanData),e.widget=function(t,i,s){var n,a,o,r,h={},l=t.split(".")[0];return t=t.split(".")[1],n=l+"-"+t,s||(s=i,i=e.Widget),e.expr[":"][n.toLowerCase()]=function(t){return!!e.data(t,n)},e[l]=e[l]||{},a=e[l][t],o=e[l][t]=function(e,t){return this._createWidget?(arguments.length&&this._createWidget(e,t),void 0):new o(e,t)},e.extend(o,a,{version:s.version,_proto:e.extend({},s),_childConstructors:[]}),r=new i,r.options=e.widget.extend({},r.options),e.each(s,function(t,s){return e.isFunction(s)?(h[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},n=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,a=this._superApply;return this._super=e,this._superApply=n,t=s.apply(this,arguments),this._super=i,this._superApply=a,t}}(),void 0):(h[t]=s,void 0)}),o.prototype=e.widget.extend(r,{widgetEventPrefix:a?r.widgetEventPrefix||t:t},h,{constructor:o,namespace:l,widgetName:t,widgetFullName:n}),a?(e.each(a._childConstructors,function(t,i){var s=i.prototype;e.widget(s.namespace+"."+s.widgetName,o,i._proto)}),delete a._childConstructors):i._childConstructors.push(o),e.widget.bridge(t,o),o},e.widget.extend=function(t){for(var i,s,n=u.call(arguments,1),a=0,o=n.length;o>a;a++)for(i in n[a])s=n[a][i],n[a].hasOwnProperty(i)&&void 0!==s&&(t[i]=e.isPlainObject(s)?e.isPlainObject(t[i])?e.widget.extend({},t[i],s):e.widget.extend({},s):s);return t},e.widget.bridge=function(t,i){var s=i.prototype.widgetFullName||t;e.fn[t]=function(n){var a="string"==typeof n,o=u.call(arguments,1),r=this;return a?this.each(function(){var i,a=e.data(this,s);return"instance"===n?(r=a,!1):a?e.isFunction(a[n])&&"_"!==n.charAt(0)?(i=a[n].apply(a,o),i!==a&&void 0!==i?(r=i&&i.jquery?r.pushStack(i.get()):i,!1):void 0):e.error("no such method '"+n+"' for "+t+" widget instance"):e.error("cannot call methods on "+t+" prior to initialization; "+"attempted to call method '"+n+"'")}):(o.length&&(n=e.widget.extend.apply(null,[n].concat(o))),this.each(function(){var t=e.data(this,s);t?(t.option(n||{}),t._init&&t._init()):e.data(this,s,new i(n,this))})),r}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{disabled:!1,create:null},_createWidget:function(t,i){i=e(i||this.defaultElement||this)[0],this.element=e(i),this.uuid=l++,this.eventNamespace="."+this.widgetName+this.uuid,this.bindings=e(),this.hoverable=e(),this.focusable=e(),i!==this&&(e.data(i,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===i&&this.destroy()}}),this.document=e(i.style?i.ownerDocument:i.document||i),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(t,i){var s,n,a,o=t;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof t)if(o={},s=t.split("."),t=s.shift(),s.length){for(n=o[t]=e.widget.extend({},this.options[t]),a=0;s.length-1>a;a++)n[s[a]]=n[s[a]]||{},n=n[s[a]];if(t=s.pop(),1===arguments.length)return void 0===n[t]?null:n[t];n[t]=i}else{if(1===arguments.length)return void 0===this.options[t]?null:this.options[t];o[t]=i}return this._setOptions(o),this},_setOptions:function(e){var t;for(t in e)this._setOption(t,e[t]);return this},_setOption:function(e,t){return this.options[e]=t,"disabled"===e&&(this.widget().toggleClass(this.widgetFullName+"-disabled",!!t),t&&(this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"))),this},enable:function(){return this._setOptions({disabled:!1})},disable:function(){return this._setOptions({disabled:!0})},_on:function(t,i,s){var n,a=this;"boolean"!=typeof t&&(s=i,i=t,t=!1),s?(i=n=e(i),this.bindings=this.bindings.add(i)):(s=i,i=this.element,n=this.widget()),e.each(s,function(s,o){function r(){return t||a.options.disabled!==!0&&!e(this).hasClass("ui-state-disabled")?("string"==typeof o?a[o]:o).apply(a,arguments):void 0}"string"!=typeof o&&(r.guid=o.guid=o.guid||r.guid||e.guid++);var h=s.match(/^([\w:-]*)\s*(.*)$/),l=h[1]+a.eventNamespace,u=h[2];u?n.delegate(u,l,r):i.bind(l,r)})},_off:function(t,i){i=(i||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace,t.unbind(i).undelegate(i),this.bindings=e(this.bindings.not(t).get()),this.focusable=e(this.focusable.not(t).get()),this.hoverable=e(this.hoverable.not(t).get())},_delay:function(e,t){function i(){return("string"==typeof e?s[e]:e).apply(s,arguments)}var s=this;return setTimeout(i,t||0)},_hoverable:function(t){this.hoverable=this.hoverable.add(t),this._on(t,{mouseenter:function(t){e(t.currentTarget).addClass("ui-state-hover")},mouseleave:function(t){e(t.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(t){this.focusable=this.focusable.add(t),this._on(t,{focusin:function(t){e(t.currentTarget).addClass("ui-state-focus")},focusout:function(t){e(t.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(t,i,s){var n,a,o=this.options[t];if(s=s||{},i=e.Event(i),i.type=(t===this.widgetEventPrefix?t:this.widgetEventPrefix+t).toLowerCase(),i.target=this.element[0],a=i.originalEvent)for(n in a)n in i||(i[n]=a[n]);return this.element.trigger(i,s),!(e.isFunction(o)&&o.apply(this.element[0],[i].concat(s))===!1||i.isDefaultPrevented())}},e.each({show:"fadeIn",hide:"fadeOut"},function(t,i){e.Widget.prototype["_"+t]=function(s,n,a){"string"==typeof n&&(n={effect:n});var o,r=n?n===!0||"number"==typeof n?i:n.effect||i:t;n=n||{},"number"==typeof n&&(n={duration:n}),o=!e.isEmptyObject(n),n.complete=a,n.delay&&s.delay(n.delay),o&&e.effects&&e.effects.effect[r]?s[t](n):r!==t&&s[r]?s[r](n.duration,n.easing,a):s.queue(function(i){e(this)[t](),a&&a.call(s[0]),i()})}}),e.widget;var d=!1;e(document).mouseup(function(){d=!1}),e.widget("ui.mouse",{version:"1.11.4",options:{cancel:"input,textarea,button,select,option",distance:1,delay:0},_mouseInit:function(){var t=this;this.element.bind("mousedown."+this.widgetName,function(e){return t._mouseDown(e)}).bind("click."+this.widgetName,function(i){return!0===e.data(i.target,t.widgetName+".preventClickEvent")?(e.removeData(i.target,t.widgetName+".preventClickEvent"),i.stopImmediatePropagation(),!1):void 0}),this.started=!1},_mouseDestroy:function(){this.element.unbind("."+this.widgetName),this._mouseMoveDelegate&&this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate)},_mouseDown:function(t){if(!d){this._mouseMoved=!1,this._mouseStarted&&this._mouseUp(t),this._mouseDownEvent=t;var i=this,s=1===t.which,n="string"==typeof this.options.cancel&&t.target.nodeName?e(t.target).closest(this.options.cancel).length:!1;return s&&!n&&this._mouseCapture(t)?(this.mouseDelayMet=!this.options.delay,this.mouseDelayMet||(this._mouseDelayTimer=setTimeout(function(){i.mouseDelayMet=!0},this.options.delay)),this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(t)!==!1,!this._mouseStarted)?(t.preventDefault(),!0):(!0===e.data(t.target,this.widgetName+".preventClickEvent")&&e.removeData(t.target,this.widgetName+".preventClickEvent"),this._mouseMoveDelegate=function(e){return i._mouseMove(e)},this._mouseUpDelegate=function(e){return i._mouseUp(e)},this.document.bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate),t.preventDefault(),d=!0,!0)):!0}},_mouseMove:function(t){if(this._mouseMoved){if(e.ui.ie&&(!document.documentMode||9>document.documentMode)&&!t.button)return this._mouseUp(t);if(!t.which)return this._mouseUp(t)}return(t.which||t.button)&&(this._mouseMoved=!0),this._mouseStarted?(this._mouseDrag(t),t.preventDefault()):(this._mouseDistanceMet(t)&&this._mouseDelayMet(t)&&(this._mouseStarted=this._mouseStart(this._mouseDownEvent,t)!==!1,this._mouseStarted?this._mouseDrag(t):this._mouseUp(t)),!this._mouseStarted)},_mouseUp:function(t){return this.document.unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate),this._mouseStarted&&(this._mouseStarted=!1,t.target===this._mouseDownEvent.target&&e.data(t.target,this.widgetName+".preventClickEvent",!0),this._mouseStop(t)),d=!1,!1},_mouseDistanceMet:function(e){return Math.max(Math.abs(this._mouseDownEvent.pageX-e.pageX),Math.abs(this._mouseDownEvent.pageY-e.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}}),function(){function t(e,t,i){return[parseFloat(e[0])*(p.test(e[0])?t/100:1),parseFloat(e[1])*(p.test(e[1])?i/100:1)]}function i(t,i){return parseInt(e.css(t,i),10)||0}function s(t){var i=t[0];return 9===i.nodeType?{width:t.width(),height:t.height(),offset:{top:0,left:0}}:e.isWindow(i)?{width:t.width(),height:t.height(),offset:{top:t.scrollTop(),left:t.scrollLeft()}}:i.preventDefault?{width:0,height:0,offset:{top:i.pageY,left:i.pageX}}:{width:t.outerWidth(),height:t.outerHeight(),offset:t.offset()}}e.ui=e.ui||{};var n,a,o=Math.max,r=Math.abs,h=Math.round,l=/left|center|right/,u=/top|center|bottom/,d=/[\+\-]\d+(\.[\d]+)?%?/,c=/^\w+/,p=/%$/,f=e.fn.position;e.position={scrollbarWidth:function(){if(void 0!==n)return n;var t,i,s=e("
"),a=s.children()[0];return e("body").append(s),t=a.offsetWidth,s.css("overflow","scroll"),i=a.offsetWidth,t===i&&(i=s[0].clientWidth),s.remove(),n=t-i},getScrollInfo:function(t){var i=t.isWindow||t.isDocument?"":t.element.css("overflow-x"),s=t.isWindow||t.isDocument?"":t.element.css("overflow-y"),n="scroll"===i||"auto"===i&&t.widthi?"left":t>0?"right":"center",vertical:0>a?"top":s>0?"bottom":"middle"};d>m&&m>r(t+i)&&(h.horizontal="center"),c>g&&g>r(s+a)&&(h.vertical="middle"),h.important=o(r(t),r(i))>o(r(s),r(a))?"horizontal":"vertical",n.using.call(this,e,h)}),u.offset(e.extend(M,{using:l}))})},e.ui.position={fit:{left:function(e,t){var i,s=t.within,n=s.isWindow?s.scrollLeft:s.offset.left,a=s.width,r=e.left-t.collisionPosition.marginLeft,h=n-r,l=r+t.collisionWidth-a-n;t.collisionWidth>a?h>0&&0>=l?(i=e.left+h+t.collisionWidth-a-n,e.left+=h-i):e.left=l>0&&0>=h?n:h>l?n+a-t.collisionWidth:n:h>0?e.left+=h:l>0?e.left-=l:e.left=o(e.left-r,e.left)},top:function(e,t){var i,s=t.within,n=s.isWindow?s.scrollTop:s.offset.top,a=t.within.height,r=e.top-t.collisionPosition.marginTop,h=n-r,l=r+t.collisionHeight-a-n;t.collisionHeight>a?h>0&&0>=l?(i=e.top+h+t.collisionHeight-a-n,e.top+=h-i):e.top=l>0&&0>=h?n:h>l?n+a-t.collisionHeight:n:h>0?e.top+=h:l>0?e.top-=l:e.top=o(e.top-r,e.top)}},flip:{left:function(e,t){var i,s,n=t.within,a=n.offset.left+n.scrollLeft,o=n.width,h=n.isWindow?n.scrollLeft:n.offset.left,l=e.left-t.collisionPosition.marginLeft,u=l-h,d=l+t.collisionWidth-o-h,c="left"===t.my[0]?-t.elemWidth:"right"===t.my[0]?t.elemWidth:0,p="left"===t.at[0]?t.targetWidth:"right"===t.at[0]?-t.targetWidth:0,f=-2*t.offset[0];0>u?(i=e.left+c+p+f+t.collisionWidth-o-a,(0>i||r(u)>i)&&(e.left+=c+p+f)):d>0&&(s=e.left-t.collisionPosition.marginLeft+c+p+f-h,(s>0||d>r(s))&&(e.left+=c+p+f))},top:function(e,t){var i,s,n=t.within,a=n.offset.top+n.scrollTop,o=n.height,h=n.isWindow?n.scrollTop:n.offset.top,l=e.top-t.collisionPosition.marginTop,u=l-h,d=l+t.collisionHeight-o-h,c="top"===t.my[1],p=c?-t.elemHeight:"bottom"===t.my[1]?t.elemHeight:0,f="top"===t.at[1]?t.targetHeight:"bottom"===t.at[1]?-t.targetHeight:0,m=-2*t.offset[1];0>u?(s=e.top+p+f+m+t.collisionHeight-o-a,(0>s||r(u)>s)&&(e.top+=p+f+m)):d>0&&(i=e.top-t.collisionPosition.marginTop+p+f+m-h,(i>0||d>r(i))&&(e.top+=p+f+m))}},flipfit:{left:function(){e.ui.position.flip.left.apply(this,arguments),e.ui.position.fit.left.apply(this,arguments)},top:function(){e.ui.position.flip.top.apply(this,arguments),e.ui.position.fit.top.apply(this,arguments)}}},function(){var t,i,s,n,o,r=document.getElementsByTagName("body")[0],h=document.createElement("div");t=document.createElement(r?"div":"body"),s={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},r&&e.extend(s,{position:"absolute",left:"-1000px",top:"-1000px"});for(o in s)t.style[o]=s[o];t.appendChild(h),i=r||document.documentElement,i.insertBefore(t,i.firstChild),h.style.cssText="position: absolute; left: 10.7432222px;",n=e(h).offset().left,a=n>10&&11>n,t.innerHTML="",i.removeChild(t)}()}(),e.ui.position,e.widget("ui.accordion",{version:"1.11.4",options:{active:0,animate:{},collapsible:!1,event:"click",header:"> li > :first-child,> :not(li):even",heightStyle:"auto",icons:{activeHeader:"ui-icon-triangle-1-s",header:"ui-icon-triangle-1-e"},activate:null,beforeActivate:null},hideProps:{borderTopWidth:"hide",borderBottomWidth:"hide",paddingTop:"hide",paddingBottom:"hide",height:"hide"},showProps:{borderTopWidth:"show",borderBottomWidth:"show",paddingTop:"show",paddingBottom:"show",height:"show"},_create:function(){var t=this.options;this.prevShow=this.prevHide=e(),this.element.addClass("ui-accordion ui-widget ui-helper-reset").attr("role","tablist"),t.collapsible||t.active!==!1&&null!=t.active||(t.active=0),this._processPanels(),0>t.active&&(t.active+=this.headers.length),this._refresh()},_getCreateEventData:function(){return{header:this.active,panel:this.active.length?this.active.next():e()}},_createIcons:function(){var t=this.options.icons;t&&(e("").addClass("ui-accordion-header-icon ui-icon "+t.header).prependTo(this.headers),this.active.children(".ui-accordion-header-icon").removeClass(t.header).addClass(t.activeHeader),this.headers.addClass("ui-accordion-icons"))},_destroyIcons:function(){this.headers.removeClass("ui-accordion-icons").children(".ui-accordion-header-icon").remove()},_destroy:function(){var e;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role"),this.headers.removeClass("ui-accordion-header ui-accordion-header-active ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("aria-controls").removeAttr("tabIndex").removeUniqueId(),this._destroyIcons(),e=this.headers.next().removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled").css("display","").removeAttr("role").removeAttr("aria-hidden").removeAttr("aria-labelledby").removeUniqueId(),"content"!==this.options.heightStyle&&e.css("height","")},_setOption:function(e,t){return"active"===e?(this._activate(t),void 0):("event"===e&&(this.options.event&&this._off(this.headers,this.options.event),this._setupEvents(t)),this._super(e,t),"collapsible"!==e||t||this.options.active!==!1||this._activate(0),"icons"===e&&(this._destroyIcons(),t&&this._createIcons()),"disabled"===e&&(this.element.toggleClass("ui-state-disabled",!!t).attr("aria-disabled",t),this.headers.add(this.headers.next()).toggleClass("ui-state-disabled",!!t)),void 0)},_keydown:function(t){if(!t.altKey&&!t.ctrlKey){var i=e.ui.keyCode,s=this.headers.length,n=this.headers.index(t.target),a=!1;switch(t.keyCode){case i.RIGHT:case i.DOWN:a=this.headers[(n+1)%s];break;case i.LEFT:case i.UP:a=this.headers[(n-1+s)%s];break;case i.SPACE:case i.ENTER:this._eventHandler(t);break;case i.HOME:a=this.headers[0];break;case i.END:a=this.headers[s-1]}a&&(e(t.target).attr("tabIndex",-1),e(a).attr("tabIndex",0),a.focus(),t.preventDefault())}},_panelKeyDown:function(t){t.keyCode===e.ui.keyCode.UP&&t.ctrlKey&&e(t.currentTarget).prev().focus()},refresh:function(){var t=this.options;this._processPanels(),t.active===!1&&t.collapsible===!0||!this.headers.length?(t.active=!1,this.active=e()):t.active===!1?this._activate(0):this.active.length&&!e.contains(this.element[0],this.active[0])?this.headers.length===this.headers.find(".ui-state-disabled").length?(t.active=!1,this.active=e()):this._activate(Math.max(0,t.active-1)):t.active=this.headers.index(this.active),this._destroyIcons(),this._refresh()},_processPanels:function(){var e=this.headers,t=this.panels;this.headers=this.element.find(this.options.header).addClass("ui-accordion-header ui-state-default ui-corner-all"),this.panels=this.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom").filter(":not(.ui-accordion-content-active)").hide(),t&&(this._off(e.not(this.headers)),this._off(t.not(this.panels)))},_refresh:function(){var t,i=this.options,s=i.heightStyle,n=this.element.parent();this.active=this._findActive(i.active).addClass("ui-accordion-header-active ui-state-active ui-corner-top").removeClass("ui-corner-all"),this.active.next().addClass("ui-accordion-content-active").show(),this.headers.attr("role","tab").each(function(){var t=e(this),i=t.uniqueId().attr("id"),s=t.next(),n=s.uniqueId().attr("id");t.attr("aria-controls",n),s.attr("aria-labelledby",i)}).next().attr("role","tabpanel"),this.headers.not(this.active).attr({"aria-selected":"false","aria-expanded":"false",tabIndex:-1}).next().attr({"aria-hidden":"true"}).hide(),this.active.length?this.active.attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0}).next().attr({"aria-hidden":"false"}):this.headers.eq(0).attr("tabIndex",0),this._createIcons(),this._setupEvents(i.event),"fill"===s?(t=n.height(),this.element.siblings(":visible").each(function(){var i=e(this),s=i.css("position");"absolute"!==s&&"fixed"!==s&&(t-=i.outerHeight(!0))}),this.headers.each(function(){t-=e(this).outerHeight(!0)}),this.headers.next().each(function(){e(this).height(Math.max(0,t-e(this).innerHeight()+e(this).height()))}).css("overflow","auto")):"auto"===s&&(t=0,this.headers.next().each(function(){t=Math.max(t,e(this).css("height","").height())}).height(t))},_activate:function(t){var i=this._findActive(t)[0];i!==this.active[0]&&(i=i||this.active[0],this._eventHandler({target:i,currentTarget:i,preventDefault:e.noop}))},_findActive:function(t){return"number"==typeof t?this.headers.eq(t):e()},_setupEvents:function(t){var i={keydown:"_keydown"};t&&e.each(t.split(" "),function(e,t){i[t]="_eventHandler"}),this._off(this.headers.add(this.headers.next())),this._on(this.headers,i),this._on(this.headers.next(),{keydown:"_panelKeyDown"}),this._hoverable(this.headers),this._focusable(this.headers)},_eventHandler:function(t){var i=this.options,s=this.active,n=e(t.currentTarget),a=n[0]===s[0],o=a&&i.collapsible,r=o?e():n.next(),h=s.next(),l={oldHeader:s,oldPanel:h,newHeader:o?e():n,newPanel:r};t.preventDefault(),a&&!i.collapsible||this._trigger("beforeActivate",t,l)===!1||(i.active=o?!1:this.headers.index(n),this.active=a?e():n,this._toggle(l),s.removeClass("ui-accordion-header-active ui-state-active"),i.icons&&s.children(".ui-accordion-header-icon").removeClass(i.icons.activeHeader).addClass(i.icons.header),a||(n.removeClass("ui-corner-all").addClass("ui-accordion-header-active ui-state-active ui-corner-top"),i.icons&&n.children(".ui-accordion-header-icon").removeClass(i.icons.header).addClass(i.icons.activeHeader),n.next().addClass("ui-accordion-content-active")))},_toggle:function(t){var i=t.newPanel,s=this.prevShow.length?this.prevShow:t.oldPanel;this.prevShow.add(this.prevHide).stop(!0,!0),this.prevShow=i,this.prevHide=s,this.options.animate?this._animate(i,s,t):(s.hide(),i.show(),this._toggleComplete(t)),s.attr({"aria-hidden":"true"}),s.prev().attr({"aria-selected":"false","aria-expanded":"false"}),i.length&&s.length?s.prev().attr({tabIndex:-1,"aria-expanded":"false"}):i.length&&this.headers.filter(function(){return 0===parseInt(e(this).attr("tabIndex"),10)}).attr("tabIndex",-1),i.attr("aria-hidden","false").prev().attr({"aria-selected":"true","aria-expanded":"true",tabIndex:0})},_animate:function(e,t,i){var s,n,a,o=this,r=0,h=e.css("box-sizing"),l=e.length&&(!t.length||e.index()",delay:300,options:{icons:{submenu:"ui-icon-carat-1-e"},items:"> *",menus:"ul",position:{my:"left-1 top",at:"right top"},role:"menu",blur:null,focus:null,select:null},_create:function(){this.activeMenu=this.element,this.mouseHandled=!1,this.element.uniqueId().addClass("ui-menu ui-widget ui-widget-content").toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length).attr({role:this.options.role,tabIndex:0}),this.options.disabled&&this.element.addClass("ui-state-disabled").attr("aria-disabled","true"),this._on({"mousedown .ui-menu-item":function(e){e.preventDefault()},"click .ui-menu-item":function(t){var i=e(t.target);!this.mouseHandled&&i.not(".ui-state-disabled").length&&(this.select(t),t.isPropagationStopped()||(this.mouseHandled=!0),i.has(".ui-menu").length?this.expand(t):!this.element.is(":focus")&&e(this.document[0].activeElement).closest(".ui-menu").length&&(this.element.trigger("focus",[!0]),this.active&&1===this.active.parents(".ui-menu").length&&clearTimeout(this.timer)))},"mouseenter .ui-menu-item":function(t){if(!this.previousFilter){var i=e(t.currentTarget); -i.siblings(".ui-state-active").removeClass("ui-state-active"),this.focus(t,i)}},mouseleave:"collapseAll","mouseleave .ui-menu":"collapseAll",focus:function(e,t){var i=this.active||this.element.find(this.options.items).eq(0);t||this.focus(e,i)},blur:function(t){this._delay(function(){e.contains(this.element[0],this.document[0].activeElement)||this.collapseAll(t)})},keydown:"_keydown"}),this.refresh(),this._on(this.document,{click:function(e){this._closeOnDocumentClick(e)&&this.collapseAll(e),this.mouseHandled=!1}})},_destroy:function(){this.element.removeAttr("aria-activedescendant").find(".ui-menu").addBack().removeClass("ui-menu ui-widget ui-widget-content ui-menu-icons ui-front").removeAttr("role").removeAttr("tabIndex").removeAttr("aria-labelledby").removeAttr("aria-expanded").removeAttr("aria-hidden").removeAttr("aria-disabled").removeUniqueId().show(),this.element.find(".ui-menu-item").removeClass("ui-menu-item").removeAttr("role").removeAttr("aria-disabled").removeUniqueId().removeClass("ui-state-hover").removeAttr("tabIndex").removeAttr("role").removeAttr("aria-haspopup").children().each(function(){var t=e(this);t.data("ui-menu-submenu-carat")&&t.remove()}),this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content")},_keydown:function(t){var i,s,n,a,o=!0;switch(t.keyCode){case e.ui.keyCode.PAGE_UP:this.previousPage(t);break;case e.ui.keyCode.PAGE_DOWN:this.nextPage(t);break;case e.ui.keyCode.HOME:this._move("first","first",t);break;case e.ui.keyCode.END:this._move("last","last",t);break;case e.ui.keyCode.UP:this.previous(t);break;case e.ui.keyCode.DOWN:this.next(t);break;case e.ui.keyCode.LEFT:this.collapse(t);break;case e.ui.keyCode.RIGHT:this.active&&!this.active.is(".ui-state-disabled")&&this.expand(t);break;case e.ui.keyCode.ENTER:case e.ui.keyCode.SPACE:this._activate(t);break;case e.ui.keyCode.ESCAPE:this.collapse(t);break;default:o=!1,s=this.previousFilter||"",n=String.fromCharCode(t.keyCode),a=!1,clearTimeout(this.filterTimer),n===s?a=!0:n=s+n,i=this._filterMenuItems(n),i=a&&-1!==i.index(this.active.next())?this.active.nextAll(".ui-menu-item"):i,i.length||(n=String.fromCharCode(t.keyCode),i=this._filterMenuItems(n)),i.length?(this.focus(t,i),this.previousFilter=n,this.filterTimer=this._delay(function(){delete this.previousFilter},1e3)):delete this.previousFilter}o&&t.preventDefault()},_activate:function(e){this.active.is(".ui-state-disabled")||(this.active.is("[aria-haspopup='true']")?this.expand(e):this.select(e))},refresh:function(){var t,i,s=this,n=this.options.icons.submenu,a=this.element.find(this.options.menus);this.element.toggleClass("ui-menu-icons",!!this.element.find(".ui-icon").length),a.filter(":not(.ui-menu)").addClass("ui-menu ui-widget ui-widget-content ui-front").hide().attr({role:this.options.role,"aria-hidden":"true","aria-expanded":"false"}).each(function(){var t=e(this),i=t.parent(),s=e("").addClass("ui-menu-icon ui-icon "+n).data("ui-menu-submenu-carat",!0);i.attr("aria-haspopup","true").prepend(s),t.attr("aria-labelledby",i.attr("id"))}),t=a.add(this.element),i=t.find(this.options.items),i.not(".ui-menu-item").each(function(){var t=e(this);s._isDivider(t)&&t.addClass("ui-widget-content ui-menu-divider")}),i.not(".ui-menu-item, .ui-menu-divider").addClass("ui-menu-item").uniqueId().attr({tabIndex:-1,role:this._itemRole()}),i.filter(".ui-state-disabled").attr("aria-disabled","true"),this.active&&!e.contains(this.element[0],this.active[0])&&this.blur()},_itemRole:function(){return{menu:"menuitem",listbox:"option"}[this.options.role]},_setOption:function(e,t){"icons"===e&&this.element.find(".ui-menu-icon").removeClass(this.options.icons.submenu).addClass(t.submenu),"disabled"===e&&this.element.toggleClass("ui-state-disabled",!!t).attr("aria-disabled",t),this._super(e,t)},focus:function(e,t){var i,s;this.blur(e,e&&"focus"===e.type),this._scrollIntoView(t),this.active=t.first(),s=this.active.addClass("ui-state-focus").removeClass("ui-state-active"),this.options.role&&this.element.attr("aria-activedescendant",s.attr("id")),this.active.parent().closest(".ui-menu-item").addClass("ui-state-active"),e&&"keydown"===e.type?this._close():this.timer=this._delay(function(){this._close()},this.delay),i=t.children(".ui-menu"),i.length&&e&&/^mouse/.test(e.type)&&this._startOpening(i),this.activeMenu=t.parent(),this._trigger("focus",e,{item:t})},_scrollIntoView:function(t){var i,s,n,a,o,r;this._hasScroll()&&(i=parseFloat(e.css(this.activeMenu[0],"borderTopWidth"))||0,s=parseFloat(e.css(this.activeMenu[0],"paddingTop"))||0,n=t.offset().top-this.activeMenu.offset().top-i-s,a=this.activeMenu.scrollTop(),o=this.activeMenu.height(),r=t.outerHeight(),0>n?this.activeMenu.scrollTop(a+n):n+r>o&&this.activeMenu.scrollTop(a+n-o+r))},blur:function(e,t){t||clearTimeout(this.timer),this.active&&(this.active.removeClass("ui-state-focus"),this.active=null,this._trigger("blur",e,{item:this.active}))},_startOpening:function(e){clearTimeout(this.timer),"true"===e.attr("aria-hidden")&&(this.timer=this._delay(function(){this._close(),this._open(e)},this.delay))},_open:function(t){var i=e.extend({of:this.active},this.options.position);clearTimeout(this.timer),this.element.find(".ui-menu").not(t.parents(".ui-menu")).hide().attr("aria-hidden","true"),t.show().removeAttr("aria-hidden").attr("aria-expanded","true").position(i)},collapseAll:function(t,i){clearTimeout(this.timer),this.timer=this._delay(function(){var s=i?this.element:e(t&&t.target).closest(this.element.find(".ui-menu"));s.length||(s=this.element),this._close(s),this.blur(t),this.activeMenu=s},this.delay)},_close:function(e){e||(e=this.active?this.active.parent():this.element),e.find(".ui-menu").hide().attr("aria-hidden","true").attr("aria-expanded","false").end().find(".ui-state-active").not(".ui-state-focus").removeClass("ui-state-active")},_closeOnDocumentClick:function(t){return!e(t.target).closest(".ui-menu").length},_isDivider:function(e){return!/[^\-\u2014\u2013\s]/.test(e.text())},collapse:function(e){var t=this.active&&this.active.parent().closest(".ui-menu-item",this.element);t&&t.length&&(this._close(),this.focus(e,t))},expand:function(e){var t=this.active&&this.active.children(".ui-menu ").find(this.options.items).first();t&&t.length&&(this._open(t.parent()),this._delay(function(){this.focus(e,t)}))},next:function(e){this._move("next","first",e)},previous:function(e){this._move("prev","last",e)},isFirstItem:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},isLastItem:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},_move:function(e,t,i){var s;this.active&&(s="first"===e||"last"===e?this.active["first"===e?"prevAll":"nextAll"](".ui-menu-item").eq(-1):this.active[e+"All"](".ui-menu-item").eq(0)),s&&s.length&&this.active||(s=this.activeMenu.find(this.options.items)[t]()),this.focus(i,s)},nextPage:function(t){var i,s,n;return this.active?(this.isLastItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.nextAll(".ui-menu-item").each(function(){return i=e(this),0>i.offset().top-s-n}),this.focus(t,i)):this.focus(t,this.activeMenu.find(this.options.items)[this.active?"last":"first"]())),void 0):(this.next(t),void 0)},previousPage:function(t){var i,s,n;return this.active?(this.isFirstItem()||(this._hasScroll()?(s=this.active.offset().top,n=this.element.height(),this.active.prevAll(".ui-menu-item").each(function(){return i=e(this),i.offset().top-s+n>0}),this.focus(t,i)):this.focus(t,this.activeMenu.find(this.options.items).first())),void 0):(this.next(t),void 0)},_hasScroll:function(){return this.element.outerHeight()",options:{appendTo:null,autoFocus:!1,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null,change:null,close:null,focus:null,open:null,response:null,search:null,select:null},requestIndex:0,pending:0,_create:function(){var t,i,s,n=this.element[0].nodeName.toLowerCase(),a="textarea"===n,o="input"===n;this.isMultiLine=a?!0:o?!1:this.element.prop("isContentEditable"),this.valueMethod=this.element[a||o?"val":"text"],this.isNewMenu=!0,this.element.addClass("ui-autocomplete-input").attr("autocomplete","off"),this._on(this.element,{keydown:function(n){if(this.element.prop("readOnly"))return t=!0,s=!0,i=!0,void 0;t=!1,s=!1,i=!1;var a=e.ui.keyCode;switch(n.keyCode){case a.PAGE_UP:t=!0,this._move("previousPage",n);break;case a.PAGE_DOWN:t=!0,this._move("nextPage",n);break;case a.UP:t=!0,this._keyEvent("previous",n);break;case a.DOWN:t=!0,this._keyEvent("next",n);break;case a.ENTER:this.menu.active&&(t=!0,n.preventDefault(),this.menu.select(n));break;case a.TAB:this.menu.active&&this.menu.select(n);break;case a.ESCAPE:this.menu.element.is(":visible")&&(this.isMultiLine||this._value(this.term),this.close(n),n.preventDefault());break;default:i=!0,this._searchTimeout(n)}},keypress:function(s){if(t)return t=!1,(!this.isMultiLine||this.menu.element.is(":visible"))&&s.preventDefault(),void 0;if(!i){var n=e.ui.keyCode;switch(s.keyCode){case n.PAGE_UP:this._move("previousPage",s);break;case n.PAGE_DOWN:this._move("nextPage",s);break;case n.UP:this._keyEvent("previous",s);break;case n.DOWN:this._keyEvent("next",s)}}},input:function(e){return s?(s=!1,e.preventDefault(),void 0):(this._searchTimeout(e),void 0)},focus:function(){this.selectedItem=null,this.previous=this._value()},blur:function(e){return this.cancelBlur?(delete this.cancelBlur,void 0):(clearTimeout(this.searching),this.close(e),this._change(e),void 0)}}),this._initSource(),this.menu=e("