├── netty-common
├── src
│ └── main
│ │ └── java
│ │ └── com
│ │ └── haoxy
│ │ └── common
│ │ ├── ivm
│ │ └── model
│ │ └── CustomProtocol.java
├── target
│ └── classes
│ │ └── com
│ │ └── haoxy
│ │ └── common
│ │ └── model
│ │ └── CustomProtocol.class
├── pom.xml
└── netty-common.iml
├── netty-server
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── haoxy
│ │ └── server
│ │ ├── ServerApp.java
│ │ ├── init
│ │ └── HeartbeatInitializer.java
│ │ ├── util
│ │ └── NettySocketHolder.java
│ │ ├── encode
│ │ └── HeartbeatDecoder.java
│ │ ├── handle
│ │ └── HeartBeatSimpleHandle.java
│ │ └── heart
│ │ └── HeartBeatServer.java
├── target
│ └── classes
│ │ ├── application.properties
│ │ └── com
│ │ └── haoxy
│ │ └── server
│ │ ├── ServerApp.class
│ │ ├── heart
│ │ └── HeartBeatServer.class
│ │ ├── encode
│ │ └── HeartbeatDecoder.class
│ │ ├── util
│ │ └── NettySocketHolder.class
│ │ ├── init
│ │ └── HeartbeatInitializer.class
│ │ └── handle
│ │ └── HeartBeatSimpleHandle.class
├── pom.xml
└── netty-server.iml
├── netty-client
├── target
│ └── classes
│ │ ├── com
│ │ └── haoxy
│ │ │ └── client
│ │ │ ├── ClientApp.class
│ │ │ ├── heart
│ │ │ └── HeartbeatClient.class
│ │ │ ├── config
│ │ │ └── HeartBeatConfig.class
│ │ │ ├── encode
│ │ │ └── HeartbeatEncode.class
│ │ │ ├── handle
│ │ │ └── EchoClientHandle.class
│ │ │ ├── util
│ │ │ └── SpringBeanFactory.class
│ │ │ └── init
│ │ │ └── CustomerHandleInitializer.class
│ │ └── application.properties
├── src
│ └── main
│ │ ├── resources
│ │ └── application.properties
│ │ └── java
│ │ └── com
│ │ └── haoxy
│ │ └── client
│ │ ├── ClientApp.java
│ │ ├── config
│ │ └── HeartBeatConfig.java
│ │ ├── encode
│ │ └── HeartbeatEncode.java
│ │ ├── init
│ │ └── CustomerHandleInitializer.java
│ │ ├── util
│ │ └── SpringBeanFactory.java
│ │ ├── heart
│ │ └── HeartbeatClient.java
│ │ └── handle
│ │ └── EchoClientHandle.java
├── pom.xml
└── netty-client.iml
├── .idea
├── kotlinc.xml
├── misc.xml
├── encodings.xml
├── libraries
│ ├── Maven__junit_junit_4_11.xml
│ ├── Maven__org_ow2_asm_asm_5_0_3.xml
│ ├── Maven__org_yaml_snakeyaml_1_17.xml
│ ├── Maven__org_objenesis_objenesis_2_1.xml
│ ├── Maven__org_slf4j_slf4j_api_1_7_25.xml
│ ├── Maven__com_fasterxml_classmate_1_3_3.xml
│ ├── Maven__net_minidev_json_smart_2_2_1.xml
│ ├── Maven__org_hamcrest_hamcrest_core_1_3.xml
│ ├── Maven__org_assertj_assertj_core_2_6_0.xml
│ ├── Maven__org_slf4j_jul_to_slf4j_1_7_25.xml
│ ├── Maven__org_skyscreamer_jsonassert_1_4_0.xml
│ ├── Maven__net_minidev_accessors_smart_1_1.xml
│ ├── Maven__com_jayway_jsonpath_json_path_2_2_0.xml
│ ├── Maven__io_netty_netty_all_4_1_21_Final.xml
│ ├── Maven__org_mockito_mockito_core_1_10_19.xml
│ ├── Maven__org_slf4j_jcl_over_slf4j_1_7_25.xml
│ ├── Maven__org_hamcrest_hamcrest_library_1_3.xml
│ ├── Maven__ch_qos_logback_logback_core_1_1_11.xml
│ ├── Maven__org_slf4j_log4j_over_slf4j_1_7_25.xml
│ ├── Maven__ch_qos_logback_logback_classic_1_1_11.xml
│ ├── Maven__com_fasterxml_jackson_core_jackson_core_2_8_9.xml
│ ├── Maven__org_jboss_logging_jboss_logging_3_3_1_Final.xml
│ ├── Maven__javax_validation_validation_api_1_1_0_Final.xml
│ ├── Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_16.xml
│ ├── Maven__org_springframework_spring_aop_4_3_10_RELEASE.xml
│ ├── Maven__org_springframework_spring_web_4_3_10_RELEASE.xml
│ ├── Maven__com_fasterxml_jackson_core_jackson_databind_2_8_9.xml
│ ├── Maven__org_springframework_spring_core_4_3_10_RELEASE.xml
│ ├── Maven__org_springframework_spring_test_4_3_10_RELEASE.xml
│ ├── Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_16.xml
│ ├── Maven__org_springframework_spring_beans_4_3_10_RELEASE.xml
│ ├── Maven__org_hibernate_hibernate_validator_5_3_5_Final.xml
│ ├── Maven__org_springframework_boot_spring_boot_1_5_6_RELEASE.xml
│ ├── Maven__org_springframework_spring_webmvc_4_3_10_RELEASE.xml
│ ├── Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_0.xml
│ ├── Maven__org_springframework_spring_context_4_3_10_RELEASE.xml
│ ├── Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_16.xml
│ ├── Maven__org_springframework_spring_expression_4_3_10_RELEASE.xml
│ ├── Maven__org_springframework_boot_spring_boot_test_1_5_6_RELEASE.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_1_5_6_RELEASE.xml
│ ├── Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_web_1_5_6_RELEASE.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_test_1_5_6_RELEASE.xml
│ ├── Maven__org_springframework_boot_spring_boot_autoconfigure_1_5_6_RELEASE.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_tomcat_1_5_6_RELEASE.xml
│ ├── Maven__org_springframework_boot_spring_boot_starter_logging_1_5_6_RELEASE.xml
│ └── Maven__org_springframework_boot_spring_boot_test_autoconfigure_1_5_6_RELEASE.xml
├── modules.xml
├── compiler.xml
├── inspectionProfiles
│ └── Project_Default.xml
└── workspace.xml
├── .gitignore
├── springboot-netty.iml
├── pom.xml
└── README.md
/netty-common/src/main/java/com/haoxy/common/ivm:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/netty-server/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # web port
2 | server.port=8081
3 | netty.server.port=11211
4 |
5 |
6 |
--------------------------------------------------------------------------------
/netty-server/target/classes/application.properties:
--------------------------------------------------------------------------------
1 | # web port
2 | server.port=8081
3 | netty.server.port=11211
4 |
5 |
6 |
--------------------------------------------------------------------------------
/netty-client/target/classes/com/haoxy/client/ClientApp.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-client/target/classes/com/haoxy/client/ClientApp.class
--------------------------------------------------------------------------------
/netty-server/target/classes/com/haoxy/server/ServerApp.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-server/target/classes/com/haoxy/server/ServerApp.class
--------------------------------------------------------------------------------
/netty-client/target/classes/com/haoxy/client/heart/HeartbeatClient.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-client/target/classes/com/haoxy/client/heart/HeartbeatClient.class
--------------------------------------------------------------------------------
/netty-common/target/classes/com/haoxy/common/model/CustomProtocol.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-common/target/classes/com/haoxy/common/model/CustomProtocol.class
--------------------------------------------------------------------------------
/netty-server/target/classes/com/haoxy/server/heart/HeartBeatServer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-server/target/classes/com/haoxy/server/heart/HeartBeatServer.class
--------------------------------------------------------------------------------
/.idea/kotlinc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/netty-client/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | # web port
2 | server.port=8082
3 | # 通道 ID
4 | channel.id=100
5 |
6 | netty.server.host=127.0.0.1
7 | netty.server.port=11211
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/netty-client/target/classes/application.properties:
--------------------------------------------------------------------------------
1 | # web port
2 | server.port=8082
3 | # 通道 ID
4 | channel.id=100
5 |
6 | netty.server.host=127.0.0.1
7 | netty.server.port=11211
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/netty-client/target/classes/com/haoxy/client/config/HeartBeatConfig.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-client/target/classes/com/haoxy/client/config/HeartBeatConfig.class
--------------------------------------------------------------------------------
/netty-client/target/classes/com/haoxy/client/encode/HeartbeatEncode.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-client/target/classes/com/haoxy/client/encode/HeartbeatEncode.class
--------------------------------------------------------------------------------
/netty-client/target/classes/com/haoxy/client/handle/EchoClientHandle.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-client/target/classes/com/haoxy/client/handle/EchoClientHandle.class
--------------------------------------------------------------------------------
/netty-client/target/classes/com/haoxy/client/util/SpringBeanFactory.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-client/target/classes/com/haoxy/client/util/SpringBeanFactory.class
--------------------------------------------------------------------------------
/netty-server/target/classes/com/haoxy/server/encode/HeartbeatDecoder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-server/target/classes/com/haoxy/server/encode/HeartbeatDecoder.class
--------------------------------------------------------------------------------
/netty-server/target/classes/com/haoxy/server/util/NettySocketHolder.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-server/target/classes/com/haoxy/server/util/NettySocketHolder.class
--------------------------------------------------------------------------------
/netty-server/target/classes/com/haoxy/server/init/HeartbeatInitializer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-server/target/classes/com/haoxy/server/init/HeartbeatInitializer.class
--------------------------------------------------------------------------------
/netty-server/target/classes/com/haoxy/server/handle/HeartBeatSimpleHandle.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-server/target/classes/com/haoxy/server/handle/HeartBeatSimpleHandle.class
--------------------------------------------------------------------------------
/netty-client/target/classes/com/haoxy/client/init/CustomerHandleInitializer.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/haoxiaoyong1014/springboot-netty/HEAD/netty-client/target/classes/com/haoxy/client/init/CustomerHandleInitializer.class
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__junit_junit_4_11.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/netty-client/src/main/java/com/haoxy/client/ClientApp.java:
--------------------------------------------------------------------------------
1 | package com.haoxy.client;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * Created by haoxy on 2018/10/17.
8 | * E-mail:hxyHelloWorld@163.com
9 | * github:https://github.com/haoxiaoyong1014
10 | */
11 | @SpringBootApplication
12 | public class ClientApp {
13 | public static void main(String[] args) {
14 | SpringApplication.run(ClientApp.class,args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/netty-server/src/main/java/com/haoxy/server/ServerApp.java:
--------------------------------------------------------------------------------
1 | package com.haoxy.server;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * Created by haoxy on 2018/10/17.
8 | * E-mail:hxyHelloWorld@163.com
9 | * github:https://github.com/haoxiaoyong1014
10 | */
11 | @SpringBootApplication
12 | public class ServerApp {
13 | public static void main(String[] args) {
14 | SpringApplication.run(ServerApp.class,args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_ow2_asm_asm_5_0_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_yaml_snakeyaml_1_17.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/netty-common/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | springboot-netty
7 | com.haoxy.netty
8 | 1.0-SNAPSHOT
9 |
10 | 4.0.0
11 |
12 | netty-common
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_objenesis_objenesis_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_classmate_1_3_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__net_minidev_json_smart_2_2_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_assertj_assertj_core_2_6_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_slf4j_jul_to_slf4j_1_7_25.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_skyscreamer_jsonassert_1_4_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__net_minidev_accessors_smart_1_1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_jayway_jsonpath_json_path_2_2_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__io_netty_netty_all_4_1_21_Final.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_mockito_mockito_core_1_10_19.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_slf4j_jcl_over_slf4j_1_7_25.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hamcrest_hamcrest_library_1_3.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__ch_qos_logback_logback_core_1_1_11.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_slf4j_log4j_over_slf4j_1_7_25.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_11.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_8_9.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_jboss_logging_jboss_logging_3_3_1_Final.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__javax_validation_validation_api_1_1_0_Final.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_el_8_5_16.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_aop_4_3_10_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_web_4_3_10_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_8_9.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_core_4_3_10_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_test_4_3_10_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_8_5_16.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_beans_4_3_10_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_hibernate_hibernate_validator_5_3_5_Final.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_1_5_6_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_webmvc_4_3_10_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_0.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_context_4_3_10_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/netty-client/src/main/java/com/haoxy/client/config/HeartBeatConfig.java:
--------------------------------------------------------------------------------
1 | package com.haoxy.client.config;
2 |
3 | import com.haoxy.common.model.CustomProtocol;
4 | import org.springframework.beans.factory.annotation.Value;
5 | import org.springframework.context.annotation.Bean;
6 | import org.springframework.context.annotation.Configuration;
7 |
8 | /**
9 | * Created by haoxy on 2018/10/17.
10 | * E-mail:hxyHelloWorld@163.com
11 | * github:https://github.com/haoxiaoyong1014
12 | */
13 | @Configuration
14 | public class HeartBeatConfig {
15 |
16 | @Value("${channel.id}")
17 | private long id;
18 |
19 | @Bean(value = "heartBeat")
20 | public CustomProtocol heartBeat(){
21 | return new CustomProtocol(id,"ping") ;
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_8_5_16.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_spring_expression_4_3_10_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_1_5_6_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_1_5_6_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__com_vaadin_external_google_android_json_0_0_20131108_vaadin1.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_1_5_6_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_1_5_6_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/netty-client/src/main/java/com/haoxy/client/encode/HeartbeatEncode.java:
--------------------------------------------------------------------------------
1 | package com.haoxy.client.encode;
2 |
3 | import com.haoxy.common.model.CustomProtocol;
4 | import io.netty.buffer.ByteBuf;
5 | import io.netty.channel.ChannelHandlerContext;
6 | import io.netty.handler.codec.MessageToByteEncoder;
7 |
8 | /**
9 | * Created by haoxy on 2018/10/17.
10 | * E-mail:hxyHelloWorld@163.com
11 | * github:https://github.com/haoxiaoyong1014
12 | * 客户端编码器
13 | */
14 | public class HeartbeatEncode extends MessageToByteEncoder {
15 | @Override
16 | protected void encode(ChannelHandlerContext channelHandlerContext, CustomProtocol customProtocol, ByteBuf byteBuf) throws Exception {
17 | byteBuf.writeLong(customProtocol.getId()) ;
18 | byteBuf.writeBytes(customProtocol.getContent().getBytes()) ;
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_1_5_6_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_1_5_6_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_1_5_6_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_1_5_6_RELEASE.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/netty-client/src/main/java/com/haoxy/client/init/CustomerHandleInitializer.java:
--------------------------------------------------------------------------------
1 | package com.haoxy.client.init;
2 |
3 | import com.haoxy.client.encode.HeartbeatEncode;
4 | import com.haoxy.client.handle.EchoClientHandle;
5 | import io.netty.channel.Channel;
6 | import io.netty.channel.ChannelInitializer;
7 | import io.netty.handler.timeout.IdleStateHandler;
8 |
9 | /**
10 | * Created by haoxy on 2018/10/17.
11 | * E-mail:hxyHelloWorld@163.com
12 | * github:https://github.com/haoxiaoyong1014
13 | */
14 | public class CustomerHandleInitializer extends ChannelInitializer {
15 | @Override
16 | protected void initChannel(Channel channel) throws Exception {
17 | channel.pipeline()
18 | //10 秒没发送消息 将IdleStateHandler 添加到 ChannelPipeline 中
19 | .addLast(new IdleStateHandler(0, 10, 0))
20 | .addLast(new HeartbeatEncode())
21 | .addLast(new EchoClientHandle());
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/netty-server/src/main/java/com/haoxy/server/init/HeartbeatInitializer.java:
--------------------------------------------------------------------------------
1 | package com.haoxy.server.init;
2 |
3 | import com.haoxy.server.encode.HeartbeatDecoder;
4 | import com.haoxy.server.handle.HeartBeatSimpleHandle;
5 | import io.netty.channel.Channel;
6 | import io.netty.channel.ChannelInitializer;
7 | import io.netty.handler.timeout.IdleStateHandler;
8 |
9 | /**
10 | * Created by haoxy on 2018/10/17.
11 | * E-mail:hxyHelloWorld@163.com
12 | * github:https://github.com/haoxiaoyong1014
13 | */
14 | public class HeartbeatInitializer extends ChannelInitializer {
15 | @Override
16 | protected void initChannel(Channel channel) throws Exception {
17 | channel.pipeline()
18 | //五秒没有收到消息 将IdleStateHandler 添加到 ChannelPipeline 中
19 | .addLast(new IdleStateHandler(5, 0, 0))
20 | .addLast(new HeartbeatDecoder())
21 | .addLast(new HeartBeatSimpleHandle());
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/netty-client/src/main/java/com/haoxy/client/util/SpringBeanFactory.java:
--------------------------------------------------------------------------------
1 | package com.haoxy.client.util;
2 |
3 | import org.springframework.beans.BeansException;
4 | import org.springframework.context.ApplicationContext;
5 | import org.springframework.context.ApplicationContextAware;
6 | import org.springframework.stereotype.Component;
7 |
8 | /**
9 | * Created by haoxy on 2018/10/17.
10 | * E-mail:hxyHelloWorld@163.com
11 | * github:https://github.com/haoxiaoyong1014
12 | */
13 | @Component
14 | public final class SpringBeanFactory implements ApplicationContextAware {
15 |
16 | private static ApplicationContext context;
17 |
18 | public static T getBean(Class c){
19 | return context.getBean(c);
20 | }
21 |
22 |
23 | public static T getBean(String name,Class clazz){
24 | return context.getBean(name,clazz);
25 | }
26 |
27 | @Override
28 | public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
29 | context = applicationContext;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/netty-server/src/main/java/com/haoxy/server/util/NettySocketHolder.java:
--------------------------------------------------------------------------------
1 | package com.haoxy.server.util;
2 |
3 | import io.netty.channel.socket.nio.NioSocketChannel;
4 |
5 | import java.util.Map;
6 | import java.util.concurrent.ConcurrentHashMap;
7 |
8 | /**
9 | * Created by haoxy on 2018/10/17.
10 | * E-mail:hxyHelloWorld@163.com
11 | * github:https://github.com/haoxiaoyong1014
12 | */
13 | public class NettySocketHolder {
14 |
15 | private static final Map MAP = new ConcurrentHashMap<>(16);
16 |
17 | public static void put(Long id, NioSocketChannel socketChannel) {
18 | MAP.put(id, socketChannel);
19 | }
20 |
21 | public static NioSocketChannel get(Long id) {
22 | return MAP.get(id);
23 | }
24 |
25 | public static Map getMAP() {
26 | return MAP;
27 | }
28 |
29 | public static void remove(NioSocketChannel nioSocketChannel) {
30 | MAP.entrySet().stream().filter(entry -> entry.getValue() == nioSocketChannel).forEach(entry -> MAP.remove(entry.getKey()));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/netty-server/src/main/java/com/haoxy/server/encode/HeartbeatDecoder.java:
--------------------------------------------------------------------------------
1 | package com.haoxy.server.encode;
2 |
3 | import com.haoxy.common.model.CustomProtocol;
4 | import io.netty.buffer.ByteBuf;
5 | import io.netty.channel.ChannelHandlerContext;
6 | import io.netty.handler.codec.ByteToMessageDecoder;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * Created by haoxy on 2018/10/17.
12 | * E-mail:hxyHelloWorld@163.com
13 | * github:https://github.com/haoxiaoyong1014
14 | * 服务端解码器
15 | */
16 | public class HeartbeatDecoder extends ByteToMessageDecoder {
17 | @Override
18 | protected void decode(ChannelHandlerContext channelHandlerContext, ByteBuf byteBuf, List