|
|
@@ -125,12 +125,12 @@ class MsgHandler { |
|
|
|
|
|
|
|
static createSendMsg(ChatType chatType, content,
|
|
|
|
{int extra,
|
|
|
|
int friendId,
|
|
|
|
String localFile,
|
|
|
|
MsgModel refMsg,
|
|
|
|
String refShortTxt,
|
|
|
|
List<int> altUsers,
|
|
|
|
ChatChannelType channelType = ChatChannelType.Session}) {
|
|
|
|
int friendId,
|
|
|
|
String localFile,
|
|
|
|
MsgModel refMsg,
|
|
|
|
String refShortTxt,
|
|
|
|
List<int> altUsers,
|
|
|
|
ChatChannelType channelType = ChatChannelType.Session}) {
|
|
|
|
MsgModel msg;
|
|
|
|
|
|
|
|
if (content is String) {
|
|
|
@@ -248,7 +248,7 @@ class MsgHandler { |
|
|
|
seq.channelType = ChatChannelType.CSD;
|
|
|
|
} else {
|
|
|
|
seq.channelType =
|
|
|
|
isGroup ? ChatChannelType.Group : ChatChannelType.Session;
|
|
|
|
isGroup ? ChatChannelType.Group : ChatChannelType.Session;
|
|
|
|
}
|
|
|
|
|
|
|
|
NetWork().sendMsg(ComId.Chat, 5, seq);
|
|
|
@@ -258,7 +258,6 @@ class MsgHandler { |
|
|
|
static int mLastClickTime = 0;
|
|
|
|
static int timeInterval = 2500;
|
|
|
|
static handlerReceiveMsg(PushChat chat) async {
|
|
|
|
|
|
|
|
bool isGroup = false;
|
|
|
|
bool isTranslateHK = false;
|
|
|
|
if (chat.channelType == ChatChannelType.Group) {
|
|
|
@@ -267,7 +266,7 @@ class MsgHandler { |
|
|
|
} else if (chat.channelType == ChatChannelType.TransHK) {
|
|
|
|
print('聊天管家消息');
|
|
|
|
isTranslateHK = true;
|
|
|
|
}else if (chat.channelType == ChatChannelType.CSD) {
|
|
|
|
} else if (chat.channelType == ChatChannelType.CSD) {
|
|
|
|
print('反馈消息');
|
|
|
|
}
|
|
|
|
|
|
|
@@ -276,6 +275,7 @@ class MsgHandler { |
|
|
|
//更新消息
|
|
|
|
print('服务器更新消息');
|
|
|
|
|
|
|
|
|
|
|
|
MsgModel findMsg;
|
|
|
|
int sessionId = chat.targetId;
|
|
|
|
var msgList;
|
|
|
@@ -305,6 +305,7 @@ class MsgHandler { |
|
|
|
ChatDataMgr().updateLastMsgWithTranslateMsg(chat);
|
|
|
|
SqlUtil().updateUserTranslateContent(chat.targetId,
|
|
|
|
chat.sendTime.toInt(), chat.humanTranslate, chat.translateState);
|
|
|
|
MessageMgr().emit('Update Translate Message', findMsg);
|
|
|
|
} else if (chat.translateState == 3 || chat.translateState == 2) {
|
|
|
|
print('机器翻译结果更新');
|
|
|
|
|
|
|
@@ -318,10 +319,17 @@ class MsgHandler { |
|
|
|
chat.tencentTranslate,
|
|
|
|
chat.googleTranslate,
|
|
|
|
chat.translateState);
|
|
|
|
}
|
|
|
|
MessageMgr().emit('Update Translate Message', findMsg);
|
|
|
|
} else if (chat.translateState == 5 || chat.translateState == 6) {
|
|
|
|
//5翻译失败,6翻译跳过
|
|
|
|
print('人工翻译结果更新${chat.targetId},${chat.translateState}');
|
|
|
|
findMsg.translateContent = chat.humanTranslate;
|
|
|
|
|
|
|
|
MessageMgr().emit('Update Translate Message', findMsg);
|
|
|
|
}else{
|
|
|
|
SqlUtil().updateUserTranslateContent(chat.targetId,
|
|
|
|
chat.sendTime.toInt(), chat.humanTranslate, chat.translateState);
|
|
|
|
MessageMgr().emit('Update Translate Message', findMsg);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
debugPrint2('更新消息找不到!!!!!!');
|
|
|
|
}
|
|
|
|
} else {
|
|
|
@@ -420,51 +428,46 @@ class MsgHandler { |
|
|
|
}
|
|
|
|
} else if (isTranslateHK) {
|
|
|
|
var myId = UserData().basicInfo.userId;
|
|
|
|
TransHKChatNotice notice = TransHKChatNotice.fromBuffer(chat.contentBuff);
|
|
|
|
BaseUserInfo friendId ;
|
|
|
|
TranslateHKMgr().isUser = myId== notice.employer.id; ///判断自己是翻译官还是用户
|
|
|
|
TransHKChatNotice notice =
|
|
|
|
TransHKChatNotice.fromBuffer(chat.contentBuff);
|
|
|
|
BaseUserInfo friendId;
|
|
|
|
TranslateHKMgr().isUser = myId == notice.employer.id;
|
|
|
|
|
|
|
|
///判断自己是翻译官还是用户
|
|
|
|
|
|
|
|
if(myId== notice.employer.id){
|
|
|
|
friendId =notice.inter;
|
|
|
|
}else{
|
|
|
|
if (myId == notice.employer.id) {
|
|
|
|
friendId = notice.inter;
|
|
|
|
} else {
|
|
|
|
friendId = notice.employer;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print('friend id: ${friendId.id} ');
|
|
|
|
print('结束chat.sendTime ${chat.sendTime}');
|
|
|
|
int sessionId = chat.targetId;
|
|
|
|
if (chat.cType == ChatType.GroupChatNoticeType) {
|
|
|
|
|
|
|
|
msgModel = MsgModel(0, friendId.id, chat.cType.value,
|
|
|
|
chat.contentBuff, chat.sendTime.toInt(), sessionId,
|
|
|
|
channelType: ChatChannelType.Session.value);
|
|
|
|
}
|
|
|
|
|
|
|
|
///接到开始翻译管家消息-打开翻译管家聊天页面
|
|
|
|
if(notice.noticeType==TransHKChatNoticeType.StartChat){
|
|
|
|
|
|
|
|
if(ChatPage.isChatPageActive){
|
|
|
|
if (notice.noticeType == TransHKChatNoticeType.StartChat) {
|
|
|
|
if (ChatPage.isChatPageActive) {
|
|
|
|
Navigator.of(context).pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Future.delayed(Duration(seconds: 1),(){
|
|
|
|
Future.delayed(Duration(seconds: 1), () {
|
|
|
|
TranslateHKMgr().orderStatus = TranslateHKMgr.ORDER_STATUS_EMPTY;
|
|
|
|
MessageMgr().emit(MessageMgr.TRANSLATE_HK_REFRESH_ORDER );
|
|
|
|
MessageMgr().emit(MessageMgr.TRANSLATE_HK_REFRESH_ORDER);
|
|
|
|
|
|
|
|
curActiveSession = sessionId;
|
|
|
|
print('curActiveSession:$curActiveSession');
|
|
|
|
MessageMgr().emit(MessageMgr.TRANSLATE_HK_START_CHAT, friendId.id);
|
|
|
|
MessageMgr()
|
|
|
|
.emit(MessageMgr.TRANSLATE_HK_START_CHAT, friendId.id);
|
|
|
|
});
|
|
|
|
|
|
|
|
}else if(notice.noticeType==TransHKChatNoticeType.EndChat){
|
|
|
|
} else if (notice.noticeType == TransHKChatNoticeType.EndChat) {
|
|
|
|
print('chat.contentBuff cccc');
|
|
|
|
MessageMgr().emit(MessageMgr.TRANSLATE_HK_END_CHAT, friendId.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//私聊通知消息
|
|
|
@@ -509,7 +512,9 @@ class MsgHandler { |
|
|
|
showGroup = groupInfo.messageFree == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isAt = false;///@的消息无论开不开群打扰都要显示推送
|
|
|
|
bool isAt = false;
|
|
|
|
|
|
|
|
///@的消息无论开不开群打扰都要显示推送
|
|
|
|
if (chat.altUserIds.length > 0) {
|
|
|
|
print('存在@消息');
|
|
|
|
msgModel.altUsers = chat.altUserIds;
|
|
|
@@ -523,8 +528,6 @@ class MsgHandler { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (showGroup || isAt) {
|
|
|
|
int nowTime = DateTime.now().millisecondsSinceEpoch;
|
|
|
|
|
|
|
@@ -618,7 +621,8 @@ class MsgHandler { |
|
|
|
debugPrint2('消息为空,无法保存');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
debugPrint2('收到消息,准备保存 会话Id:${msgModel.sessionId} friendId: ${msgModel.friendId} ChatType: ${msgModel.channelType}');
|
|
|
|
debugPrint2(
|
|
|
|
'收到消息,准备保存 会话Id:${msgModel.sessionId} friendId: ${msgModel.friendId} ChatType: ${msgModel.channelType}');
|
|
|
|
// showToast('收到消息,准备保存 会话Id:${msgModel.sessionId} friendId: ${msgModel.friendId} ChatType: ${msgModel.channelType}');
|
|
|
|
ChatDataMgr().saveMsg(msgModel);
|
|
|
|
if (msgModel.msgType == ChatType.ShortVoiceChatType.value) {
|
|
|
@@ -863,8 +867,7 @@ class MsgHandler { |
|
|
|
ChatDataMgr().updateRecordWithUnreadMsg(noticeList);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int msgCount=0;
|
|
|
|
static int msgCount = 0;
|
|
|
|
|
|
|
|
static handlerServerMsg(int comId, int msgId, List<int> content) {
|
|
|
|
switch (comId) {
|
|
|
@@ -947,10 +950,9 @@ class MsgHandler { |
|
|
|
LocalNotificationUtil.instance
|
|
|
|
.show(I18n.of(context).notice, I18n.of(context).new_video_msg);
|
|
|
|
playAudioRing();
|
|
|
|
if(TranslateHKMgr().order==null){
|
|
|
|
if (TranslateHKMgr().order == null) {
|
|
|
|
MessageMgr().emit('Receive AudioChat Request', friendId);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (msgId == 14) {
|
|
|
|
var msgContent = PushRealtimeCallRespond.fromBuffer(content);
|
|
|
@@ -1014,13 +1016,13 @@ class MsgHandler { |
|
|
|
handlerCancelTranslateOrder(content);
|
|
|
|
} else if (msgId == 20) {
|
|
|
|
handlerDeliveryInterpreterOrderPush(content);
|
|
|
|
}else if(msgId==21){
|
|
|
|
} else if (msgId == 21) {
|
|
|
|
handlerCancellationTransHKOrderPush(content);
|
|
|
|
}else if(msgId==8){
|
|
|
|
} else if (msgId == 8) {
|
|
|
|
handlerEndTransHKOrderRes(content);
|
|
|
|
}else if(msgId==10){
|
|
|
|
} else if (msgId == 10) {
|
|
|
|
handlerTransHKInterSetIsReceiptRes(content);
|
|
|
|
}else if(msgId==31){
|
|
|
|
} else if (msgId == 31) {
|
|
|
|
handlerAnotherOrderRes(content);
|
|
|
|
}
|
|
|
|
break;
|
|
|
@@ -1034,7 +1036,7 @@ class MsgHandler { |
|
|
|
switch (type) {
|
|
|
|
case 'notice':
|
|
|
|
|
|
|
|
///由于极光本地推送点击事件无反应,暂时不走这,由远端推
|
|
|
|
///由于极光本地推送点击事件无反应,暂时不走这,由远端推
|
|
|
|
String messageJson = map['message'];
|
|
|
|
Map messageMap = json.decode(messageJson);
|
|
|
|
|
|
|
@@ -1168,9 +1170,9 @@ class MsgHandler { |
|
|
|
|
|
|
|
Navigator.pushReplacement(context,
|
|
|
|
MaterialPageRoute<void>(builder: (BuildContext context) {
|
|
|
|
return GroupChatPage(
|
|
|
|
key: Key('GroupChat'), groupInfoModel: groupInfoModel);
|
|
|
|
}));
|
|
|
|
return GroupChatPage(
|
|
|
|
key: Key('GroupChat'), groupInfoModel: groupInfoModel);
|
|
|
|
}));
|
|
|
|
} else {
|
|
|
|
switch (res.errorCode) {
|
|
|
|
case 3007:
|
|
|
@@ -1311,10 +1313,11 @@ class MsgHandler { |
|
|
|
}
|
|
|
|
|
|
|
|
//发布翻译管家帮助订单
|
|
|
|
static sendCreateTranslateOrder(int fromLanguage,int toLanguage,int scences,String extraDesc) {
|
|
|
|
|
|
|
|
TranslateHKMgr().isUser=true;
|
|
|
|
debugPrint2('发布翻译管家帮助订单 fromLanguage:$fromLanguage toLanguage: $toLanguage | ${fromLanguage|toLanguage}' );
|
|
|
|
static sendCreateTranslateOrder(
|
|
|
|
int fromLanguage, int toLanguage, int scences, String extraDesc) {
|
|
|
|
TranslateHKMgr().isUser = true;
|
|
|
|
debugPrint2(
|
|
|
|
'发布翻译管家帮助订单 fromLanguage:$fromLanguage toLanguage: $toLanguage | ${fromLanguage | toLanguage}');
|
|
|
|
var seq = IssueTransHKOrderReq.create();
|
|
|
|
seq.tLanguage = fromLanguage | toLanguage;
|
|
|
|
seq.scenes = scences;
|
|
|
@@ -1337,30 +1340,25 @@ class MsgHandler { |
|
|
|
} else {
|
|
|
|
debugPrint2('发布翻译管家帮助订单失败 ${res.errorCode}');
|
|
|
|
|
|
|
|
String errorStr=I18n.of(context).translation_butler_order_failed;
|
|
|
|
switch(res.errorCode){
|
|
|
|
String errorStr = I18n.of(context).translation_butler_order_failed;
|
|
|
|
switch (res.errorCode) {
|
|
|
|
case 5014:
|
|
|
|
case 5014:
|
|
|
|
errorStr=I18n.of(context).translation_butler_order_failed2;
|
|
|
|
errorStr = I18n.of(context).translation_butler_order_failed2;
|
|
|
|
break;
|
|
|
|
case 5015:
|
|
|
|
errorStr=I18n.of(context).not_enough;
|
|
|
|
errorStr = I18n.of(context).not_enough;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
showToast('$errorStr -${res.errorCode}',duration: Duration(seconds: 3));
|
|
|
|
showToast('$errorStr -${res.errorCode}', duration: Duration(seconds: 3));
|
|
|
|
TranslateHKMgr().orderStatus = TranslateHKMgr.ORDER_STATUS_EMPTY;
|
|
|
|
MessageMgr().emit(MessageMgr.TRANSLATE_HK_REFRESH_ORDER);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//翻译官开启/关闭接收订单
|
|
|
|
static translateReceiptOrStopOrder(bool isReceipt) {
|
|
|
|
|
|
|
|
debugPrint2('翻译官开启/关闭接收订单 请求 $isReceipt' );
|
|
|
|
debugPrint2('翻译官开启/关闭接收订单 请求 $isReceipt');
|
|
|
|
var seq = TransHKInterSetIsReceiptReq.create();
|
|
|
|
seq.isReceipt = isReceipt;
|
|
|
|
|
|
|
@@ -1372,7 +1370,8 @@ class MsgHandler { |
|
|
|
debugPrint2('翻译官开启/关闭接收订单 回应');
|
|
|
|
var res = TransHKInterSetIsReceiptRes.fromBuffer(msgContent);
|
|
|
|
if (res.errorCode == 0) {
|
|
|
|
MessageMgr().emit(MessageMgr.TRANSLATE_HK_IS_RECEIVED_ORDER,res.isReceipt);
|
|
|
|
MessageMgr()
|
|
|
|
.emit(MessageMgr.TRANSLATE_HK_IS_RECEIVED_ORDER, res.isReceipt);
|
|
|
|
|
|
|
|
debugPrint2('翻译官开启/关闭接收订单 回应成功: ${res.isReceipt}');
|
|
|
|
} else {
|
|
|
@@ -1380,7 +1379,6 @@ class MsgHandler { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//撤销订单消息
|
|
|
|
static sendCancelTranslateOrder() {
|
|
|
|
debugPrint2('取消订单 orderid:${TranslateHKMgr().orderId}');
|
|
|
@@ -1409,31 +1407,28 @@ class MsgHandler { |
|
|
|
'OrderId: ${res.orderId} createTime: ${res.createTime} tLanguage:${res.tLanguage} scenes:${res.scenes} desc${res.desc}');
|
|
|
|
|
|
|
|
TranslateOrder order = new TranslateOrder();
|
|
|
|
order.orderId=res.orderId;
|
|
|
|
order.desc=res.desc;
|
|
|
|
order.createTime=res.createTime.toInt();
|
|
|
|
order.tLanguage=res.tLanguage.toInt();
|
|
|
|
order.scenes=res.scenes.toInt();
|
|
|
|
order.orderId = res.orderId;
|
|
|
|
order.desc = res.desc;
|
|
|
|
order.createTime = res.createTime.toInt();
|
|
|
|
order.tLanguage = res.tLanguage.toInt();
|
|
|
|
order.scenes = res.scenes.toInt();
|
|
|
|
order.userName = res.employer.niceName;
|
|
|
|
TranslateHKMgr().order = order;
|
|
|
|
MessageMgr().emit(MessageMgr.TRANSLATE_HK_RECEIVE_ORDER, order);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//派送订单已被取消
|
|
|
|
static handlerCancellationTransHKOrderPush(List<int> msgContent) {
|
|
|
|
|
|
|
|
var res = CancellationTransHKOrderPush.fromBuffer(msgContent);
|
|
|
|
debugPrint2('派送订单已被取消: orderId${res.orderId}');
|
|
|
|
// print('OrderId: ${res.orderId} createTime: ${res.createTime} tLanguage:${res.tLanguage} scenes:${res.scenes} desc${res.desc}');
|
|
|
|
|
|
|
|
TranslateHKMgr().order = null;
|
|
|
|
MessageMgr().emit(MessageMgr.TRANSLATE_HK_CANCEL_ORDER);
|
|
|
|
showToast(I18n.of(context).translation_butler_order_time_out,duration: Duration(seconds: 3));
|
|
|
|
showToast(I18n.of(context).translation_butler_order_time_out,
|
|
|
|
duration: Duration(seconds: 3));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//接收订单请求
|
|
|
|
static sendReceiveOrder() {
|
|
|
|
TranslateOrder order = TranslateHKMgr().order;
|
|
|
@@ -1456,12 +1451,9 @@ class MsgHandler { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//用户发送再来一单请求
|
|
|
|
static sendAnotherOrderReq() {
|
|
|
|
debugPrint2('用户发送再来一单请求 orderId:${ TranslateHKMgr().orderId}');
|
|
|
|
debugPrint2('用户发送再来一单请求 orderId:${TranslateHKMgr().orderId}');
|
|
|
|
var seq = AnotherOrderReq.create();
|
|
|
|
seq.orderId = TranslateHKMgr().orderId;
|
|
|
|
|
|
|
@@ -1481,11 +1473,9 @@ class MsgHandler { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//用户主动结束翻译管家服务
|
|
|
|
static sendEndTransHKOrderReq() {
|
|
|
|
|
|
|
|
debugPrint2('用户主动结束翻译管家服务 ${TranslateHKMgr().orderId}' );
|
|
|
|
debugPrint2('用户主动结束翻译管家服务 ${TranslateHKMgr().orderId}');
|
|
|
|
var seq = EndTransHKOrderReq.create();
|
|
|
|
seq.orderId = TranslateHKMgr().orderId;
|
|
|
|
NetWork().sendMsg(ComId.TranslateOrder, 7, seq);
|
|
|
@@ -1496,7 +1486,6 @@ class MsgHandler { |
|
|
|
debugPrint2('用户主动结束翻译管家服务');
|
|
|
|
var res = EndTransHKOrderRes.fromBuffer(msgContent);
|
|
|
|
if (res.errorCode == 0) {
|
|
|
|
|
|
|
|
// GroupInfoMgr().updateMemberMsgFree(res.groupId, res.messageFree);
|
|
|
|
debugPrint2('用户主动结束翻译管家服务 成功: ');
|
|
|
|
} else {
|
|
|
@@ -1504,11 +1493,6 @@ class MsgHandler { |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//消息免打扰请求结果
|
|
|
|
static handlerGroupIsShowMenberNiceName(List<int> msgContent) {
|
|
|
|
print('设置是否显示群昵称');
|
|
|
|