7 changed files with 161 additions and 55 deletions
@ -0,0 +1,16 @@ |
|||
package org.thingsboard.server.common.transport; |
|||
|
|||
import org.thingsboard.server.gen.transport.TransportProtos; |
|||
|
|||
/** |
|||
* Created by ashvayka on 04.10.18. |
|||
*/ |
|||
public interface TransportService { |
|||
|
|||
void process(TransportProtos.SessionEventMsg msg); |
|||
|
|||
void process(TransportProtos.PostTelemetryMsg msg); |
|||
|
|||
void process(TransportProtos.PostAttributeMsg msg); |
|||
|
|||
} |
|||
@ -0,0 +1,79 @@ |
|||
/** |
|||
* Copyright © 2016-2018 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
syntax = "proto3"; |
|||
package transport; |
|||
|
|||
option java_package = "org.thingsboard.server.gen.transport"; |
|||
option java_outer_classname = "TransportProtos"; |
|||
|
|||
/** |
|||
* Data Structures; |
|||
*/ |
|||
message SessionInfoProto { |
|||
string nodeId = 1; |
|||
int64 sessionIdMSB = 2; |
|||
int64 sessionIdLSB = 3; |
|||
} |
|||
|
|||
enum SessionEvent { |
|||
OPEN = 0; |
|||
CLOSED = 1; |
|||
} |
|||
|
|||
message KeyValueProto { |
|||
string key = 1; |
|||
bool bool_v = 2; |
|||
int64 long_v = 3; |
|||
double double_v = 4; |
|||
string string_v = 5; |
|||
} |
|||
|
|||
message TsKvListProto { |
|||
int64 ts = 1; |
|||
repeated KeyValueProto kv = 2; |
|||
} |
|||
|
|||
/** |
|||
* Messages that use Data Structures; |
|||
*/ |
|||
message SessionEventMsg { |
|||
SessionInfoProto sessionInfo = 1; |
|||
int64 deviceIdMSB = 2; |
|||
int64 deviceIdLSB = 3; |
|||
} |
|||
|
|||
message PostTelemetryMsg { |
|||
SessionInfoProto sessionInfo = 1; |
|||
repeated TsKvListProto tsKvList = 2; |
|||
} |
|||
|
|||
message PostAttributeMsg { |
|||
SessionInfoProto sessionInfo = 1; |
|||
repeated TsKvListProto tsKvList = 2; |
|||
} |
|||
|
|||
message GetAttributeRequestMsg { |
|||
SessionInfoProto sessionInfo = 1; |
|||
repeated string clientAttributeNames = 2; |
|||
repeated string sharedAttributeNames = 3; |
|||
} |
|||
|
|||
message GetAttributeResponseMsg { |
|||
SessionInfoProto sessionInfo = 1; |
|||
repeated TsKvListProto clientAttributeList = 2; |
|||
repeated TsKvListProto sharedAttributeList = 3; |
|||
repeated string deletedAttributeKeys = 4; |
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package org.thingsboard.server.transport.mqtt; |
|||
|
|||
import io.netty.handler.ssl.SslHandler; |
|||
import lombok.Data; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.context.annotation.Lazy; |
|||
import org.springframework.stereotype.Component; |
|||
import org.thingsboard.server.common.transport.TransportService; |
|||
import org.thingsboard.server.common.transport.quota.host.HostRequestsQuotaService; |
|||
import org.thingsboard.server.transport.mqtt.adaptors.MqttTransportAdaptor; |
|||
|
|||
/** |
|||
* Created by ashvayka on 04.10.18. |
|||
*/ |
|||
@Component |
|||
@Data |
|||
public class MqttTransportContext { |
|||
|
|||
@Autowired |
|||
@Lazy |
|||
private TransportService transportService; |
|||
|
|||
@Autowired(required = false) |
|||
private MqttSslHandlerProvider sslHandlerProvider; |
|||
|
|||
@Autowired(required = false) |
|||
private HostRequestsQuotaService quotaService; |
|||
|
|||
@Autowired |
|||
private MqttTransportAdaptor adaptor; |
|||
|
|||
@Value("${mqtt.netty.max_payload_size}") |
|||
private Integer maxPayloadSize; |
|||
|
|||
private SslHandler sslHandler; |
|||
|
|||
} |
|||
Loading…
Reference in new issue