mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
新增 netty整合mqtt协议,与车位相机通讯并保存通讯信息
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.jsowell.netty.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/12/19 9:39:48
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class MqttConnectPayload {
|
||||
private String clientIdentifier;
|
||||
private String willTopic;
|
||||
private String willMessage;
|
||||
private String userName;
|
||||
private String password;
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.jsowell.netty.domain;
|
||||
|
||||
import io.netty.handler.codec.mqtt.MqttQoS;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author Lemon
|
||||
* @Date 2023/12/19 8:27:30
|
||||
*/
|
||||
public class MqttRequest {
|
||||
private boolean mutable = true;
|
||||
private byte[] payload;
|
||||
private MqttQoS qos = MqttQoS.AT_MOST_ONCE;
|
||||
private boolean retained = false;
|
||||
private boolean dup = false;
|
||||
private int messageId;
|
||||
|
||||
public MqttRequest() {
|
||||
this.setPayload(new byte[0]);
|
||||
}
|
||||
|
||||
public MqttRequest(byte[] payload) {
|
||||
this.setPayload(payload);
|
||||
}
|
||||
|
||||
public byte[] getPayload() {
|
||||
return this.payload;
|
||||
}
|
||||
|
||||
public void clearPayload() {
|
||||
this.checkMutable();
|
||||
this.payload = new byte[0];
|
||||
}
|
||||
|
||||
public void setPayload(byte[] payload) {
|
||||
this.checkMutable();
|
||||
if (payload == null) {
|
||||
throw new NullPointerException();
|
||||
} else {
|
||||
this.payload = payload;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isRetained() {
|
||||
return this.retained;
|
||||
}
|
||||
|
||||
public void setRetained(boolean retained) {
|
||||
this.checkMutable();
|
||||
this.retained = retained;
|
||||
}
|
||||
|
||||
public MqttQoS getQos() {
|
||||
return qos;
|
||||
}
|
||||
|
||||
public void setQos(MqttQoS qos) {
|
||||
this.qos = qos;
|
||||
}
|
||||
|
||||
public boolean isMutable() {
|
||||
return mutable;
|
||||
}
|
||||
|
||||
public void setMutable(boolean mutable) {
|
||||
this.mutable = mutable;
|
||||
}
|
||||
|
||||
protected void checkMutable() throws IllegalStateException {
|
||||
if (!this.mutable) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isDup() {
|
||||
return dup;
|
||||
}
|
||||
|
||||
public void setDup(boolean dup) {
|
||||
this.dup = dup;
|
||||
}
|
||||
|
||||
public int getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(int messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new String(this.payload);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user