feat: 增加密码连接

This commit is contained in:
2026-07-22 20:32:52 +08:00
parent ef786b1529
commit bdde6ccd2e
19 changed files with 541 additions and 25 deletions

View File

@@ -8,12 +8,16 @@ import 'dart:convert';
/// - [toDeviceId] 接收方设备 ID
/// - [deviceType] 设备类型CONTROLLER / CONTROLLED
/// - [payload] JSON 字符串形式的负载SDP / ICE 候选等)
/// - [authType] 鉴权类型CODE动态验证码/ PASSWORD固定密码
/// - [authValue] 鉴权值:动态验证码或固定密码
class SignalMessage {
final String? type;
final String? fromDeviceId;
final String? toDeviceId;
final String? deviceType;
final String? payload;
final String? authType;
final String? authValue;
const SignalMessage({
this.type,
@@ -21,6 +25,8 @@ class SignalMessage {
this.toDeviceId,
this.deviceType,
this.payload,
this.authType,
this.authValue,
});
factory SignalMessage.fromJson(Map<String, dynamic> json) => SignalMessage(
@@ -29,6 +35,8 @@ class SignalMessage {
toDeviceId: json['toDeviceId'] as String?,
deviceType: json['deviceType'] as String?,
payload: json['payload'] as String?,
authType: json['authType'] as String?,
authValue: json['authValue'] as String?,
);
Map<String, dynamic> toJson() => {
@@ -37,6 +45,8 @@ class SignalMessage {
if (toDeviceId != null) 'toDeviceId': toDeviceId,
if (deviceType != null) 'deviceType': deviceType,
if (payload != null) 'payload': payload,
if (authType != null) 'authType': authType,
if (authValue != null) 'authValue': authValue,
};
/// 便捷构造方法payload 为任意 Map会自动序列化为 JSON 字符串。
@@ -46,6 +56,8 @@ class SignalMessage {
required String toDeviceId,
required String deviceType,
required Map<String, dynamic> payload,
String? authType,
String? authValue,
}) {
return SignalMessage(
type: type,
@@ -53,6 +65,8 @@ class SignalMessage {
toDeviceId: toDeviceId,
deviceType: deviceType,
payload: jsonEncode(payload),
authType: authType,
authValue: authValue,
);
}