├── logo.png
├── .travis.yml
├── doc
└── img
│ ├── gzh.jpg
│ ├── logo.png
│ ├── broker.jpg
│ └── launch.jpg
├── out
└── production
│ └── ttiot-broker
│ └── META-INF
│ └── ttiot-broker.kotlin_module
├── ttiot-common
├── ttiot-common-core
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── link
│ │ │ └── ttiot
│ │ │ └── common
│ │ │ └── core
│ │ │ ├── constant
│ │ │ ├── enums
│ │ │ │ ├── ThreadPoolEnum.java
│ │ │ │ └── MessageState.java
│ │ │ ├── AppProtocalMqttConstant.java
│ │ │ ├── ProtocalConstant.java
│ │ │ └── CommonConstant.java
│ │ │ ├── bean
│ │ │ └── KeyFiledBean.java
│ │ │ ├── exception
│ │ │ ├── ProtocalException.java
│ │ │ └── ConnectException.java
│ │ │ ├── provider
│ │ │ └── bean
│ │ │ │ ├── SimpleBeanProvider.java
│ │ │ │ └── SingtonBeanProvider.java
│ │ │ ├── thread
│ │ │ ├── ThreadProvider.java
│ │ │ └── ThreadPoolProvider.java
│ │ │ ├── ssl
│ │ │ └── SslBuilder.java
│ │ │ ├── security
│ │ │ └── IdGenerator.java
│ │ │ ├── function
│ │ │ └── FunctionApi.java
│ │ │ └── channel
│ │ │ └── ChannelUtils.java
│ └── pom.xml
├── ttiot-common-config
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ └── banner.txt
│ │ │ └── java
│ │ │ └── link
│ │ │ └── ttiot
│ │ │ └── common
│ │ │ └── config
│ │ │ └── ConfigurationFileReader.java
│ └── pom.xml
├── pom.xml
├── ttiot-common-ioc
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── link
│ │ └── ttiot
│ │ └── common
│ │ └── ioc
│ │ ├── vo
│ │ ├── MqttPayload.java
│ │ ├── HttpRequest.java
│ │ └── HttpRet.java
│ │ ├── core
│ │ ├── HttpHandler.java
│ │ ├── RuleHandler.java
│ │ ├── ApplicationListener.java
│ │ ├── ApplicationEvent.java
│ │ └── AbstractApplicationListener.java
│ │ ├── annotation
│ │ ├── DefaultListener.java
│ │ ├── Inject.java
│ │ ├── Http.java
│ │ ├── Ruler.java
│ │ ├── Eventor.java
│ │ └── Listener.java
│ │ └── multicaster
│ │ ├── Multicaster.java
│ │ └── ListenerRetriever.java
├── ttiot-common-redis
│ ├── src
│ │ └── main
│ │ │ └── java
│ │ │ └── link
│ │ │ └── ttiot
│ │ │ └── common
│ │ │ └── redis
│ │ │ ├── KeyNamePolicy.java
│ │ │ └── serializer
│ │ │ └── Serializer.java
│ └── pom.xml
└── ttiot-common-context
│ ├── src
│ └── main
│ │ └── java
│ │ └── link
│ │ └── ttiot
│ │ └── common
│ │ └── context
│ │ ├── entity
│ │ ├── Tenant.java
│ │ ├── Device.java
│ │ ├── Subscribe.java
│ │ └── MessageStore.java
│ │ ├── protocal
│ │ ├── mqtt
│ │ │ ├── MqttApplicationListener.java
│ │ │ └── MqttApplicationEvent.java
│ │ ├── ProtocolApplicationListener.java
│ │ └── ProtocolApplicationEvent.java
│ │ ├── exception
│ │ └── ExceptionHandlerAdapter.java
│ │ ├── service
│ │ ├── DeviceService.java
│ │ ├── SessionService.java
│ │ ├── SubscribeService.java
│ │ └── MessageStoreService.java
│ │ ├── Session.java
│ │ └── ChannelGroup.java
│ └── pom.xml
├── ttiot-example
├── Dockerfile
├── src
│ └── main
│ │ ├── resources
│ │ └── TTIotBootstrap.yml
│ │ └── java
│ │ └── link
│ │ └── ttiot
│ │ └── example
│ │ └── server
│ │ ├── listener
│ │ ├── DbDemo.java
│ │ └── LoginLogListener.java
│ │ ├── exception
│ │ └── ExceptionHandlerDemo.java
│ │ ├── ServerExampleLauncher.java
│ │ ├── rule
│ │ └── ChatRuleHandler.java
│ │ └── http
│ │ └── DemoHttpHandler.java
└── pom.xml
├── docker-compose.yml
├── ttiot-broker
├── src
│ ├── main
│ │ ├── resources
│ │ │ └── TTIotBootstrap.yml
│ │ └── java
│ │ │ ├── link
│ │ │ └── ttiot
│ │ │ │ └── broker
│ │ │ │ ├── handler
│ │ │ │ ├── http
│ │ │ │ │ ├── Method.java
│ │ │ │ │ ├── HttpMqttRequestVo.java
│ │ │ │ │ ├── HttpPacket.java
│ │ │ │ │ ├── KeyValue.java
│ │ │ │ │ ├── MqttHttpHandler.java
│ │ │ │ │ ├── HttpRequestHandler.java
│ │ │ │ │ └── RequestLine.java
│ │ │ │ ├── websocket
│ │ │ │ │ └── MqttWebSocketCodec.java
│ │ │ │ ├── listener
│ │ │ │ │ ├── connect
│ │ │ │ │ │ ├── MqttIdentifierRejectedExceptionListener.java
│ │ │ │ │ │ ├── MqttUnacceptableProtocolVersionExceptionListener.java
│ │ │ │ │ │ ├── MqttDisConnectListener.java
│ │ │ │ │ │ └── MqttConnectBackListener.java
│ │ │ │ │ ├── decode
│ │ │ │ │ │ ├── MqttDecoderSucceedDefaultListener.java
│ │ │ │ │ │ └── MqttDecodeErrorDefaultListener.java
│ │ │ │ │ ├── ping
│ │ │ │ │ │ └── MqttPingListener.java
│ │ │ │ │ ├── publish
│ │ │ │ │ │ ├── ack
│ │ │ │ │ │ │ └── MqttPubAckListener.java
│ │ │ │ │ │ ├── comp
│ │ │ │ │ │ │ └── MqttPubCompListener.java
│ │ │ │ │ │ ├── rel
│ │ │ │ │ │ │ └── MqttPubRelListener.java
│ │ │ │ │ │ ├── rec
│ │ │ │ │ │ │ └── MqttPubRecListener.java
│ │ │ │ │ │ └── MqttUnconfirmedPublishListener.java
│ │ │ │ │ ├── subscribe
│ │ │ │ │ │ └── MqttUnSubscribeListener.java
│ │ │ │ │ ├── ack
│ │ │ │ │ │ └── MqttAckListener.java
│ │ │ │ │ └── lwt
│ │ │ │ │ │ └── MqttLwtListener.java
│ │ │ │ ├── rule
│ │ │ │ │ └── RuleDispatcher.java
│ │ │ │ ├── ExceptionHandler.java
│ │ │ │ └── MqttDecoderHandler.java
│ │ │ │ ├── exception
│ │ │ │ └── ServerExceptionHandler.java
│ │ │ │ └── eventor
│ │ │ │ ├── publish
│ │ │ │ ├── MqttUnconfirmedPublishEvent.java
│ │ │ │ ├── ack
│ │ │ │ │ └── MqttPubAckEvent.java
│ │ │ │ ├── rec
│ │ │ │ │ └── MqttPubRecEvent.java
│ │ │ │ ├── comp
│ │ │ │ │ └── MqttPubCompEvent.java
│ │ │ │ ├── rel
│ │ │ │ │ └── MqttPubRelEvent.java
│ │ │ │ ├── MqttPublishEvent.java
│ │ │ │ ├── MqttPublishDevEvent.java
│ │ │ │ └── MqttPublishTopicEvent.java
│ │ │ │ ├── ack
│ │ │ │ └── MqttAckEvent.java
│ │ │ │ ├── lwt
│ │ │ │ └── MqttLwtEvent.java
│ │ │ │ ├── ping
│ │ │ │ └── MqttPingEvent.java
│ │ │ │ ├── connect
│ │ │ │ ├── MqttDisConnectEvent.java
│ │ │ │ ├── MqttUnacceptableProtocolVersionExceptionEvent.java
│ │ │ │ ├── MqttIdentifierRejectedExceptionEvent.java
│ │ │ │ ├── MqttConnectEvent.java
│ │ │ │ └── MqttConnectBackEvent.java
│ │ │ │ ├── decode
│ │ │ │ ├── MqttDecoderFailEvent.java
│ │ │ │ └── MqttDecoderSuccessEvent.java
│ │ │ │ ├── http
│ │ │ │ └── HttpRequestEvent.java
│ │ │ │ └── subscribe
│ │ │ │ ├── MqttSubscribeEvent.java
│ │ │ │ └── MqttUnSubscribeEvent.java
│ │ │ └── Bootstrap.java
│ └── test
│ │ └── java
│ │ ├── IdGenerateTest.java
│ │ └── DbTest.java
└── pom.xml
├── .gitignore
└── ttiot-client-java
├── src
└── main
│ └── java
│ └── link
│ └── ttiot
│ └── client
│ └── java
│ ├── exception
│ └── ClientExceptionHandler.java
│ ├── Bootstrap.java
│ ├── eventor
│ ├── lwt
│ │ └── MqttLwtEvent.java
│ └── decode
│ │ ├── MqttDecoderFailEvent.java
│ │ └── MqttDecoderSuccessEvent.java
│ └── handler
│ └── MqttDecoderHandler.java
└── pom.xml
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shijun90/TTIot/HEAD/logo.png
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 | jdk:
3 | - oraclejdk8
4 | script: true
--------------------------------------------------------------------------------
/doc/img/gzh.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shijun90/TTIot/HEAD/doc/img/gzh.jpg
--------------------------------------------------------------------------------
/doc/img/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shijun90/TTIot/HEAD/doc/img/logo.png
--------------------------------------------------------------------------------
/out/production/ttiot-broker/META-INF/ttiot-broker.kotlin_module:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/doc/img/broker.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shijun90/TTIot/HEAD/doc/img/broker.jpg
--------------------------------------------------------------------------------
/doc/img/launch.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/shijun90/TTIot/HEAD/doc/img/launch.jpg
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-core/src/main/java/link/ttiot/common/core/constant/enums/ThreadPoolEnum.java:
--------------------------------------------------------------------------------
1 | package link.ttiot.common.core.constant.enums;
2 |
3 | public enum ThreadPoolEnum {
4 | fixedThread,singleThread,cachedThread
5 | }
6 |
--------------------------------------------------------------------------------
/ttiot-example/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM anapsix/alpine-java:8_server-jre_unlimited
2 |
3 | MAINTAINER conttononline@outlook.com
4 |
5 | RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
6 |
7 | RUN mkdir -p /ttiot-example
8 |
9 | WORKDIR /ttiot-example
10 |
11 | EXPOSE 8729
12 |
13 | ADD ./ttiot-example/target/ttiot-example.jar ./
14 |
15 | CMD java -Djava.security.egd=file:/dev/./urandom -jar ttiot-example.jar
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: '2'
2 | services:
3 | ttiot-redis:
4 | image: redis:5.0
5 | command: redis-server --requirepass TTIot
6 | ports:
7 | - 6379:6379
8 | restart: always
9 | container_name: ttiot-redis
10 | hostname: ttiot-redis
11 |
12 | ttiot-example:
13 | build:
14 | context: ./
15 | dockerfile: ./ttiot-example/Dockerfile
16 | restart: always
17 | ports:
18 | - 8729:8729
19 | container_name: ttiot-example
20 | hostname: ttiot-example
21 | image: ttiot-example
--------------------------------------------------------------------------------
/ttiot-broker/src/main/resources/TTIotBootstrap.yml:
--------------------------------------------------------------------------------
1 | TTiot:
2 | port: 8729
3 | host: 0.0.0.0
4 | heartbeatTimeout: 10
5 | netty:
6 | bossGroupCount: -1
7 | workerGroupCount: -1
8 | leakDetectorLevel: DISABLED
9 | maxPayloadSize: 6553600
10 | ssl:
11 | enabled: false
12 | certificateType:
13 | certificatePath:
14 | certificatePassword:
15 | redis:
16 | host: ttiot-redis
17 | port: 6379
18 | timeout: 2000
19 | connectionTimeout: 2000
20 | soTimeout: 2000
21 | password: TTIot
22 | database: 0
23 | ssl: false
24 | maxIdle: 8
25 | minIdle: 0
26 | maxTotal: 8
27 | maxWaitMillis: -1
28 |
29 |
--------------------------------------------------------------------------------
/ttiot-example/src/main/resources/TTIotBootstrap.yml:
--------------------------------------------------------------------------------
1 | TTiot:
2 | port: 8729
3 | host: 0.0.0.0
4 | heartbeatTimeout: 10
5 | netty:
6 | bossGroupCount: -1
7 | workerGroupCount: -1
8 | leakDetectorLevel: DISABLED
9 | maxPayloadSize: 65536
10 | ssl:
11 | enabled: true
12 | certificateType: PKCS12
13 | certificatePath:
14 | certificatePassword:
15 | redis:
16 | host: ttiot-redis
17 | port: 6379
18 | timeout: 2000
19 | connectionTimeout: 2000
20 | soTimeout: 2000
21 | password: TTIot
22 | database: 0
23 | ssl: false
24 | maxIdle: 8
25 | minIdle: 0
26 | maxTotal: 8
27 | maxWaitMillis: -1
28 |
29 |
30 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/handler/http/Method.java:
--------------------------------------------------------------------------------
1 | package link.ttiot.broker.handler.http;
2 |
3 | import java.util.Objects;
4 |
5 | /**
6 | * @author wchao
7 | * 2017年6月28日 下午2:23:16
8 | */
9 | public enum Method {
10 | GET("GET"), POST("POST"), HEAD("HEAD"), PUT("PUT"), TRACE("TRACE"), OPTIONS("OPTIONS"), PATCH("PATCH");
11 | public static Method from(String method) {
12 | Method[] values = Method.values();
13 | for (Method v : values) {
14 | if (Objects.equals(v.value, method)) {
15 | return v;
16 | }
17 | }
18 | return GET;
19 | }
20 |
21 | String value;
22 |
23 | private Method(String value) {
24 | this.value = value;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-config/src/main/resources/banner.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | .___________.___________. __ ______ .___________.
4 | | | || | / __ \ | |
5 | `---| |----`---| |----`| | | | | | `---| |----`
6 | | | | | | | | | | | | |
7 | | | | | | | | `--' | | |
8 | |__| |__| |__| \______/ |__|
9 |
10 | Copyright © www.ttiot.link
11 | VERSION: {}
12 | PORT: {}
13 | BOSSGROUP: {}
14 | WORKERGROUP: {}
15 | HEARTBEATTIMEOUT: {}
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ### gradle ###
2 | .gradle
3 | /build/
4 | !gradle/wrapper/gradle-wrapper.jar
5 |
6 | ### STS ###
7 | .settings/
8 | .apt_generated
9 | .classpath
10 | .factorypath
11 | .project
12 | .settings
13 | .springBeans
14 | bin/
15 |
16 | ### IntelliJ IDEA ###
17 | .idea
18 | *.iws
19 | *.iml
20 | *.ipr
21 | rebel.xml
22 |
23 | ### NetBeans ###
24 | nbproject/private/
25 | build/
26 | nbbuild/
27 | dist/
28 | nbdist/
29 | .nb-gradle/
30 |
31 | ### maven ###
32 | target/
33 | *.war
34 | *.ear
35 | *.zip
36 | *.tar
37 | *.tar.gz
38 |
39 | ### logs ####
40 | /logs/
41 | *.log
42 |
43 | ### temp ignore ###
44 | *.cache
45 | *.diff
46 | *.patch
47 | *.tmp
48 | *.java~
49 | *.properties~
50 | *.xml~
51 |
52 | ### system ignore ###
53 | .DS_Store
54 | Thumbs.db
55 | Servers
56 | .metadata
57 | upload
58 | gen_code
59 |
60 | ### node ###
61 | node_modules
62 |
--------------------------------------------------------------------------------
/ttiot-common/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 |
18 | import link.ttiot.broker.start.ServerLauncher;
19 |
20 | /**
21 | * @author: shijun
22 | * @date: 2019-04-11
23 | * @description:
24 | */
25 | public class Bootstrap {
26 |
27 | public static void main(String[] args){
28 | new ServerLauncher().launch();
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-ioc/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | package link.ttiot.common.core.constant.enums; 18 | 19 | /** 20 | * @author: shijun 21 | * @date: 2019-05-04 22 | * @description: 存储的消息状态 23 | */ 24 | public enum MessageState { 25 | PUBLISH, //等待REC,这类消息需要重新发送 26 | PUBREL, //等待COMPLETE,重发消息标识 27 | } 28 | -------------------------------------------------------------------------------- /ttiot-broker/src/main/java/link/ttiot/broker/exception/ServerExceptionHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | package link.ttiot.broker.exception; 18 | 19 | import link.ttiot.common.context.exception.ExceptionHandlerAdapter; 20 | 21 | /** 22 | * @author: shijun 23 | * @date: 2020-02-27 24 | * @description: 25 | */ 26 | public class ServerExceptionHandler extends ExceptionHandlerAdapter { 27 | } 28 | -------------------------------------------------------------------------------- /ttiot-client-java/src/main/java/link/ttiot/client/java/exception/ClientExceptionHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | package link.ttiot.client.java.exception; 18 | 19 | import link.ttiot.common.context.exception.ExceptionHandlerAdapter; 20 | 21 | /** 22 | * @author: shijun 23 | * @date: 2020-02-27 24 | * @description: 25 | */ 26 | public class ClientExceptionHandler extends ExceptionHandlerAdapter { 27 | } 28 | -------------------------------------------------------------------------------- /ttiot-client-java/src/main/java/link/ttiot/client/java/Bootstrap.java: -------------------------------------------------------------------------------- 1 | package link.ttiot.client.java; /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | 18 | import link.ttiot.client.java.start.ClientLauncher; 19 | 20 | /** 21 | * @author: shijun 22 | * @date: 2019-04-11 23 | * @description: 24 | */ 25 | public class Bootstrap { 26 | 27 | public static void main(String[] args){ 28 | new ClientLauncher().launch(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/vo/MqttPayload.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | package link.ttiot.common.ioc.vo; 18 | 19 | import lombok.Data; 20 | import lombok.ToString; 21 | 22 | /** 23 | * @author: shijun 24 | * @date: 2020-03-09 25 | * @description: 26 | */ 27 | @Data 28 | @ToString 29 | public class MqttPayload { 30 | 31 | private String rule; 32 | 33 | private String content; 34 | 35 | } 36 | -------------------------------------------------------------------------------- /ttiot-common/ttiot-common-core/src/main/java/link/ttiot/common/core/bean/KeyFiledBean.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | package link.ttiot.common.core.bean; 18 | 19 | import lombok.AllArgsConstructor; 20 | import lombok.Data; 21 | 22 | /** 23 | * @author: shijun 24 | * @date: 2019-04-22 25 | * @description: 26 | */ 27 | @AllArgsConstructor 28 | @Data 29 | public class KeyFiledBean { 30 | 31 | private String key; 32 | private String filed; 33 | } 34 | -------------------------------------------------------------------------------- /ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/core/HttpHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | package link.ttiot.common.ioc.core; 18 | 19 | import link.ttiot.common.ioc.vo.HttpRequest; 20 | import link.ttiot.common.ioc.vo.HttpRet; 21 | 22 | 23 | /** 24 | * @author: shijun 25 | * @date: 2019-04-15 26 | * @description: 27 | */ 28 | public interface HttpHandler{ 29 | 30 | public HttpRet handler(HttpRequest param); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/annotation/DefaultListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | package link.ttiot.common.ioc.annotation; 18 | 19 | import java.lang.annotation.*; 20 | 21 | /** 22 | * @author: shijun 23 | * @date: 2019-04-15 24 | * @description: 25 | */ 26 | @Documented 27 | @Inherited 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.TYPE) 30 | public @interface DefaultListener { 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/annotation/Inject.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | package link.ttiot.common.ioc.annotation; 18 | 19 | import java.lang.annotation.*; 20 | 21 | /** 22 | * @author: shijun 23 | * @date: 2019-04-28 24 | * @description: 25 | */ 26 | @Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) 27 | @Retention(RetentionPolicy.RUNTIME) 28 | @Documented 29 | public @interface Inject { 30 | 31 | } 32 | -------------------------------------------------------------------------------- /ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/annotation/Http.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | package link.ttiot.common.ioc.annotation; 18 | 19 | import java.lang.annotation.*; 20 | 21 | /** 22 | * @author: shijun 23 | * @date: 2019-04-15 24 | * @description: 25 | */ 26 | @Documented 27 | @Inherited 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.TYPE) 30 | public @interface Http { 31 | 32 | String uri() default ""; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/annotation/Ruler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software 10 | * distributed under the License is distributed on an "AS IS" BASIS, 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | * See the License for the specific language governing permissions and 13 | * limitations under the License. 14 | * Author: shijun (conttononline@outlook.com) 15 | */ 16 | 17 | package link.ttiot.common.ioc.annotation; 18 | 19 | import java.lang.annotation.*; 20 | 21 | /** 22 | * @author: shijun 23 | * @date: 2019-04-15 24 | * @description: 25 | */ 26 | @Documented 27 | @Inherited 28 | @Retention(RetentionPolicy.RUNTIME) 29 | @Target(ElementType.TYPE) 30 | public @interface Ruler { 31 | 32 | String name() default ""; 33 | 34 | } 35 | -------------------------------------------------------------------------------- /ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/core/RuleHandler.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright(c) link.ttiot & shijun All rights reserved. 3 | * Licensed under the Apache License, Version 2.0 (the "License"); 4 | * you may not use this file except in compliance with the License. 5 | * You may obtain a copy of the License at 6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0 8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.ioc.core;
18 |
19 | import link.ttiot.common.ioc.vo.MqttPayload;
20 |
21 | import java.util.EventListener;
22 |
23 | /**
24 | * @author: shijun
25 | * @date: 2019-04-15
26 | * @description:
27 | */
28 | public interface RuleHandler
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.ioc.multicaster;
18 |
19 | import link.ttiot.common.ioc.core.ApplicationEvent;
20 |
21 | /**
22 | * @author: shijun
23 | * @date: 2019-05-05
24 | * @description:
25 | */
26 | public interface Multicaster {
27 |
28 | void multicastEventProcess(ApplicationEvent event);
29 |
30 | void multicastEvent(final ApplicationEvent event);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/vo/HttpRequest.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.ioc.vo;
18 |
19 | import lombok.AllArgsConstructor;
20 | import lombok.Data;
21 |
22 | /**
23 | * @author: shijun
24 | * @date: 2020-03-26
25 | * @description:
26 | */
27 | @AllArgsConstructor
28 | @Data
29 | public class HttpRequest {
30 | private String userName;
31 | private String password;
32 | private String body;
33 | private String tenantId;
34 | }
35 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-config/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.handler.http;
18 |
19 | import link.ttiot.common.ioc.vo.MqttPayload;
20 | import lombok.Data;
21 |
22 | /**
23 | * @author: shijun
24 | * @date: 2020-03-09
25 | * @description:
26 | */
27 | @Data
28 | public class HttpMqttRequestVo {
29 |
30 | private String topic;
31 |
32 | private int mqttQos;
33 |
34 | private Boolean retain;
35 |
36 | private MqttPayload payload;
37 | }
38 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/annotation/Eventor.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.ioc.annotation;
18 |
19 | import java.lang.annotation.*;
20 |
21 | /**
22 | * @author: shijun
23 | * @date: 2019-04-15
24 | * @description:
25 | */
26 | @Documented
27 | @Inherited
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.TYPE)
30 | public @interface Eventor {
31 |
32 | String value() default "";
33 |
34 | boolean auth() default true;
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/annotation/Listener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.ioc.annotation;
18 |
19 | import java.lang.annotation.*;
20 |
21 | /**
22 | * @author: shijun
23 | * @date: 2019-04-15
24 | * @description:
25 | */
26 | @Documented
27 | @Inherited
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.TYPE)
30 | public @interface Listener {
31 |
32 | boolean replace() default false;
33 |
34 | boolean asynchronous() default false;
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-redis/src/main/java/link/ttiot/common/redis/KeyNamePolicy.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.redis;
18 |
19 | /**
20 | * @author: shijun
21 | * @date: 2019-04-19
22 | * @description:
23 | */
24 | public interface KeyNamePolicy {
25 |
26 | KeyNamePolicy defaultKeyNamePolicy = new KeyNamePolicy() {
27 | @Override
28 | public String getKeyName(Object key) {
29 | return key.toString();
30 | }
31 | };
32 |
33 | String getKeyName(Object var1);
34 | }
35 |
--------------------------------------------------------------------------------
/ttiot-example/src/main/java/link/ttiot/example/server/listener/DbDemo.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.example.server.listener;
18 |
19 | import cn.hutool.core.lang.Console;
20 | import lombok.experimental.UtilityClass;
21 |
22 | /**
23 | * @author: shijun
24 | * @date: 2019-05-06
25 | * @description:
26 | */
27 | @UtilityClass
28 | public class DbDemo {
29 |
30 |
31 | public void saveLogin(Long time,String devName,String tenant){
32 | Console.print("储存信息:"+"租户:"+tenant+"设备编号:"+devName+"在"+time+"登陆");
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-context/src/main/java/link/ttiot/common/context/entity/Tenant.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.context.entity;
18 |
19 | import lombok.AllArgsConstructor;
20 | import lombok.Data;
21 |
22 | import java.io.Serializable;
23 |
24 | /**
25 | * @author: shijun
26 | * @date: 2019-04-19
27 | * @description:
28 | */
29 | @Data
30 | @AllArgsConstructor
31 | public class Tenant implements Serializable {
32 |
33 | private static final long serialVersionUID = 1L;
34 |
35 | private String tenantId;
36 | private String tenantName;
37 | }
38 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-redis/src/main/java/link/ttiot/common/redis/serializer/Serializer.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.redis.serializer;
18 |
19 | /**
20 | * @author: shijun
21 | * @date: 2019-04-19
22 | * @description:
23 | */
24 | public interface Serializer {
25 |
26 | byte[] keyToBytes(String var1);
27 |
28 | String keyFromBytes(byte[] var1);
29 |
30 | byte[] fieldToBytes(Object var1);
31 |
32 | Object fieldFromBytes(byte[] var1);
33 |
34 | byte[] valueToBytes(Object var1);
35 |
36 | Object valueFromBytes(byte[] var1);
37 | }
38 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/core/ApplicationListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.ioc.core;
18 |
19 |
20 |
21 | import link.ttiot.common.ioc.core.ApplicationEvent;
22 |
23 | import java.util.EventListener;
24 |
25 | /**
26 | * @author: shijun
27 | * @date: 2019-04-13
28 | * @description:
29 | */
30 |
31 | public interface ApplicationListener
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.publish;
18 |
19 |
20 | import link.ttiot.common.ioc.core.ApplicationEvent;
21 |
22 | /**
23 | * @author: shijun
24 | * @date: 2019-05-05
25 | * @description:
26 | */
27 | public class MqttUnconfirmedPublishEvent extends ApplicationEvent {
28 |
29 | public MqttUnconfirmedPublishEvent(Object source) {
30 | super(source);
31 | }
32 |
33 | @Override
34 | public String getSource() {
35 | return (String) super.getSource();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-context/src/main/java/link/ttiot/common/context/entity/Device.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.context.entity;
18 |
19 | import lombok.AllArgsConstructor;
20 | import lombok.Data;
21 |
22 | import java.io.Serializable;
23 |
24 | /**
25 | * @author: shijun
26 | * @date: 2019-04-19
27 | * @description:
28 | */
29 | @Data
30 | @AllArgsConstructor
31 | public class Device implements Serializable {
32 |
33 | private static final long serialVersionUID = 1L;
34 | private String clientId;
35 | private String clientPassword;
36 | private String tenantId;
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ttiot-example/src/main/java/link/ttiot/example/server/exception/ExceptionHandlerDemo.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.example.server.exception;
18 |
19 | import cn.hutool.core.lang.Console;
20 | import link.ttiot.broker.exception.ServerExceptionHandler;
21 |
22 |
23 | /**
24 | * @author: shijun
25 | * @date: 2019-05-07
26 | * @description:
27 | */
28 | public class ExceptionHandlerDemo extends ServerExceptionHandler {
29 |
30 | @Override
31 | public void uncaughtException(Thread t, Throwable e) {
32 | super.uncaughtException(t, e);
33 | Console.print("my exception handler");
34 | }
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/ttiot-client-java/src/main/java/link/ttiot/client/java/eventor/lwt/MqttLwtEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.client.java.eventor.lwt;
18 |
19 | import link.ttiot.common.ioc.annotation.Eventor;
20 | import link.ttiot.common.ioc.core.ApplicationEvent;
21 |
22 |
23 | /**
24 | * @author: shijun
25 | * @date: 2019-04-15
26 | * @description:遗嘱事件
27 | */
28 | @Eventor
29 | public class MqttLwtEvent extends ApplicationEvent {
30 |
31 | public MqttLwtEvent(String clientId) {
32 | super(clientId);
33 | }
34 |
35 | @Override
36 | public String getSource() {
37 | return (String) source;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-context/src/main/java/link/ttiot/common/context/protocal/mqtt/MqttApplicationListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.context.protocal.mqtt;
18 |
19 |
20 | import link.ttiot.common.context.protocal.ProtocolApplicationListener;
21 |
22 | /**
23 | * @author: shijun
24 | * @date: 2019-04-15
25 | * @description:
26 | */
27 | public abstract class MqttApplicationListener
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.context.entity;
18 |
19 | import lombok.AllArgsConstructor;
20 | import lombok.Data;
21 |
22 | import java.io.Serializable;
23 |
24 | /**
25 | * @author: shijun
26 | * @date: 2019-04-19
27 | * @description:
28 | */
29 | @Data
30 | @AllArgsConstructor
31 | public class Subscribe implements Serializable {
32 |
33 | private static final long serialVersionUID = 1L;
34 |
35 | private String topicFilter;
36 |
37 | private String devName;
38 |
39 | private int mqttQoS;
40 |
41 | private String clientId;
42 | }
43 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/ack/MqttAckEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.ack;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.ioc.annotation.Eventor;
23 |
24 |
25 | /**
26 | * @author: shijun
27 | * @date: 2019-04-15
28 | * @description:
29 | */
30 | @Eventor
31 | public class MqttAckEvent extends MqttApplicationEvent {
32 |
33 | public MqttAckEvent(MqttMessage msg, ChannelHandlerContext context) {
34 | super(msg,context);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/core/ApplicationEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.ioc.core;
18 |
19 |
20 | import java.util.EventObject;
21 |
22 | /**
23 | * @author: shijun
24 | * @date: 2019-04-13
25 | * @description:
26 | */
27 |
28 | public abstract class ApplicationEvent extends EventObject {
29 |
30 | private static final long serialVersionUID = 1L;
31 |
32 | private final long timestamp = System.currentTimeMillis();
33 |
34 | public ApplicationEvent(Object source) {
35 | super(source);
36 | }
37 |
38 | public final long getTimestamp() {
39 | return this.timestamp;
40 | }
41 | }
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-context/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.lwt;
18 |
19 | import io.netty.handler.codec.mqtt.MqttQoS;
20 | import link.ttiot.common.ioc.annotation.Eventor;
21 | import link.ttiot.common.ioc.core.ApplicationEvent;
22 | import lombok.Getter;
23 |
24 |
25 | /**
26 | * @author: shijun
27 | * @date: 2019-04-15
28 | * @description:遗嘱事件
29 | */
30 | @Eventor
31 | public class MqttLwtEvent extends ApplicationEvent {
32 |
33 | public MqttLwtEvent(String clientId) {
34 | super(clientId);
35 | }
36 |
37 | @Override
38 | public String getSource() {
39 | return (String) source;
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-core/src/main/java/link/ttiot/common/core/exception/ProtocalException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.core.exception;
18 |
19 | import io.netty.channel.Channel;
20 | import lombok.Getter;
21 |
22 | /**
23 | * @author: shijun
24 | * @date: 2019-05-07
25 | * @description:
26 | */
27 | public class ProtocalException extends RuntimeException {
28 |
29 | @Getter
30 | private Channel channel;
31 |
32 | public ProtocalException(Channel channel){
33 | this.channel=channel;
34 | }
35 |
36 | public ProtocalException( String msg, Throwable throwable, Channel channel) {
37 | super(msg, throwable);
38 | this.channel=channel;
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-core/src/main/java/link/ttiot/common/core/provider/bean/SimpleBeanProvider.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.core.provider.bean;
18 |
19 | import cn.hutool.core.exceptions.ExceptionUtil;
20 | import cn.hutool.core.exceptions.UtilException;
21 | import lombok.experimental.UtilityClass;
22 |
23 | /**
24 | * @author: shijun
25 | * @date: 2019-04-14
26 | * @description:
27 | */
28 | @UtilityClass
29 | public class SimpleBeanProvider {
30 |
31 | public
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.example.server;
18 |
19 |
20 | import link.ttiot.broker.db.redis.RedisDbHelper;
21 | import link.ttiot.broker.start.ServerLauncher;
22 | import link.ttiot.common.redis.RedisSourceProvider;
23 | import link.ttiot.example.server.exception.ExceptionHandlerDemo;
24 |
25 | /**
26 | * @author: shijun
27 | * @date: 2019-05-05
28 | * @description:
29 | */
30 | public class ServerExampleLauncher {
31 |
32 | public static void main(String[] args) {
33 | new ServerLauncher().dbHelper(new RedisDbHelper(new RedisSourceProvider())).exceptionHandler(new ExceptionHandlerDemo()).launch();
34 | }
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-context/src/main/java/link/ttiot/common/context/exception/ExceptionHandlerAdapter.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.context.exception;
18 |
19 |
20 | import link.ttiot.common.context.Context;
21 | import link.ttiot.common.core.channel.ChannelUtils;
22 | import link.ttiot.common.core.exception.ConnectException;
23 | import lombok.extern.slf4j.Slf4j;
24 |
25 | /**
26 | * @author: shijun
27 | * @date: 2019-04-24
28 | * @description:
29 | */
30 | @Slf4j
31 | public abstract class ExceptionHandlerAdapter implements Thread.UncaughtExceptionHandler {
32 |
33 | /**
34 | * 连接中异常
35 | * @param t
36 | * @param e
37 | */
38 | @Override
39 | public void uncaughtException(Thread t, Throwable e) {
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/ttiot-example/src/main/java/link/ttiot/example/server/listener/LoginLogListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.example.server.listener;
18 |
19 | import link.ttiot.broker.eventor.connect.MqttConnectEvent;
20 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationListener;
21 | import link.ttiot.common.ioc.annotation.Listener;
22 |
23 | /**
24 | * @author: shijun
25 | * @date: 2019-05-06
26 | * @description:
27 | */
28 | @Listener(asynchronous = true)
29 | public class LoginLogListener extends MqttApplicationListener
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.example.server.rule;
18 |
19 | import link.ttiot.common.context.service.DeviceService;
20 | import link.ttiot.common.ioc.annotation.Inject;
21 | import link.ttiot.common.ioc.annotation.Ruler;
22 | import link.ttiot.common.ioc.core.RuleHandler;
23 | import link.ttiot.common.ioc.vo.MqttPayload;
24 |
25 | /**
26 | * @author: shijun
27 | * @date: 2020-03-19
28 | * @description:
29 | */
30 | @Ruler(name = "chat")
31 | public class ChatRuleHandler implements RuleHandler {
32 |
33 | @Inject
34 | private DeviceService deviceService;
35 |
36 | @Override
37 | public void handler(MqttPayload mqttPayloadVo) {
38 | System.out.println(mqttPayloadVo);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/ping/MqttPingEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.ping;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.core.constant.AppProtocalMqttConstant;
23 | import link.ttiot.common.ioc.annotation.Eventor;
24 |
25 |
26 | /**
27 | * @author: shijun
28 | * @date: 2019-04-15
29 | * @description:
30 | */
31 | @Eventor(value = AppProtocalMqttConstant.PINGREQ,auth = true)
32 | public class MqttPingEvent extends MqttApplicationEvent {
33 |
34 | public MqttPingEvent(MqttMessage msg, ChannelHandlerContext context) {
35 | super(msg, context);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/publish/ack/MqttPubAckEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.publish.ack;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.core.constant.AppProtocalMqttConstant;
23 | import link.ttiot.common.ioc.annotation.Eventor;
24 |
25 |
26 | /**
27 | * @author: shijun
28 | * @date: 2019-04-15
29 | * @description:
30 | */
31 | @Eventor(value = AppProtocalMqttConstant.PUBACK)
32 | public class MqttPubAckEvent extends MqttApplicationEvent {
33 |
34 | public MqttPubAckEvent(MqttMessage msg, ChannelHandlerContext context) {
35 | super(msg,context);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/publish/rec/MqttPubRecEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.publish.rec;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.core.constant.AppProtocalMqttConstant;
23 | import link.ttiot.common.ioc.annotation.Eventor;
24 |
25 |
26 | /**
27 | * @author: shijun
28 | * @date: 2019-04-15
29 | * @description:
30 | */
31 | @Eventor(value = AppProtocalMqttConstant.PUBREC)
32 | public class MqttPubRecEvent extends MqttApplicationEvent {
33 |
34 | public MqttPubRecEvent(MqttMessage msg, ChannelHandlerContext context) {
35 | super(msg,context);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/connect/MqttDisConnectEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.connect;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.core.constant.AppProtocalMqttConstant;
23 | import link.ttiot.common.ioc.annotation.Eventor;
24 |
25 |
26 | /**
27 | * @author: shijun
28 | * @date: 2019-04-15
29 | * @description:
30 | */
31 | @Eventor(value = AppProtocalMqttConstant.DISCONNECT)
32 | public class MqttDisConnectEvent extends MqttApplicationEvent {
33 |
34 | public MqttDisConnectEvent(MqttMessage msg, ChannelHandlerContext context) {
35 | super(msg,context);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/decode/MqttDecoderFailEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.decode;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.ioc.annotation.Eventor;
23 |
24 | /**
25 | * @author: shijun
26 | * @date: 2019-04-15
27 | * @description:
28 | */
29 | @Eventor(auth = false)
30 | public class MqttDecoderFailEvent extends MqttApplicationEvent {
31 |
32 | public MqttDecoderFailEvent(MqttMessage msg,ChannelHandlerContext source) {
33 | super(msg,source);
34 | }
35 | @Override
36 | public MqttMessage getSource() {
37 | return (MqttMessage)source;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/publish/comp/MqttPubCompEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.publish.comp;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.core.constant.AppProtocalMqttConstant;
23 | import link.ttiot.common.ioc.annotation.Eventor;
24 |
25 |
26 | /**
27 | * @author: shijun
28 | * @date: 2019-04-15
29 | * @description:
30 | */
31 | @Eventor(value = AppProtocalMqttConstant.PUBCOMP)
32 | public class MqttPubCompEvent extends MqttApplicationEvent {
33 |
34 | public MqttPubCompEvent(MqttMessage msg, ChannelHandlerContext context) {
35 | super(msg,context);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/publish/rel/MqttPubRelEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.publish.rel;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.core.constant.AppProtocalMqttConstant;
23 | import link.ttiot.common.ioc.annotation.Eventor;
24 |
25 |
26 | /**
27 | * @author: shijun
28 | * @date: 2019-04-15
29 | * @description: 收到recive消息之后回复
30 | */
31 | @Eventor(value = AppProtocalMqttConstant.PUBREL)
32 | public class MqttPubRelEvent extends MqttApplicationEvent {
33 |
34 | public MqttPubRelEvent(MqttMessage msg, ChannelHandlerContext context) {
35 | super(msg,context);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-context/src/main/java/link/ttiot/common/context/protocal/mqtt/MqttApplicationEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.context.protocal.mqtt;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.ProtocolApplicationEvent;
22 |
23 | /**
24 | * @author: shijun
25 | * @date: 2019-04-15
26 | * @description:
27 | */
28 | public abstract class MqttApplicationEvent extends ProtocolApplicationEvent {
29 |
30 | public MqttApplicationEvent(MqttMessage mqttMessage, ChannelHandlerContext context) {
31 | super(mqttMessage,context);
32 | }
33 |
34 | @Override
35 | public MqttMessage getSource() {
36 | return (MqttMessage) source;
37 | }
38 |
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/decode/MqttDecoderSuccessEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.decode;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.ioc.annotation.Eventor;
23 |
24 | /**
25 | * @author: shijun
26 | * @date: 2019-04-15
27 | * @description:
28 | */
29 | @Eventor(auth = false)
30 | public class MqttDecoderSuccessEvent extends MqttApplicationEvent {
31 |
32 | public MqttDecoderSuccessEvent( MqttMessage msg,ChannelHandlerContext context) {
33 | super(msg,context);
34 | }
35 | @Override
36 | public MqttMessage getSource() {
37 | return (MqttMessage)source;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ttiot-client-java/src/main/java/link/ttiot/client/java/eventor/decode/MqttDecoderFailEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.client.java.eventor.decode;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.ioc.annotation.Eventor;
23 |
24 | /**
25 | * @author: shijun
26 | * @date: 2019-04-15
27 | * @description:
28 | */
29 | @Eventor(auth = false)
30 | public class MqttDecoderFailEvent extends MqttApplicationEvent {
31 |
32 | public MqttDecoderFailEvent(MqttMessage msg,ChannelHandlerContext source) {
33 | super(msg,source);
34 | }
35 | @Override
36 | public MqttMessage getSource() {
37 | return (MqttMessage)source;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ttiot-client-java/src/main/java/link/ttiot/client/java/eventor/decode/MqttDecoderSuccessEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.client.java.eventor.decode;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.ioc.annotation.Eventor;
23 |
24 | /**
25 | * @author: shijun
26 | * @date: 2019-04-15
27 | * @description:
28 | */
29 | @Eventor(auth = false)
30 | public class MqttDecoderSuccessEvent extends MqttApplicationEvent {
31 |
32 | public MqttDecoderSuccessEvent( MqttMessage msg,ChannelHandlerContext context) {
33 | super(msg,context);
34 | }
35 | @Override
36 | public MqttMessage getSource() {
37 | return (MqttMessage)source;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/ttiot-example/src/main/java/link/ttiot/example/server/http/DemoHttpHandler.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.example.server.http;
18 |
19 | import link.ttiot.common.context.service.DeviceService;
20 | import link.ttiot.common.ioc.annotation.Http;
21 | import link.ttiot.common.ioc.annotation.Inject;
22 | import link.ttiot.common.ioc.core.HttpHandler;
23 | import link.ttiot.common.ioc.vo.HttpRequest;
24 | import link.ttiot.common.ioc.vo.HttpRet;
25 |
26 | /**
27 | * @author: shijun
28 | * @date: 2020-03-25
29 | * @description:
30 | */
31 | @Http(uri = "/demo")
32 | public class DemoHttpHandler implements HttpHandler {
33 |
34 | @Inject
35 | private DeviceService deviceService;
36 |
37 |
38 | @Override
39 | public HttpRet handler(HttpRequest param) {
40 |
41 | return HttpRet.success(param);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-context/src/main/java/link/ttiot/common/context/service/DeviceService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.context.service;
18 |
19 | import link.ttiot.common.context.db.DbHelper;
20 | import link.ttiot.common.ioc.annotation.Inject;
21 | import lombok.Getter;
22 |
23 | import java.util.Optional;
24 |
25 | /**
26 | * @author: shijun
27 | * @date: 2019-04-22
28 | * @description:
29 | */
30 | public class DeviceService{
31 |
32 | @Getter
33 | @Inject
34 | private DbHelper dbHelper;
35 |
36 | public boolean login(String tenantId, String userName, String password) {
37 | return Optional.ofNullable(dbHelper.getDev(tenantId, userName)).
38 | map(u -> u.getClientPassword()
39 | .equals(password))
40 | .orElse(false);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-core/src/main/java/link/ttiot/common/core/constant/AppProtocalMqttConstant.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.core.constant;
18 |
19 | /**
20 | * @author: shijun
21 | * @date: 2019-04-16
22 | * @description:
23 | */
24 | public interface AppProtocalMqttConstant {
25 |
26 | String CONNECT="CONNECT";
27 | String CONNACK="CONNACK";
28 | String PUBLISH="PUBLISH";
29 | String PUBACK="PUBACK";
30 | String PUBREC="PUBREC";
31 | String PUBREL="PUBREL";
32 | String PUBCOMP="PUBCOMP";
33 | String SUBSCRIBE="SUBSCRIBE";
34 | String SUBACK="SUBACK";
35 | String UNSUBSCRIBE="UNSUBSCRIBE";
36 | String UNSUBACK="UNSUBACK";
37 | String PINGREQ="PINGREQ";
38 | String PINGRESP="PINGRESP";
39 | String DISCONNECT="DISCONNECT";
40 | String HTTPREQUEST="httpRequest";
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-context/src/main/java/link/ttiot/common/context/service/SessionService.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.context.service;
18 | import link.ttiot.common.context.Session;
19 | import link.ttiot.common.context.db.DbHelper;
20 | import link.ttiot.common.ioc.annotation.Inject;
21 | import lombok.Getter;
22 |
23 | /**
24 | * @author: shijun
25 | * @date: 2019-05-03
26 | * @description:
27 | */
28 | public class SessionService {
29 |
30 | @Getter
31 | @Inject
32 | private DbHelper dbHelper;
33 |
34 | public void save(Session ttIotSession) {
35 | dbHelper.saveSession(ttIotSession);
36 | }
37 |
38 | public Session get(String clientId) {
39 | return dbHelper.getSession(clientId);
40 | }
41 |
42 | public void delete(String clientId) {
43 | dbHelper.deleteSession(clientId);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/handler/http/KeyValue.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.handler.http;
18 |
19 | /**
20 | * @author: shijun
21 | * @date: 2020-03-03
22 | * @description:
23 | */
24 | public class KeyValue {
25 | private String key;
26 | private String value;
27 |
28 | /**
29 | * @return the key
30 | */
31 | public String getKey() {
32 | return key;
33 | }
34 |
35 | /**
36 | * @return the value
37 | */
38 | public String getValue() {
39 | return value;
40 | }
41 |
42 | /**
43 | * @param key the key to set
44 | */
45 | public void setKey(String key) {
46 | this.key = key;
47 | }
48 |
49 | /**
50 | * @param value the value to set
51 | */
52 | public void setValue(String value) {
53 | this.value = value;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-context/src/main/java/link/ttiot/common/context/protocal/ProtocolApplicationListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.context.protocal;
18 |
19 | import link.ttiot.common.context.Context;
20 | import link.ttiot.common.ioc.core.AbstractApplicationListener;
21 | import link.ttiot.common.ioc.core.ApplicationEvent;
22 |
23 | /**
24 | * @author: shijun
25 | * @date: 2019-04-15
26 | * @description:
27 | */
28 | public abstract class ProtocolApplicationListener
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.connect;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
22 | import link.ttiot.common.ioc.annotation.Eventor;
23 |
24 | /**
25 | * @author: shijun
26 | * @date: 2019-04-15
27 | * @description:
28 | */
29 | @Eventor(auth = false)
30 | public class MqttUnacceptableProtocolVersionExceptionEvent extends MqttApplicationEvent {
31 | public MqttUnacceptableProtocolVersionExceptionEvent( MqttMessage msg,ChannelHandlerContext context) {
32 | super(msg,context);
33 | }
34 | @Override
35 | public MqttMessage getSource() {
36 | return (MqttMessage)source;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/ttiot-common/ttiot-common-ioc/src/main/java/link/ttiot/common/ioc/core/AbstractApplicationListener.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.ioc.core;
18 |
19 | import lombok.Getter;
20 | import lombok.Setter;
21 |
22 | /**
23 | * @author: shijun
24 | * @date: 2019-04-15
25 | * @description:
26 | */
27 | public abstract class AbstractApplicationListener
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.core.constant;
18 |
19 | import io.netty.util.AttributeKey;
20 |
21 | import java.util.List;
22 | import java.util.Set;
23 |
24 | /**
25 | * @author: shijun
26 | * @date: 2019-04-22
27 | * @description:
28 | */
29 | public interface ProtocalConstant {
30 |
31 | String SEPARATOR = "-";
32 | String TERMINATOR = ";";
33 | int CLIENT_IDENTIFY_LENGTH = 21;
34 | char SEPARATORTOPIC_CHAR = '/';
35 | String SEPARATORTOPIC_STRING = "/";
36 | String SEPARATORTOPIC_SINGLE = "+";
37 | String SEPARATORTOPIC_GLOB = "#";
38 | AttributeKey
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.common.context;
18 |
19 | import io.netty.handler.codec.mqtt.MqttPublishMessage;
20 | import link.ttiot.common.core.security.ClientIdReader;
21 | import lombok.AllArgsConstructor;
22 | import lombok.Data;
23 | import lombok.NoArgsConstructor;
24 |
25 | import java.io.Serializable;
26 |
27 | /**
28 | * @author: shijun
29 | * @date: 2019-05-02
30 | * @description:
31 | */
32 | @Data
33 | @AllArgsConstructor
34 | @NoArgsConstructor
35 | public class Session implements Serializable {
36 |
37 | private static final long serialVersionUID = 1L;
38 |
39 | private String clientId;
40 |
41 | private boolean cleanSession;
42 |
43 | private MqttPublishMessage willMessage;
44 |
45 | public String getTenantId() {
46 | return ClientIdReader.tenantId(this.clientId);
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/connect/MqttIdentifierRejectedExceptionEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.connect;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttConnectMessage;
21 | import io.netty.handler.codec.mqtt.MqttMessage;
22 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
23 | import link.ttiot.common.ioc.annotation.Eventor;
24 |
25 | /**
26 | * @author: shijun
27 | * @date: 2019-04-15
28 | * @description:
29 | */
30 | @Eventor(auth = false)
31 | public class MqttIdentifierRejectedExceptionEvent extends MqttApplicationEvent {
32 | public MqttIdentifierRejectedExceptionEvent( MqttMessage msg,ChannelHandlerContext context) {
33 | super(msg,context);
34 | }
35 |
36 | @Override
37 | public MqttConnectMessage getSource() {
38 | return (MqttConnectMessage)source;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/http/HttpRequestEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.http;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.http.FullHttpRequest;
21 | import io.netty.handler.codec.mqtt.MqttMessage;
22 | import link.ttiot.common.context.protocal.ProtocolApplicationEvent;
23 | import link.ttiot.common.core.constant.AppProtocalMqttConstant;
24 | import link.ttiot.common.ioc.annotation.Eventor;
25 |
26 | /**
27 | * @author: shijun
28 | * @date: 2020-03-17
29 | * @description:
30 | */
31 | @Eventor(value = AppProtocalMqttConstant.HTTPREQUEST,auth = false)
32 | public class HttpRequestEvent extends ProtocolApplicationEvent {
33 |
34 | public HttpRequestEvent(Object msg, ChannelHandlerContext context) {
35 | super(msg, context);
36 | }
37 |
38 | @Override
39 | public FullHttpRequest getSource() {
40 | return (FullHttpRequest) source;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/publish/MqttPublishEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.publish;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import io.netty.handler.codec.mqtt.MqttPublishMessage;
22 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
23 | import link.ttiot.common.core.constant.AppProtocalMqttConstant;
24 | import link.ttiot.common.ioc.annotation.Eventor;
25 |
26 |
27 | /**
28 | * @author: shijun
29 | * @date: 2019-04-15
30 | * @description:
31 | */
32 | @Eventor(value = AppProtocalMqttConstant.PUBLISH)
33 | public class MqttPublishEvent extends MqttApplicationEvent {
34 |
35 | public MqttPublishEvent(MqttMessage msg,ChannelHandlerContext context) {
36 | super(msg,context);
37 | }
38 |
39 | @Override
40 | public MqttPublishMessage getSource() {
41 | return (MqttPublishMessage) source;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/connect/MqttConnectEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.connect;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttConnectMessage;
21 | import io.netty.handler.codec.mqtt.MqttMessage;
22 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
23 | import link.ttiot.common.core.constant.AppProtocalMqttConstant;
24 | import link.ttiot.common.ioc.annotation.Eventor;
25 |
26 |
27 | /**
28 | * @author: shijun
29 | * @date: 2019-04-15
30 | * @description:
31 | */
32 | @Eventor(value = AppProtocalMqttConstant.CONNECT,auth = false)
33 | public class MqttConnectEvent extends MqttApplicationEvent {
34 |
35 | public MqttConnectEvent(MqttMessage msg,ChannelHandlerContext context) {
36 | super(msg, context);
37 | }
38 |
39 | @Override
40 | public MqttConnectMessage getSource() {
41 | return (MqttConnectMessage)source;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/eventor/subscribe/MqttSubscribeEvent.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.eventor.subscribe;
18 |
19 | import io.netty.channel.ChannelHandlerContext;
20 | import io.netty.handler.codec.mqtt.MqttMessage;
21 | import io.netty.handler.codec.mqtt.MqttSubscribeMessage;
22 | import link.ttiot.common.context.protocal.mqtt.MqttApplicationEvent;
23 | import link.ttiot.common.core.constant.AppProtocalMqttConstant;
24 | import link.ttiot.common.ioc.annotation.Eventor;
25 |
26 |
27 | /**
28 | * @author: shijun
29 | * @date: 2019-04-15
30 | * @description:
31 | */
32 | @Eventor(value = AppProtocalMqttConstant.SUBSCRIBE)
33 | public class MqttSubscribeEvent extends MqttApplicationEvent {
34 |
35 | public MqttSubscribeEvent(MqttMessage msg,ChannelHandlerContext context) {
36 | super(msg,context);
37 | }
38 |
39 | @Override
40 | public MqttSubscribeMessage getSource() {
41 | return (MqttSubscribeMessage) source;
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/ttiot-broker/src/main/java/link/ttiot/broker/handler/websocket/MqttWebSocketCodec.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright(c) link.ttiot & shijun All rights reserved.
3 | * Licensed under the Apache License, Version 2.0 (the "License");
4 | * you may not use this file except in compliance with the License.
5 | * You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software
10 | * distributed under the License is distributed on an "AS IS" BASIS,
11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | * See the License for the specific language governing permissions and
13 | * limitations under the License.
14 | * Author: shijun (conttononline@outlook.com)
15 | */
16 |
17 | package link.ttiot.broker.handler.websocket;
18 |
19 | import io.netty.buffer.ByteBuf;
20 | import io.netty.channel.ChannelHandlerContext;
21 | import io.netty.handler.codec.MessageToMessageCodec;
22 | import io.netty.handler.codec.http.websocketx.BinaryWebSocketFrame;
23 |
24 | import java.util.List;
25 |
26 | /**
27 | * @author: shijun
28 | * @date: 2020-03-04
29 | * @description:
30 | */
31 | public class MqttWebSocketCodec extends MessageToMessageCodec