71 changed files with 136 additions and 1950 deletions
@ -1,35 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.actors.shared; |
|||
|
|||
import lombok.Data; |
|||
import org.thingsboard.server.common.msg.MsgType; |
|||
import org.thingsboard.server.common.msg.TbActorMsg; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class SessionTimeoutMsg implements Serializable, TbActorMsg { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private final SessionId sessionId; |
|||
|
|||
@Override |
|||
public MsgType getMsgType() { |
|||
return MsgType.SESSION_TIMEOUT_MSG; |
|||
} |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.aware; |
|||
|
|||
public interface SessionAwareMsg { |
|||
|
|||
SessionId getSessionId(); |
|||
|
|||
} |
|||
@ -1,30 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import org.thingsboard.server.common.msg.TbActorMsg; |
|||
import org.thingsboard.server.common.msg.aware.SessionAwareMsg; |
|||
import org.thingsboard.server.common.msg.session.ToDeviceMsg; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
public interface ActorSystemToDeviceSessionActorMsg extends SessionAwareMsg, Serializable, TbActorMsg { |
|||
|
|||
ToDeviceMsg getMsg(); |
|||
} |
|||
@ -1,29 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
public class AttributesSubscribeMsg implements FromDeviceMsg { |
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.SUBSCRIBE_ATTRIBUTES_REQUEST; |
|||
} |
|||
} |
|||
@ -1,30 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
public class AttributesUnsubscribeMsg implements FromDeviceMsg { |
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.UNSUBSCRIBE_ATTRIBUTES_REQUEST; |
|||
} |
|||
} |
|||
@ -1,47 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.msg.kv.AttributesKVMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.ToDeviceMsg; |
|||
|
|||
@ToString |
|||
public class AttributesUpdateNotification implements ToDeviceMsg { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private AttributesKVMsg data; |
|||
|
|||
public AttributesUpdateNotification(AttributesKVMsg data) { |
|||
this.data = data; |
|||
} |
|||
|
|||
@Override |
|||
public boolean isSuccess() { |
|||
return true; |
|||
} |
|||
|
|||
public SessionMsgType getSessionMsgType() { |
|||
return SessionMsgType.ATTRIBUTES_UPDATE_NOTIFICATION; |
|||
} |
|||
|
|||
public AttributesKVMsg getData() { |
|||
return data; |
|||
} |
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import java.util.Set; |
|||
|
|||
import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
|||
import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
|||
import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg; |
|||
|
|||
public interface AttributesUpdateRequest extends FromDeviceRequestMsg { |
|||
|
|||
Set<AttributeKvEntry> getAttributes(); |
|||
|
|||
} |
|||
@ -1,63 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import java.util.Collection; |
|||
import java.util.LinkedHashSet; |
|||
import java.util.Set; |
|||
|
|||
import org.thingsboard.server.common.data.kv.AttributeKvEntry; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
public class BasicAttributesUpdateRequest extends BasicRequest implements AttributesUpdateRequest { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private final Set<AttributeKvEntry> data; |
|||
|
|||
public BasicAttributesUpdateRequest() { |
|||
this(DEFAULT_REQUEST_ID); |
|||
} |
|||
|
|||
public BasicAttributesUpdateRequest(Integer requestId) { |
|||
super(requestId); |
|||
this.data = new LinkedHashSet<>(); |
|||
} |
|||
|
|||
public void add(AttributeKvEntry entry) { |
|||
this.data.add(entry); |
|||
} |
|||
|
|||
public void add(Collection<AttributeKvEntry> entries) { |
|||
this.data.addAll(entries); |
|||
} |
|||
|
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.POST_ATTRIBUTES_REQUEST; |
|||
} |
|||
|
|||
@Override |
|||
public Set<AttributeKvEntry> getAttributes() { |
|||
return data; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "BasicAttributesUpdateRequest [data=" + data + "]"; |
|||
} |
|||
|
|||
} |
|||
@ -1,45 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
public class BasicCommandAckResponse extends BasicResponseMsg<Integer> implements StatusCodeResponse { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
public static BasicCommandAckResponse onSuccess(SessionMsgType requestMsgType, Integer requestId) { |
|||
return BasicCommandAckResponse.onSuccess(requestMsgType, requestId, 200); |
|||
} |
|||
|
|||
public static BasicCommandAckResponse onSuccess(SessionMsgType requestMsgType, Integer requestId, Integer code) { |
|||
return new BasicCommandAckResponse(requestMsgType, requestId, true, null, code); |
|||
} |
|||
|
|||
public static BasicCommandAckResponse onError(SessionMsgType requestMsgType, Integer requestId, Exception error) { |
|||
return new BasicCommandAckResponse(requestMsgType, requestId, false, error, null); |
|||
} |
|||
|
|||
private BasicCommandAckResponse(SessionMsgType requestMsgType, Integer requestId, boolean success, Exception error, Integer code) { |
|||
super(requestMsgType, requestId, SessionMsgType.TO_DEVICE_RPC_RESPONSE_ACK, success, error, code); |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "BasicStatusCodeResponse []"; |
|||
} |
|||
} |
|||
@ -1,59 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
import java.util.Collections; |
|||
import java.util.Optional; |
|||
import java.util.Set; |
|||
|
|||
@ToString |
|||
public class BasicGetAttributesRequest extends BasicRequest implements GetAttributesRequest { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private final Set<String> clientKeys; |
|||
private final Set<String> sharedKeys; |
|||
|
|||
public BasicGetAttributesRequest(Integer requestId) { |
|||
this(requestId, Collections.emptySet(), Collections.emptySet()); |
|||
} |
|||
|
|||
public BasicGetAttributesRequest(Integer requestId, Set<String> clientKeys, Set<String> sharedKeys) { |
|||
super(requestId); |
|||
this.clientKeys = clientKeys; |
|||
this.sharedKeys = sharedKeys; |
|||
} |
|||
|
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.GET_ATTRIBUTES_REQUEST; |
|||
} |
|||
|
|||
@Override |
|||
public Optional<Set<String>> getClientAttributeNames() { |
|||
return Optional.ofNullable(clientKeys); |
|||
} |
|||
|
|||
@Override |
|||
public Optional<Set<String>> getSharedAttributeNames() { |
|||
return Optional.ofNullable(sharedKeys); |
|||
} |
|||
|
|||
} |
|||
@ -1,40 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.msg.kv.AttributesKVMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
@ToString |
|||
public class BasicGetAttributesResponse extends BasicResponseMsg<AttributesKVMsg> implements GetAttributesResponse { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
public static BasicGetAttributesResponse onSuccess(SessionMsgType requestMsgType, int requestId, AttributesKVMsg code) { |
|||
return new BasicGetAttributesResponse(requestMsgType, requestId, true, null, code); |
|||
} |
|||
|
|||
public static BasicGetAttributesResponse onError(SessionMsgType requestMsgType, int requestId, Exception error) { |
|||
return new BasicGetAttributesResponse(requestMsgType, requestId, false, error, null); |
|||
} |
|||
|
|||
private BasicGetAttributesResponse(SessionMsgType requestMsgType, int requestId, boolean success, Exception error, AttributesKVMsg code) { |
|||
super(requestMsgType, requestId, SessionMsgType.GET_ATTRIBUTES_RESPONSE, success, error, code); |
|||
} |
|||
|
|||
} |
|||
@ -1,36 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
public class BasicRequest implements Serializable { |
|||
|
|||
public static final Integer DEFAULT_REQUEST_ID = 0; |
|||
|
|||
private final Integer requestId; |
|||
|
|||
public BasicRequest(Integer requestId) { |
|||
this.requestId = requestId; |
|||
} |
|||
|
|||
public Integer getRequestId() { |
|||
return requestId; |
|||
} |
|||
} |
|||
@ -1,79 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Optional; |
|||
|
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
|
|||
public class BasicResponseMsg<T extends Serializable> implements ResponseMsg<T> { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private final SessionMsgType requestMsgType; |
|||
private final Integer requestId; |
|||
private final SessionMsgType sessionMsgType; |
|||
private final boolean success; |
|||
private final T data; |
|||
private final Exception error; |
|||
|
|||
protected BasicResponseMsg(SessionMsgType requestMsgType, Integer requestId, SessionMsgType sessionMsgType, boolean success, Exception error, T data) { |
|||
super(); |
|||
this.requestMsgType = requestMsgType; |
|||
this.requestId = requestId; |
|||
this.sessionMsgType = sessionMsgType; |
|||
this.success = success; |
|||
this.error = error; |
|||
this.data = data; |
|||
} |
|||
|
|||
@Override |
|||
public SessionMsgType getRequestMsgType() { |
|||
return requestMsgType; |
|||
} |
|||
|
|||
@Override |
|||
public Integer getRequestId() { |
|||
return requestId; |
|||
} |
|||
|
|||
@Override |
|||
public boolean isSuccess() { |
|||
return success; |
|||
} |
|||
|
|||
@Override |
|||
public Optional<Exception> getError() { |
|||
return Optional.ofNullable(error); |
|||
} |
|||
|
|||
@Override |
|||
public Optional<T> getData() { |
|||
return Optional.ofNullable(data); |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "BasicResponseMsg [success=" + success + ", data=" + data + ", error=" + error + "]"; |
|||
} |
|||
|
|||
public SessionMsgType getSessionMsgType() { |
|||
return sessionMsgType; |
|||
} |
|||
} |
|||
@ -1,42 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
@ToString |
|||
public class BasicStatusCodeResponse extends BasicResponseMsg<Integer> implements StatusCodeResponse { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
public static BasicStatusCodeResponse onSuccess(SessionMsgType requestMsgType, Integer requestId) { |
|||
return BasicStatusCodeResponse.onSuccess(requestMsgType, requestId, 0); |
|||
} |
|||
|
|||
public static BasicStatusCodeResponse onSuccess(SessionMsgType requestMsgType, Integer requestId, Integer code) { |
|||
return new BasicStatusCodeResponse(requestMsgType, requestId, true, null, code); |
|||
} |
|||
|
|||
public static BasicStatusCodeResponse onError(SessionMsgType requestMsgType, Integer requestId, Exception error) { |
|||
return new BasicStatusCodeResponse(requestMsgType, requestId, false, error, null); |
|||
} |
|||
|
|||
private BasicStatusCodeResponse(SessionMsgType requestMsgType, Integer requestId, boolean success, Exception error, Integer code) { |
|||
super(requestMsgType, requestId, SessionMsgType.STATUS_CODE_RESPONSE, success, error, code); |
|||
} |
|||
} |
|||
@ -1,66 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.thingsboard.server.common.data.kv.KvEntry; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
public class BasicTelemetryUploadRequest extends BasicRequest implements TelemetryUploadRequest { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
private final Map<Long, List<KvEntry>> data; |
|||
|
|||
public BasicTelemetryUploadRequest() { |
|||
this(DEFAULT_REQUEST_ID); |
|||
} |
|||
|
|||
public BasicTelemetryUploadRequest(Integer requestId) { |
|||
super(requestId); |
|||
this.data = new HashMap<>(); |
|||
} |
|||
|
|||
public void add(long ts, KvEntry entry) { |
|||
List<KvEntry> tsEntries = data.get(ts); |
|||
if (tsEntries == null) { |
|||
tsEntries = new ArrayList<>(); |
|||
data.put(ts, tsEntries); |
|||
} |
|||
tsEntries.add(entry); |
|||
} |
|||
|
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.POST_TELEMETRY_REQUEST; |
|||
} |
|||
|
|||
@Override |
|||
public Map<Long, List<KvEntry>> getData() { |
|||
return data; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "BasicTelemetryUploadRequest [data=" + data + "]"; |
|||
} |
|||
|
|||
} |
|||
@ -1,29 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import java.util.Optional; |
|||
import java.util.Set; |
|||
|
|||
import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
|||
import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg; |
|||
|
|||
public interface GetAttributesRequest extends FromDeviceRequestMsg { |
|||
|
|||
Optional<Set<String>> getClientAttributeNames(); |
|||
Optional<Set<String>> getSharedAttributeNames(); |
|||
|
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import org.thingsboard.server.common.msg.kv.AttributesKVMsg; |
|||
|
|||
public interface GetAttributesResponse extends ResponseMsg<AttributesKVMsg> { |
|||
|
|||
} |
|||
@ -1,33 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Optional; |
|||
|
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.ToDeviceMsg; |
|||
|
|||
public interface ResponseMsg<T extends Serializable> extends ToDeviceMsg { |
|||
|
|||
SessionMsgType getRequestMsgType(); |
|||
|
|||
Integer getRequestId(); |
|||
|
|||
Optional<Exception> getError(); |
|||
|
|||
Optional<T> getData(); |
|||
} |
|||
@ -1,30 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
public class RpcSubscribeMsg implements FromDeviceMsg { |
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.SUBSCRIBE_RPC_COMMANDS_REQUEST; |
|||
} |
|||
} |
|||
@ -1,30 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
public class RpcUnsubscribeMsg implements FromDeviceMsg { |
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.UNSUBSCRIBE_RPC_COMMANDS_REQUEST; |
|||
} |
|||
} |
|||
@ -1,43 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
|
|||
public enum RuleEngineError { |
|||
|
|||
QUEUE_PUT_TIMEOUT(true), SERVER_ERROR(true), TIMEOUT; |
|||
|
|||
private final boolean critical; |
|||
|
|||
RuleEngineError() { |
|||
this(false); |
|||
} |
|||
|
|||
RuleEngineError(boolean critical) { |
|||
this.critical = critical; |
|||
} |
|||
|
|||
public boolean isCritical() { |
|||
return critical; |
|||
} |
|||
|
|||
public int getPriority() { |
|||
return ordinal(); |
|||
} |
|||
} |
|||
@ -1,53 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import lombok.Data; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.ToDeviceMsg; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
@Data |
|||
public class RuleEngineErrorMsg implements ToDeviceMsg { |
|||
|
|||
private final SessionMsgType inSessionMsgType; |
|||
private final RuleEngineError error; |
|||
|
|||
@Override |
|||
public boolean isSuccess() { |
|||
return false; |
|||
} |
|||
|
|||
public SessionMsgType getSessionMsgType() { |
|||
return SessionMsgType.RULE_ENGINE_ERROR; |
|||
} |
|||
|
|||
public String getErrorMsg() { |
|||
switch (error) { |
|||
case QUEUE_PUT_TIMEOUT: |
|||
return "Timeout during persistence of the message to the queue!"; |
|||
case SERVER_ERROR: |
|||
return "Error during processing of message by the server!"; |
|||
case TIMEOUT: |
|||
return "Timeout during processing of message by the server!"; |
|||
default: |
|||
throw new RuntimeException("Error " + error + " is not supported!"); |
|||
} |
|||
} |
|||
} |
|||
@ -1,30 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
public class SessionCloseMsg implements FromDeviceMsg { |
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.SESSION_CLOSE; |
|||
} |
|||
} |
|||
@ -1,38 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import lombok.ToString; |
|||
import org.thingsboard.server.common.msg.kv.AttributesKVMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.ToDeviceMsg; |
|||
|
|||
@ToString |
|||
public class SessionCloseNotification implements ToDeviceMsg { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
@Override |
|||
public boolean isSuccess() { |
|||
return true; |
|||
} |
|||
|
|||
public SessionMsgType getSessionMsgType() { |
|||
return SessionMsgType.SESSION_CLOSE; |
|||
} |
|||
|
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import lombok.Data; |
|||
import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
@Data |
|||
public class SessionOpenMsg implements FromDeviceMsg { |
|||
|
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.SESSION_OPEN; |
|||
} |
|||
} |
|||
@ -1,20 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
public interface StatusCodeResponse extends ResponseMsg<Integer>{ |
|||
|
|||
} |
|||
@ -1,29 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
import org.thingsboard.server.common.data.kv.KvEntry; |
|||
import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
|||
import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg; |
|||
|
|||
public interface TelemetryUploadRequest extends FromDeviceRequestMsg { |
|||
|
|||
Map<Long, List<KvEntry>> getData(); |
|||
|
|||
} |
|||
@ -1,41 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import lombok.Data; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.ToDeviceMsg; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
@Data |
|||
public class ToDeviceRpcRequestMsg implements ToDeviceMsg { |
|||
|
|||
private final int requestId; |
|||
private final String method; |
|||
private final String params; |
|||
|
|||
public SessionMsgType getSessionMsgType() { |
|||
return SessionMsgType.TO_DEVICE_RPC_REQUEST; |
|||
} |
|||
|
|||
@Override |
|||
public boolean isSuccess() { |
|||
return true; |
|||
} |
|||
} |
|||
@ -1,36 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import lombok.Data; |
|||
import org.thingsboard.server.common.msg.session.FromDeviceMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
@Data |
|||
public class ToDeviceRpcResponseMsg implements FromDeviceMsg { |
|||
|
|||
private final int requestId; |
|||
private final String data; |
|||
|
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.TO_DEVICE_RPC_RESPONSE; |
|||
} |
|||
} |
|||
@ -1,36 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.core; |
|||
|
|||
import lombok.Data; |
|||
import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg; |
|||
import org.thingsboard.server.common.msg.session.SessionMsgType; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
@Data |
|||
public class ToServerRpcRequestMsg implements FromDeviceRequestMsg { |
|||
|
|||
private final Integer requestId; |
|||
private final String method; |
|||
private final String params; |
|||
|
|||
@Override |
|||
public SessionMsgType getMsgType() { |
|||
return SessionMsgType.TO_SERVER_RPC_REQUEST; |
|||
} |
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
public interface AdaptorToSessionActorMsg extends SessionMsg { |
|||
|
|||
FromDeviceMsg getMsg(); |
|||
|
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
public class BasicAdaptorToSessionActorMsg extends BasicSessionMsg implements AdaptorToSessionActorMsg { |
|||
|
|||
private final FromDeviceMsg msg; |
|||
|
|||
public BasicAdaptorToSessionActorMsg(SessionContext ctx, FromDeviceMsg msg) { |
|||
super(ctx); |
|||
this.msg = msg; |
|||
} |
|||
|
|||
@Override |
|||
public FromDeviceMsg getMsg() { |
|||
return msg; |
|||
} |
|||
|
|||
} |
|||
@ -1,32 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
public class BasicSessionActorToAdaptorMsg extends BasicSessionMsg implements SessionActorToAdaptorMsg { |
|||
|
|||
private final ToDeviceMsg msg; |
|||
|
|||
public BasicSessionActorToAdaptorMsg(SessionContext ctx, ToDeviceMsg msg) { |
|||
super(ctx); |
|||
this.msg = msg; |
|||
} |
|||
|
|||
@Override |
|||
public ToDeviceMsg getMsg() { |
|||
return msg; |
|||
} |
|||
|
|||
} |
|||
@ -1,42 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
public class BasicSessionMsg implements SessionMsg { |
|||
|
|||
private final SessionContext ctx; |
|||
|
|||
public BasicSessionMsg(SessionContext ctx) { |
|||
super(); |
|||
this.ctx = ctx; |
|||
} |
|||
|
|||
@Override |
|||
public SessionId getSessionId() { |
|||
return ctx.getSessionId(); |
|||
} |
|||
|
|||
@Override |
|||
public SessionContext getSessionContext() { |
|||
return ctx; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "BasicSessionMsg [ctx=" + ctx + "]"; |
|||
} |
|||
|
|||
} |
|||
@ -1,73 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
import org.thingsboard.server.common.data.Device; |
|||
import org.thingsboard.server.common.data.id.CustomerId; |
|||
import org.thingsboard.server.common.data.id.DeviceId; |
|||
import org.thingsboard.server.common.data.id.TenantId; |
|||
import org.thingsboard.server.common.msg.MsgType; |
|||
|
|||
public class BasicTransportToDeviceSessionActorMsg implements TransportToDeviceSessionActorMsg { |
|||
|
|||
private final TenantId tenantId; |
|||
private final CustomerId customerId; |
|||
private final DeviceId deviceId; |
|||
private final AdaptorToSessionActorMsg msg; |
|||
|
|||
public BasicTransportToDeviceSessionActorMsg(Device device, AdaptorToSessionActorMsg msg) { |
|||
super(); |
|||
this.tenantId = device.getTenantId(); |
|||
this.customerId = device.getCustomerId(); |
|||
this.deviceId = device.getId(); |
|||
this.msg = msg; |
|||
} |
|||
|
|||
@Override |
|||
public DeviceId getDeviceId() { |
|||
return deviceId; |
|||
} |
|||
|
|||
@Override |
|||
public CustomerId getCustomerId() { |
|||
return customerId; |
|||
} |
|||
|
|||
public TenantId getTenantId() { |
|||
return tenantId; |
|||
} |
|||
|
|||
@Override |
|||
public SessionId getSessionId() { |
|||
return msg.getSessionId(); |
|||
} |
|||
|
|||
@Override |
|||
public AdaptorToSessionActorMsg getSessionMsg() { |
|||
return msg; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "BasicTransportToDeviceSessionActorMsg [tenantId=" + tenantId + ", customerId=" + customerId + ", deviceId=" + deviceId + ", msg=" + msg |
|||
+ "]"; |
|||
} |
|||
|
|||
@Override |
|||
public MsgType getMsgType() { |
|||
return MsgType.TRANSPORT_TO_DEVICE_SESSION_ACTOR_MSG; |
|||
} |
|||
} |
|||
@ -1,24 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
public interface FromDeviceMsg extends Serializable { |
|||
|
|||
SessionMsgType getMsgType(); |
|||
|
|||
} |
|||
@ -1,25 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
public interface FromDeviceRequestMsg extends FromDeviceMsg { |
|||
|
|||
Integer getRequestId(); |
|||
|
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
public interface SessionActorToAdaptorMsg extends SessionMsg { |
|||
|
|||
ToDeviceMsg getMsg(); |
|||
|
|||
} |
|||
@ -1,23 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
import org.thingsboard.server.common.msg.TbActorMsg; |
|||
import org.thingsboard.server.common.msg.aware.SessionAwareMsg; |
|||
|
|||
public interface SessionCtrlMsg extends SessionAwareMsg, TbActorMsg { |
|||
|
|||
} |
|||
@ -1,24 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
import org.thingsboard.server.common.msg.aware.SessionAwareMsg; |
|||
|
|||
public interface SessionMsg extends SessionAwareMsg { |
|||
|
|||
SessionContext getSessionContext(); |
|||
|
|||
} |
|||
@ -1,22 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
public enum SessionType { |
|||
|
|||
SYNC, ASYNC; |
|||
|
|||
} |
|||
@ -1,26 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
public interface ToDeviceMsg extends Serializable { |
|||
|
|||
boolean isSuccess(); |
|||
|
|||
SessionMsgType getSessionMsgType(); |
|||
|
|||
} |
|||
@ -1,28 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session; |
|||
|
|||
import org.thingsboard.server.common.msg.TbActorMsg; |
|||
import org.thingsboard.server.common.msg.aware.CustomerAwareMsg; |
|||
import org.thingsboard.server.common.msg.aware.DeviceAwareMsg; |
|||
import org.thingsboard.server.common.msg.aware.SessionAwareMsg; |
|||
import org.thingsboard.server.common.msg.aware.TenantAwareMsg; |
|||
|
|||
public interface TransportToDeviceSessionActorMsg extends DeviceAwareMsg, CustomerAwareMsg, TenantAwareMsg, SessionAwareMsg, TbActorMsg { |
|||
|
|||
AdaptorToSessionActorMsg getSessionMsg(); |
|||
|
|||
} |
|||
@ -1,67 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.common.msg.session.ctrl; |
|||
|
|||
import org.thingsboard.server.common.msg.MsgType; |
|||
import org.thingsboard.server.common.msg.session.SessionCtrlMsg; |
|||
|
|||
public class SessionCloseMsg implements SessionCtrlMsg { |
|||
|
|||
private final SessionId sessionId; |
|||
private final boolean revoked; |
|||
private final boolean timeout; |
|||
|
|||
public static SessionCloseMsg onDisconnect(SessionId sessionId) { |
|||
return new SessionCloseMsg(sessionId, false, false); |
|||
} |
|||
|
|||
public static SessionCloseMsg onError(SessionId sessionId) { |
|||
return new SessionCloseMsg(sessionId, false, false); |
|||
} |
|||
|
|||
public static SessionCloseMsg onTimeout(SessionId sessionId) { |
|||
return new SessionCloseMsg(sessionId, false, true); |
|||
} |
|||
|
|||
public static SessionCloseMsg onCredentialsRevoked(SessionId sessionId) { |
|||
return new SessionCloseMsg(sessionId, true, false); |
|||
} |
|||
|
|||
private SessionCloseMsg(SessionId sessionId, boolean unauthorized, boolean timeout) { |
|||
super(); |
|||
this.sessionId = sessionId; |
|||
this.revoked = unauthorized; |
|||
this.timeout = timeout; |
|||
} |
|||
|
|||
@Override |
|||
public SessionId getSessionId() { |
|||
return sessionId; |
|||
} |
|||
|
|||
public boolean isCredentialsRevoked() { |
|||
return revoked; |
|||
} |
|||
|
|||
public boolean isTimeout() { |
|||
return timeout; |
|||
} |
|||
|
|||
@Override |
|||
public MsgType getMsgType() { |
|||
return MsgType.SESSION_CTRL_MSG; |
|||
} |
|||
} |
|||
@ -1,60 +0,0 @@ |
|||
/** |
|||
* 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. |
|||
*/ |
|||
package org.thingsboard.server.transport.mqtt.session; |
|||
|
|||
import java.util.concurrent.atomic.AtomicLong; |
|||
|
|||
/** |
|||
* @author Andrew Shvayka |
|||
*/ |
|||
public class MqttSessionId implements SessionId { |
|||
|
|||
private static final AtomicLong idSeq = new AtomicLong(); |
|||
|
|||
private final long id; |
|||
|
|||
public MqttSessionId() { |
|||
this.id = idSeq.incrementAndGet(); |
|||
} |
|||
|
|||
@Override |
|||
public boolean equals(Object o) { |
|||
if (this == o) return true; |
|||
if (o == null || getClass() != o.getClass()) return false; |
|||
|
|||
MqttSessionId that = (MqttSessionId) o; |
|||
|
|||
return id == that.id; |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "MqttSessionId{" + |
|||
"id=" + id + |
|||
'}'; |
|||
} |
|||
|
|||
@Override |
|||
public int hashCode() { |
|||
return (int) (id ^ (id >>> 32)); |
|||
} |
|||
|
|||
@Override |
|||
public String toUidStr() { |
|||
return "mqtt" + id; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue