diff --git a/cim_for_netty/cim-android-sdk/.classpath b/cim_for_netty/cim-android-sdk/.classpath index 2af04b4..cf06537 100644 --- a/cim_for_netty/cim-android-sdk/.classpath +++ b/cim_for_netty/cim-android-sdk/.classpath @@ -9,6 +9,6 @@ - + diff --git a/cim_for_netty/cim-boot-server/.classpath b/cim_for_netty/cim-boot-server/.classpath new file mode 100644 index 0000000..6c81e95 --- /dev/null +++ b/cim_for_netty/cim-boot-server/.classpath @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/cim_for_netty/cim-boot-server/.gitignore b/cim_for_netty/cim-boot-server/.gitignore new file mode 100644 index 0000000..da88288 --- /dev/null +++ b/cim_for_netty/cim-boot-server/.gitignore @@ -0,0 +1 @@ +/.gradle/ diff --git a/cim_for_netty/cim-boot-server/.project b/cim_for_netty/cim-boot-server/.project new file mode 100644 index 0000000..2766f46 --- /dev/null +++ b/cim_for_netty/cim-boot-server/.project @@ -0,0 +1,23 @@ + + + cim-boot-server + Project cim-boot-server created by Buildship. + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.buildship.core.gradleprojectbuilder + + + + + + 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 new file mode 100644 index 0000000..e889521 --- /dev/null +++ b/cim_for_netty/cim-boot-server/.settings/org.eclipse.buildship.core.prefs @@ -0,0 +1,2 @@ +connection.project.dir= +eclipse.preferences.version=1 diff --git a/cim_for_netty/cim-boot-server/build.gradle b/cim_for_netty/cim-boot-server/build.gradle new file mode 100644 index 0000000..02fb348 --- /dev/null +++ b/cim_for_netty/cim-boot-server/build.gradle @@ -0,0 +1,63 @@ +buildscript { + repositories { + jcenter() + } + dependencies { + classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.4.RELEASE") + } +} + +apply plugin: 'java' +apply plugin: 'org.springframework.boot' + +//生成的jar包包名和版本 +jar { + baseName = 'lvxin-server' + version = '1.0.0' +} + +repositories { + jcenter() + maven { + url 'https://repo.spring.io/libs-milestone' + } +} +configurations { + //all*.exclude group: 'com.fasterxml.jackson.core' , module: 'jackson-databind' + all*.exclude group: 'com.fasterxml.jackson.datatype' + all*.exclude group: 'com.fasterxml.jackson.module' + + all*.exclude group: 'org.yaml' + all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat' + all*.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-jdbc' + + all*.exclude group: 'org.apache.tomcat' + all*.exclude group: 'io.undertow', module: 'undertow-websockets-jsr' + all*.exclude group: 'org.jboss.spec.javax.websocket' + all*.exclude group: 'org.jboss.spec.javax.transaction' + all*.exclude group: 'org.glassfish' + +} +dependencies { + compile fileTree(dir: 'libs', include: '*.jar') + compile 'org.springframework.boot:spring-boot-starter-web:2.0.4.RELEASE' + compile 'org.springframework.boot:spring-boot-starter-undertow:2.0.4.RELEASE' + compile 'org.springframework.boot:spring-boot-starter-freemarker:2.0.4.RELEASE' + compile 'com.google.protobuf:protobuf-java:3.6.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.28.Final' + compile 'io.netty:netty-buffer:4.1.28.Final' + compile 'io.netty:netty-codec:4.1.28.Final' + compile 'io.netty:netty-codec-http:4.1.28.Final' + compile 'io.netty:netty-common:4.1.28.Final' + compile 'io.netty:netty-transport:4.1.28.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 new file mode 100644 index 0000000..a5fe1cb Binary files /dev/null and b/cim_for_netty/cim-boot-server/gradle/wrapper/gradle-wrapper.jar 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 new file mode 100644 index 0000000..be280be --- /dev/null +++ b/cim_for_netty/cim-boot-server/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +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 new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/cim_for_netty/cim-boot-server/gradlew @@ -0,0 +1,172 @@ +#!/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 new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/cim_for_netty/cim-boot-server/gradlew.bat @@ -0,0 +1,84 @@ +@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 new file mode 100644 index 0000000..0b2b2dc --- /dev/null +++ b/cim_for_netty/cim-boot-server/settings.gradle @@ -0,0 +1,10 @@ +/* + * 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 new file mode 100644 index 0000000..77610ca --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/CIMConfig.java @@ -0,0 +1,64 @@ +package com.farsunset.cim; + +import java.io.IOException; +import java.util.HashMap; + +import javax.annotation.PostConstruct; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +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.session.CIMSession; + +@Configuration +public class CIMConfig implements CIMRequestHandler { + @Value("${cim.server.port}") + private int port; + + @Autowired + private BindHandler bindHandler; + @Autowired + private SessionClosedHandler closedHandler; + + private HashMap appHandlerMap = new HashMap<>(); + + @PostConstruct + private void initHandler() { + /* + * 账号绑定handler + */ + appHandlerMap.put("client_bind", bindHandler); + /* + * 连接关闭handler + */ + appHandlerMap.put("client_closed", closedHandler); + } + + @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 = appHandlerMap.get(body.getKey()); + + if(handler == null) {return ;} + + handler.process(session, body); + + } + +} \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/ServerLauncher.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/ServerLauncher.java new file mode 100644 index 0000000..a37e317 --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/ServerLauncher.java @@ -0,0 +1,79 @@ +/** + * Copyright 2013-2023 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; + +import java.lang.reflect.Modifier; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.boot.autoconfigure.jmx.JmxAutoConfiguration; +import org.springframework.boot.autoconfigure.validation.ValidationAutoConfiguration; +import org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAutoConfiguration; +import org.springframework.boot.autoconfigure.webservices.WebServicesAutoConfiguration; +import org.springframework.boot.autoconfigure.websocket.reactive.WebSocketReactiveAutoConfiguration; +import org.springframework.boot.autoconfigure.websocket.servlet.WebSocketMessagingAutoConfiguration; +import org.springframework.boot.autoconfigure.websocket.servlet.WebSocketServletAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.http.converter.json.GsonHttpMessageConverter; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; + +/** + * + * 其中@SpringBootApplication申明让spring boot自动给程序进行必要的配置, + * 等价于以默认属性使用@Configuration,@EnableAutoConfiguration和@ComponentScan + */ +@SpringBootApplication +@EnableAutoConfiguration(exclude = { WebSocketMessagingAutoConfiguration.class, + WebSocketReactiveAutoConfiguration.class, + WebSocketServletAutoConfiguration.class, + WebServicesAutoConfiguration.class, + JmxAutoConfiguration.class, + DataSourceAutoConfiguration.class, + ValidationAutoConfiguration.class, + WebClientAutoConfiguration.class, + JacksonAutoConfiguration.class }) + +public class ServerLauncher { + + public static void main(String[] args) { + SpringApplication.run(ServerLauncher.class, args); + } + + + @Bean + @ConditionalOnMissingBean + public GsonHttpMessageConverter gsonHttpMessageConverter(Gson gson) { + GsonHttpMessageConverter converter = new GsonHttpMessageConverter(); + gson = new GsonBuilder() + .excludeFieldsWithModifiers(Modifier.PROTECTED | Modifier.TRANSIENT | Modifier.FINAL | Modifier.STATIC) + .create(); + converter.setGson(gson); + return converter; + } + +} \ No newline at end of file diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/NavigationController.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/NavigationController.java new file mode 100644 index 0000000..1e28a5c --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/NavigationController.java @@ -0,0 +1,44 @@ +/** + * Copyright 2013-2033 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 org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.servlet.ModelAndView; + +@Controller +public class NavigationController { + + @RequestMapping(value = "/", method = RequestMethod.GET) + public ModelAndView index(ModelAndView model) { + model.setViewName("console/index"); + return model; + } + + @RequestMapping(value = "/webclient/main.action", method = RequestMethod.GET) + public ModelAndView webclient(ModelAndView model) { + model.setViewName("console/webclient/main"); + return model; + } + +} diff --git a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/admin/action/SessionAction.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/SessionController.java similarity index 63% rename from cim_for_netty/cim-server/src/main/java/com/farsunset/cim/admin/action/SessionAction.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/SessionController.java index 5f889bf..8c55f07 100644 --- a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/admin/action/SessionAction.java +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/admin/controller/SessionController.java @@ -19,34 +19,28 @@ * * *************************************************************************************** */ -package com.farsunset.cim.admin.action; +package com.farsunset.cim.admin.controller; -import java.io.IOException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.RequestMapping; -import org.apache.struts2.ServletActionContext; +import com.farsunset.cim.service.impl.CIMSessionServiceImpl; +@Controller +@RequestMapping("/console/session") +public class SessionController { -import com.farsunset.cim.push.SystemMessagePusher; -import com.farsunset.cim.sdk.server.constant.CIMConstant; -import com.farsunset.cim.sdk.server.model.Message; -import com.farsunset.cim.sdk.server.session.DefaultSessionManager; -import com.farsunset.cim.util.ContextHolder; -import com.opensymphony.xwork2.ActionSupport; - -public class SessionAction extends ActionSupport { - - /** - * - */ - private static final long serialVersionUID = 1L; - - public String list() { - ServletActionContext.getRequest().setAttribute("sessionList", - ((DefaultSessionManager) ContextHolder.getBean("CIMSessionManager")).queryAll()); - - return "list"; + @Autowired + private CIMSessionServiceImpl sessionManager; + + @RequestMapping(value = "/list.action") + public String list(Model model) { + model.addAttribute("sessionList", sessionManager.queryAll()); + return "console/session/manage"; } - public void offline() throws IOException { + /*public void offline() throws IOException { String account = ServletActionContext.getRequest().getParameter("account"); Message msg = new Message(); @@ -56,5 +50,5 @@ public class SessionAction extends ActionSupport { // 向客户端 发送消息 ContextHolder.getBean(SystemMessagePusher.class).push(msg); - } + }*/ } 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 new file mode 100644 index 0000000..eeaa570 --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/MessageController.java @@ -0,0 +1,78 @@ +/** + * Copyright 2013-2023 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 org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import com.farsunset.cim.api.controller.dto.MessageResult; +import com.farsunset.cim.push.DefaultMessagePusher; +import com.farsunset.cim.push.SystemMessagePusher; +import com.farsunset.cim.sdk.server.model.Message; +import com.farsunset.cim.util.Constants; +import com.farsunset.cim.util.StringUtil; + + +@RestController +@RequestMapping("/api/message") +public class MessageController { + + + + @Autowired + private SystemMessagePusher systemMessagePusher; + + @Autowired + 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.setMid(StringUtil.getUUID()); + if (Constants.MessageType.TYPE_2.equals(message.getAction())) { + systemMessagePusher.push(message); + } else { + defaultMessagePusher.push(message); + } + result.id = message.getMid(); + result.timestamp = message.getTimestamp(); + return result; + } + +} diff --git a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/HeartbeatHandler.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/BaseResult.java similarity index 65% rename from cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/HeartbeatHandler.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/BaseResult.java index 277c98a..bbff0bd 100644 --- a/cim_for_netty/cim-server-sdk/src/com/farsunset/cim/sdk/server/handler/HeartbeatHandler.java +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/BaseResult.java @@ -1,5 +1,5 @@ /** - * Copyright 2013-2023 Xia Jun(3979434@qq.com). + * Copyright 2013-2033 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. @@ -19,22 +19,16 @@ * * *************************************************************************************** */ -package com.farsunset.cim.sdk.server.handler; +package com.farsunset.cim.api.controller.dto; -import com.farsunset.cim.sdk.server.model.ReplyBody; -import com.farsunset.cim.sdk.server.model.SentBody; -import com.farsunset.cim.sdk.server.session.CIMSession; +import java.util.List; -/** - * 记录心跳实现 - * - */ -public class HeartbeatHandler implements CIMRequestHandler { +import org.springframework.http.HttpStatus; - public ReplyBody process(CIMSession session, SentBody message) { - // 收到心跳响应,设置心跳时间 - session.setHeartbeat(System.currentTimeMillis()); - return null; - } +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 new file mode 100644 index 0000000..574893b --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/api/controller/dto/MessageResult.java @@ -0,0 +1,27 @@ +/** + * Copyright 2013-2033 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 String id; +} diff --git a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/handler/BindHandler.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/handler/BindHandler.java similarity index 67% rename from cim_for_netty/cim-server/src/main/java/com/farsunset/cim/handler/BindHandler.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/handler/BindHandler.java index 9d9601f..065db5c 100644 --- a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/handler/BindHandler.java +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/handler/BindHandler.java @@ -21,32 +21,45 @@ */ package com.farsunset.cim.handler; -import java.net.InetAddress; -import org.apache.log4j.Logger; +import java.util.Objects; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; -import com.farsunset.cim.push.SystemMessagePusher; import com.farsunset.cim.sdk.server.constant.CIMConstant; import com.farsunset.cim.sdk.server.handler.CIMRequestHandler; import com.farsunset.cim.sdk.server.model.Message; import com.farsunset.cim.sdk.server.model.ReplyBody; import com.farsunset.cim.sdk.server.model.SentBody; import com.farsunset.cim.sdk.server.session.CIMSession; -import com.farsunset.cim.sdk.server.session.DefaultSessionManager; -import com.farsunset.cim.util.ContextHolder; +import com.farsunset.cim.service.impl.CIMSessionServiceImpl; import com.farsunset.cim.util.StringUtil; + /** * 账号绑定实现 * */ + +@Component public class BindHandler implements CIMRequestHandler { - protected final Logger logger = Logger.getLogger(BindHandler.class); + protected final Logger logger = LoggerFactory.getLogger(BindHandler.class); - public ReplyBody process(CIMSession newSession, SentBody message) { - DefaultSessionManager sessionManager = ((DefaultSessionManager) ContextHolder.getBean("CIMSessionManager")); + @Autowired + private CIMSessionServiceImpl sessionManager; + + @Value("${server.host}") + private String host; + + + public void process(CIMSession newSession, SentBody message) { ReplyBody reply = new ReplyBody(); + reply.setKey(message.getKey()); reply.setCode(CIMConstant.ReturnCode.CODE_200); try { @@ -54,13 +67,14 @@ public class BindHandler implements CIMRequestHandler { newSession.setGid(StringUtil.getUUID()); newSession.setAccount(account); newSession.setDeviceId(message.get("deviceId")); - newSession.setHost(InetAddress.getLocalHost().getHostAddress()); + newSession.setHost(host); newSession.setChannel(message.get("channel")); newSession.setDeviceModel(message.get("device")); newSession.setClientVersion(message.get("version")); newSession.setSystemVersion(message.get("osVersion")); newSession.setBindTime(System.currentTimeMillis()); newSession.setPackageName(message.get("packageName")); + /** * 由于客户端断线服务端可能会无法获知的情况,客户端重连时,需要关闭旧的连接 */ @@ -68,20 +82,13 @@ public class BindHandler implements CIMRequestHandler { // 如果是账号已经在另一台终端登录。则让另一个终端下线 - if (newSession.fromOtherDevice(oldSession)) { + if (oldSession != null && fromOtherDevice(newSession,oldSession) && oldSession.isConnected()) { sendForceOfflineMessage(oldSession, account, newSession.getDeviceModel()); } - // 如果是重复连接,则直接返回 - if (newSession.equals(oldSession)) { + // 第一次设置心跳时间为登录时间 + newSession.setBindTime(System.currentTimeMillis()); - oldSession.setStatus(CIMSession.STATUS_ENABLED); - sessionManager.update(oldSession); - reply.put("sid", oldSession.getGid()); - return reply; - } - - closeQuietly(oldSession); // 第一次设置心跳时间为登录时间 newSession.setBindTime(System.currentTimeMillis()); @@ -91,39 +98,32 @@ public class BindHandler implements CIMRequestHandler { } catch (Exception e) { reply.setCode(CIMConstant.ReturnCode.CODE_500); - e.printStackTrace(); + logger.error(e.getMessage()); } - logger.debug("bind :account:" + message.get("account") + "-----------------------------" + reply.getCode()); - reply.put("sid", newSession.getGid()); - return reply; + + newSession.write(reply); } + private boolean fromOtherDevice(CIMSession oldSession ,CIMSession newSession) { + + return !Objects.equals(oldSession.getDeviceId(), newSession.getDeviceId()); + } + private void sendForceOfflineMessage(CIMSession oldSession, String account, String deviceModel) { Message msg = new Message(); - msg.setMid(String.valueOf(System.currentTimeMillis())); msg.setAction(CIMConstant.MessageAction.ACTION_999);// 强行下线消息类型 msg.setReceiver(account); + msg.setSender("system"); msg.setContent(deviceModel); - - closeQuietly(oldSession, msg); - - ContextHolder.getBean(SystemMessagePusher.class).push(msg); - - } - - // 同一设备切换网络时关闭旧的连接 - private void closeQuietly(CIMSession oldSession) { - if (oldSession != null && oldSession.isConnected()) { - oldSession.removeAttribute(CIMConstant.SESSION_KEY); - oldSession.closeNow(); - } + msg.setMid(StringUtil.getUUID()); + closeQuietly(oldSession,msg); } // 不同设备同一账号登录时关闭旧的连接 - private void closeQuietly(CIMSession oldSession, Message msg) { - if (oldSession.isConnected()) { + private void closeQuietly(CIMSession oldSession,Message msg) { + if (oldSession.isConnected() && Objects.equals(host, oldSession.getHost())) { oldSession.write(msg); oldSession.removeAttribute(CIMConstant.SESSION_KEY); oldSession.closeNow(); diff --git a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/handler/SessionClosedHandler.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/handler/SessionClosedHandler.java similarity index 77% rename from cim_for_netty/cim-server/src/main/java/com/farsunset/cim/handler/SessionClosedHandler.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/handler/SessionClosedHandler.java index f7dba73..981667c 100644 --- a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/handler/SessionClosedHandler.java +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/handler/SessionClosedHandler.java @@ -21,36 +21,41 @@ */ package com.farsunset.cim.handler; -import org.apache.log4j.Logger; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; import com.farsunset.cim.sdk.server.constant.CIMConstant; import com.farsunset.cim.sdk.server.handler.CIMRequestHandler; -import com.farsunset.cim.sdk.server.model.ReplyBody; import com.farsunset.cim.sdk.server.model.SentBody; import com.farsunset.cim.sdk.server.session.CIMSession; -import com.farsunset.cim.sdk.server.session.DefaultSessionManager; -import com.farsunset.cim.util.ContextHolder; +import com.farsunset.cim.service.impl.CIMSessionServiceImpl; + /** * 断开连接,清除session * */ + +@Component public class SessionClosedHandler implements CIMRequestHandler { - protected final Logger logger = Logger.getLogger(SessionClosedHandler.class); + protected final Logger logger = LoggerFactory.getLogger(SessionClosedHandler.class); - public ReplyBody process(CIMSession ios, SentBody message) { + @Autowired + private CIMSessionServiceImpl sessionManager; + + public void process(CIMSession ios, SentBody message) { Object account = ios.getAttribute(CIMConstant.SESSION_KEY); if (account == null) { - return null; + return; } - DefaultSessionManager sessionManager = ((DefaultSessionManager) ContextHolder.getBean("CIMSessionManager")); ios.removeAttribute(CIMConstant.SESSION_KEY); sessionManager.remove(account.toString()); - - return null; } } diff --git a/cim_for_netty/cim-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 similarity index 100% rename from cim_for_netty/cim-server/src/main/java/com/farsunset/cim/push/CIMMessagePusher.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/CIMMessagePusher.java diff --git a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/push/DefaultMessagePusher.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/DefaultMessagePusher.java similarity index 56% rename from cim_for_netty/cim-server/src/main/java/com/farsunset/cim/push/DefaultMessagePusher.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/DefaultMessagePusher.java index a8ffa89..9e011bb 100644 --- a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/push/DefaultMessagePusher.java +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/DefaultMessagePusher.java @@ -21,70 +21,70 @@ */ package com.farsunset.cim.push; +import java.util.Objects; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + import com.farsunset.cim.sdk.server.model.Message; import com.farsunset.cim.sdk.server.session.CIMSession; import com.farsunset.cim.sdk.server.session.DefaultSessionManager; +import com.farsunset.cim.service.ApnsService; +import com.farsunset.cim.service.impl.MessageDispatcherImpl; /** * 消息发送实现类 * */ +@Component public class DefaultMessagePusher implements CIMMessagePusher { + @Value("${server.host}") + private String host; + + @Autowired private DefaultSessionManager sessionManager; + + @Autowired + private MessageDispatcherImpl messageDispatcher; + - public void setSessionManager(DefaultSessionManager sessionManager) { - this.sessionManager = sessionManager; - } - + @Autowired + private ApnsService apnsService; + + /** * 向用户发送消息 * * @param msg */ - public void push(Message msg) { - CIMSession session = sessionManager.get(msg.getReceiver()); + public void push(Message message) { + CIMSession session = sessionManager.get(message.getReceiver()); - /* + /** * 服务器集群时,可以在此 判断当前session是否连接于本台服务器,如果是,继续往下走,如果不是,将此消息发往当前session连接的服务器并 - * return if(session!=null&&!session.isLocalhost()){//判断当前session是否连接于本台服务器,如不是 - * //发往目标服务器处理 - * MessageDispatcher.execute(MessageUtil.transform(msg),session.getHost()); - * return; } */ - - if (session != null && session.isConnected()) { - - session.write(msg); + if (session.isConnected() && !Objects.equals(host, session.getHost())) { + messageDispatcher.forward(message, session.getHost()); return; } - // 如果用户标示了APNS ON 说明这是ios设备需要使用apns发送 - if (session != null && session.getApnsAble() == CIMSession.APNS_ON) { - - apnsPush(1, msg.getContent(), session.getDeviceId()); + /** + * 如果是在当前服务器则直接推送 + */ + if (session.isConnected() && Objects.equals(host, session.getHost())) { + session.write(message); + return; + } + + /** + * ios设备流程特别处理,如果长链接断开了,并且ApnsAble为打开状态的话优走apns + */ + if (Objects.equals(session.getChannel(), CIMSession.CHANNEL_IOS) && Objects.equals(session.getApnsAble(), CIMSession.APNS_ON)) { + apnsService.push(message, session.getDeviceId()); } } - /** - * 引入javaapns相关jar - * - * @param badge - * @param content - * @param token - */ - private void apnsPush(int badge, String content, String token) { - /* - * String password = "password"; String keystore = "p12 文件 绝对路径"; boolean - * isDebug = true; - * - * PushNotificationPayload payload = PushNotificationPayload.complex(); try { - * payload.addAlert(content); payload.addBadge(1); payload.addSound("default"); - * Push.payload(payload, keystore, password, isDebug, token); - * - * } catch (Exception e) { e.printStackTrace(); } - */ - } - } diff --git a/cim_for_netty/cim-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 similarity index 95% rename from cim_for_netty/cim-server/src/main/java/com/farsunset/cim/push/SystemMessagePusher.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/push/SystemMessagePusher.java index 012a790..454edd7 100644 --- a/cim_for_netty/cim-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 @@ -21,8 +21,11 @@ */ 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 diff --git a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/util/ContextHolder.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/ApnsService.java similarity index 60% rename from cim_for_netty/cim-server/src/main/java/com/farsunset/cim/util/ContextHolder.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/ApnsService.java index 3b29a5a..5acae95 100644 --- a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/util/ContextHolder.java +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/ApnsService.java @@ -1,5 +1,5 @@ /** - * Copyright 2013-2023 Xia Jun(3979434@qq.com). + * Copyright 2013-2033 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. @@ -19,27 +19,11 @@ * * *************************************************************************************** */ -package com.farsunset.cim.util; +package com.farsunset.cim.service; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; +import com.farsunset.cim.sdk.server.model.Message; -public class ContextHolder implements ApplicationContextAware { +public interface ApnsService { - private static ApplicationContext context; - - public static Object getBean(String name) { - return context.getBean(name); - } - - public static T getBean(Class c) { - - return context.getBean(c); - } - - @Override - public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - context = applicationContext; - } + void push( Message message, String deviceToken); } diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/MessageDispatcher.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/MessageDispatcher.java new file mode 100644 index 0000000..7532496 --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/MessageDispatcher.java @@ -0,0 +1,28 @@ +/** + * Copyright 2013-2033 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 com.farsunset.cim.sdk.server.model.Message; + +public interface MessageDispatcher { + void forward(final Message msg, final String ip); +} diff --git a/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/CIMSessionServiceImpl.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/CIMSessionServiceImpl.java new file mode 100644 index 0000000..6ccaaac --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/CIMSessionServiceImpl.java @@ -0,0 +1,31 @@ +/** + * Copyright 2013-2033 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 org.springframework.stereotype.Service; + +import com.farsunset.cim.sdk.server.session.DefaultSessionManager; + +@Service +public class CIMSessionServiceImpl extends DefaultSessionManager { + +} 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 new file mode 100644 index 0000000..9be0173 --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/JavaApnsServiceImpl.java @@ -0,0 +1,86 @@ +/** + * Copyright 2013-2033 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/service/impl/MessageDispatcherImpl.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/MessageDispatcherImpl.java new file mode 100644 index 0000000..a60ae1b --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/service/impl/MessageDispatcherImpl.java @@ -0,0 +1,83 @@ +/** + * Copyright 2013-2023 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.concurrent.TimeUnit; +import java.util.logging.Logger; + +import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +import com.farsunset.cim.sdk.server.model.Message; +import com.farsunset.cim.service.MessageDispatcher; + +import okhttp3.FormBody; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; + +@Component +public class MessageDispatcherImpl implements MessageDispatcher{ + + private static final Logger logger = Logger.getLogger(MessageDispatcherImpl.class.getName()); + + @Value("${sys.message.dispatch.url}") + private String dispatchUrl; + + @Override + public void forward(final Message msg, final String ip) { + String apiUrl = String.format(dispatchUrl, ip); + try { + String response = httpPost(apiUrl, msg); + logger.info("消息转发目标服务器{" + ip + "},结果:" + response); + } catch (Exception e) { + e.printStackTrace(); + logger.severe("消息转发目标服务器" + apiUrl + "message:" + e.getMessage()); + } + } + + @SuppressWarnings("deprecation") + private String httpPost(String url, Message msg) throws Exception { + + OkHttpClient httpclient = new OkHttpClient.Builder().connectTimeout(10, TimeUnit.SECONDS).build(); + FormBody.Builder build = new FormBody.Builder(); + + build.add("mid", String.valueOf(msg.getMid())); + build.add("action", msg.getAction()); + build.add("title", msg.getTitle()); + build.add("content", msg.getContent()); + build.add("sender", msg.getSender()); + build.add("receiver", msg.getReceiver()); + build.add("format", msg.getFormat()); + build.add("extra", msg.getExtra()); + build.add("timestamp", String.valueOf(msg.getTimestamp())); + Request request = new Request.Builder().url(url).post(build.build()).build(); + + Response response = httpclient.newCall(request).execute(); + String data = response.body().string(); + IOUtils.closeQuietly(response); + return data; + } + + +} diff --git a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/session/ClusterSessionManager.java b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/session/ClusterSessionManager.java similarity index 97% rename from cim_for_netty/cim-server/src/main/java/com/farsunset/cim/session/ClusterSessionManager.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/session/ClusterSessionManager.java index 286b6ca..d0e5cdc 100644 --- a/cim_for_netty/cim-server/src/main/java/com/farsunset/cim/session/ClusterSessionManager.java +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/session/ClusterSessionManager.java @@ -1,65 +1,65 @@ -/** - * Copyright 2013-2023 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.session; - -import java.util.List; -import com.farsunset.cim.sdk.server.session.CIMSession; -import com.farsunset.cim.sdk.server.session.SessionManager; - -/** - * 集群 session管理实现示例, 各位可以自行实现 AbstractSessionManager接口来实现自己的 session管理 服务器集群时 - * 须要将CIMSession 信息存入数据库或者nosql 等 第三方存储空间中,便于所有服务器都可以访问 - */ -public class ClusterSessionManager implements SessionManager { - - public CIMSession get(String account) { - - // 这里查询数据库 - /* - * CIMSession session = database.getSession(account); - * session.setIoSession(ContextHolder.getBean(CIMNioSocketAcceptor.class). - * getManagedSessions().get(session.getNid())); return session; - */ - return null; - } - - @Override - public List queryAll() { - return null; - } - - @Override - public void remove(String account) { - - } - - @Override - public void update(CIMSession session) { - - } - - @Override - public void add(CIMSession arg0) { - - } - -} +/** + * Copyright 2013-2023 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.session; + +import java.util.List; +import com.farsunset.cim.sdk.server.session.CIMSession; +import com.farsunset.cim.sdk.server.session.SessionManager; + +/** + * 集群 session管理实现示例, 各位可以自行实现 AbstractSessionManager接口来实现自己的 session管理 服务器集群时 + * 须要将CIMSession 信息存入数据库或者nosql 等 第三方存储空间中,便于所有服务器都可以访问 + */ +public class ClusterSessionManager implements SessionManager { + + public CIMSession get(String account) { + + // 这里查询数据库 + /* + * CIMSession session = database.getSession(account); + * session.setIoSession(ContextHolder.getBean(CIMNioSocketAcceptor.class). + * getManagedSessions().get(session.getNid())); return session; + */ + return null; + } + + @Override + public List queryAll() { + return null; + } + + @Override + public void remove(String account) { + + } + + @Override + public void update(CIMSession session) { + + } + + @Override + public void add(CIMSession arg0) { + + } + +} 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 new file mode 100644 index 0000000..16040da --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/util/ApnsPayloadCompat.java @@ -0,0 +1,80 @@ +/** + * Copyright 2013-2033 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-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 similarity index 100% rename from cim_for_netty/cim-server/src/main/java/com/farsunset/cim/util/Constants.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/util/Constants.java diff --git a/cim_for_netty/cim-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 similarity index 98% rename from cim_for_netty/cim-server/src/main/java/com/farsunset/cim/util/StringUtil.java rename to cim_for_netty/cim-boot-server/src/main/java/com/farsunset/cim/util/StringUtil.java index 9534640..2310a2a 100644 --- a/cim_for_netty/cim-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 @@ -63,7 +63,6 @@ public class StringUtil { } public static String getUUID() { - // TODO Auto-generated method stub 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 new file mode 100644 index 0000000..6986fb9 --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/resources/application.properties @@ -0,0 +1,34 @@ +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 new file mode 100644 index 0000000..831c109 --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/resources/i18n/messages.properties @@ -0,0 +1,67 @@ +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 new file mode 100644 index 0000000..9c09aa0 --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/resources/page/console/header.html @@ -0,0 +1,44 @@ + +
+

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 new file mode 100644 index 0000000..3710786 --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/resources/page/console/index.html @@ -0,0 +1,25 @@ + + + + + <@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/nav.html b/cim_for_netty/cim-boot-server/src/main/resources/page/console/nav.html new file mode 100644 index 0000000..afda0c3 --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/resources/page/console/nav.html @@ -0,0 +1,17 @@ + + diff --git a/cim_for_netty/cim-boot-server/src/main/resources/page/console/session/manage.html b/cim_for_netty/cim-boot-server/src/main/resources/page/console/session/manage.html new file mode 100644 index 0000000..ce4feda --- /dev/null +++ b/cim_for_netty/cim-boot-server/src/main/resources/page/console/session/manage.html @@ -0,0 +1,129 @@ + + + + +<@spring.message "module.common.html.title"/> + + + + + + + + + + + + +<#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! }${cimsession.nid!}${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_netty/cim-server/WebContent/console/webclient/loginDialog.jsp b/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/loginDialog.html similarity index 63% rename from cim_for_netty/cim-server/WebContent/console/webclient/loginDialog.jsp rename to cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/loginDialog.html index 45a0e07..9e9ab9d 100644 --- a/cim_for_netty/cim-server/WebContent/console/webclient/loginDialog.jsp +++ b/cim_for_netty/cim-boot-server/src/main/resources/page/console/webclient/loginDialog.html @@ -1,16 +1,7 @@ - <%@ page language="java" pageEncoding="utf-8"%> - <% - String loginBasePath = request.getScheme() + "://" - + request.getServerName() + ":" + request.getServerPort() - + request.getContextPath(); - - %>