2024-12-24 10:50:32 +08:00
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
2024-12-04 10:52:05 +08:00
|
|
|
import 'package:star_lock/talk/startChart/constant/payload_type_constant.dart';
|
|
|
|
|
import 'package:star_lock/talk/startChart/entity/login_response.dart';
|
|
|
|
|
import 'package:star_lock/talk/startChart/entity/scp_message.dart';
|
|
|
|
|
import 'package:star_lock/talk/startChart/handle/scp_message_base_handle.dart';
|
|
|
|
|
import 'package:star_lock/talk/startChart/handle/scp_message_handle.dart';
|
|
|
|
|
|
|
|
|
|
import '../../start_chart_manage.dart';
|
|
|
|
|
|
|
|
|
|
class UdpGoOnlineHandler extends ScpMessageBaseHandle
|
|
|
|
|
implements ScpMessageHandler {
|
|
|
|
|
@override
|
2024-12-09 09:22:58 +08:00
|
|
|
void handleReq(ScpMessage scpMessage) {
|
|
|
|
|
// TODO: 收到上线消息请求
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void handleResp(ScpMessage scpMessage) {
|
|
|
|
|
// 收到上线消息回复
|
2024-12-04 10:52:05 +08:00
|
|
|
final LoginResponse loginResponse = scpMessage.Payload;
|
|
|
|
|
final responseType = loginResponse.responseType;
|
|
|
|
|
if (responseType != null &&
|
|
|
|
|
responseType == PayloadTypeConstant.loginSuccessResponse) {
|
|
|
|
|
startChartManage.isOnlineStartChartServer = true;
|
|
|
|
|
// 上线成功,停止重发
|
|
|
|
|
startChartManage.stopReStartOnlineStartChartServer();
|
|
|
|
|
log(text: '星图登录成功');
|
|
|
|
|
} else {
|
|
|
|
|
// 上线失败,重发
|
|
|
|
|
startChartManage.reStartOnlineStartChartServer();
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-09 09:22:58 +08:00
|
|
|
|
|
|
|
|
@override
|
2024-12-11 09:32:51 +08:00
|
|
|
void handleInvalidReq(ScpMessage scpMessage) {}
|
2024-12-09 09:22:58 +08:00
|
|
|
|
|
|
|
|
@override
|
2024-12-11 09:32:51 +08:00
|
|
|
void handleRealTimeData(ScpMessage scpMessage) {}
|
2024-12-24 10:50:32 +08:00
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
deserializePayload(
|
|
|
|
|
{required int payloadType,
|
|
|
|
|
required int messageType,
|
|
|
|
|
required Uint8List byte,
|
|
|
|
|
int? offset,
|
|
|
|
|
int? PayloadLength,
|
|
|
|
|
int? spTotal,
|
|
|
|
|
int? spIndex,
|
|
|
|
|
int? messageId}) {
|
|
|
|
|
// 上线
|
|
|
|
|
LoginResponse loginResp = LoginResponse.fromBytes(byte);
|
|
|
|
|
return loginResp;
|
|
|
|
|
}
|
2024-12-04 10:52:05 +08:00
|
|
|
}
|