服务端更新消息能体现,但是再发一条消息或者退出聊天界面再次进入又变成原本的内容。求帮助
自定消息代码如下:
收到服务端消息的时候 decode中binaryContent数据是想要的。
export default class BuyVehicleRequestMessageContent extends MessageContent {
content;
orderInfo;
constructor(content, extra, mentionedType = 0, mentionedTargets = []) {
super(MessageContentType.MESSAGE_CONTENT_TYPE_BUYVEHICLE_REQUEST, mentionedType, mentionedTargets);
this.content = content;
this.orderInfo = extra
}
digest() {
return "[定车申请]";
}
encode() {
let payload = super.encode();
payload.searchableContent = this.content;
payload.binaryContent = wfc.utf8_to_b64(JSON.stringify(this.orderInfo));
return payload;
}
decode(payload) {
super.decode(payload);
console.log("开始:decode")
this.content = payload.content;
this.searchableContent = payload.searchableContent
if (payload.binaryContent && payload.binaryContent.length > 0) {
// JSON.parse 和 JSON.stringify 不能处理java long
payload.extra =JSON.parse(wfc.b64_to_utf8(payload.binaryContent))
console.log("orderState:"+payload.extra.orderState)
this.binaryContent = payload.binaryContent
this.extra = payload.extra
}
}
}