2024-12-24 10:50:32 +08:00
|
|
|
import 'dart:convert';
|
|
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
2024-12-04 15:00:56 +08:00
|
|
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
|
|
|
|
import 'package:get/get.dart';
|
2024-12-24 10:50:32 +08:00
|
|
|
import 'package:star_lock/talk/startChart/constant/message_type_constant.dart';
|
2024-12-04 15:00:56 +08:00
|
|
|
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 'package:star_lock/talk/startChart/proto/gateway_reset.pb.dart';
|
|
|
|
|
import 'package:star_lock/talk/startChart/proto/generic.pb.dart';
|
2024-12-24 10:50:32 +08:00
|
|
|
import 'package:star_lock/talk/startChart/proto/talk_hangup.pb.dart';
|
2024-12-04 15:00:56 +08:00
|
|
|
|
|
|
|
|
import '../../start_chart_manage.dart';
|
|
|
|
|
|
|
|
|
|
class UdpTalkHangUpHandler extends ScpMessageBaseHandle
|
|
|
|
|
implements ScpMessageHandler {
|
2024-12-09 09:22:58 +08:00
|
|
|
@override
|
|
|
|
|
void handleReq(ScpMessage scpMessage) {
|
2024-12-10 17:27:37 +08:00
|
|
|
// 通话中挂断请求
|
|
|
|
|
print('收到通话中挂断请求');
|
|
|
|
|
startChartManage.sendGenericRespSuccessMessage(
|
|
|
|
|
ToPeerId: scpMessage.FromPeerId!,
|
|
|
|
|
FromPeerId: scpMessage.ToPeerId!,
|
|
|
|
|
PayloadType: scpMessage.PayloadType!,
|
|
|
|
|
);
|
2024-12-10 17:32:06 +08:00
|
|
|
// 停止发送通话保持的命令
|
|
|
|
|
startChartManage.stopTalkPingMessageTimer();
|
|
|
|
|
startChartManage.stopTalkExpectMessageTimer();
|
2024-12-16 16:04:41 +08:00
|
|
|
talkStatus.setHangingUpDuring();
|
2024-12-10 17:27:37 +08:00
|
|
|
talkStatus.setEnd();
|
2024-12-10 18:33:32 +08:00
|
|
|
stopRingtone();
|
2024-12-09 09:22:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void handleResp(ScpMessage scpMessage) {
|
2024-12-10 17:27:37 +08:00
|
|
|
print('收到通话中挂断回复');
|
2024-12-10 17:32:06 +08:00
|
|
|
// 停止发送通话保持的命令
|
|
|
|
|
startChartManage.stopTalkPingMessageTimer();
|
|
|
|
|
startChartManage.stopTalkExpectMessageTimer();
|
2024-12-16 16:04:41 +08:00
|
|
|
talkStatus.setHangingUpDuring();
|
2024-12-10 17:27:37 +08:00
|
|
|
talkStatus.setEnd();
|
2024-12-10 18:33:32 +08:00
|
|
|
stopRingtone();
|
2024-12-09 09:22:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
2024-12-24 10:50:32 +08:00
|
|
|
void handleInvalidReq(ScpMessage scpMessage) {}
|
2024-12-09 09:22:58 +08:00
|
|
|
|
2024-12-04 15:00:56 +08:00
|
|
|
@override
|
2024-12-24 10:50:32 +08:00
|
|
|
void handleRealTimeData(ScpMessage scpMessage) {}
|
2024-12-11 09:32:51 +08:00
|
|
|
|
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}) {
|
|
|
|
|
if (messageType == MessageTypeConstant.Resp) {
|
|
|
|
|
final GenericResp genericResp = GenericResp();
|
|
|
|
|
genericResp.mergeFromBuffer(byte);
|
|
|
|
|
return genericResp;
|
|
|
|
|
} else if (messageType == MessageTypeConstant.RealTimeData) {
|
|
|
|
|
final TalkHangup talkHangup = TalkHangup();
|
|
|
|
|
talkHangup.mergeFromBuffer(byte);
|
|
|
|
|
return talkHangup;
|
|
|
|
|
} else {
|
|
|
|
|
String payload = utf8.decode(byte);
|
|
|
|
|
return payload;
|
|
|
|
|
}
|
2024-12-04 15:00:56 +08:00
|
|
|
}
|
|
|
|
|
}
|