fix:update message content model

This commit is contained in:
SL 2024-08-18 13:52:04 +08:00
parent deaf7fbbc8
commit 564727d44f
30 changed files with 443 additions and 255 deletions

View File

@ -3,13 +3,11 @@ plugins {
}
android {
compileSdk 33
buildToolsVersion '33.0.2'
compileSdk 34
defaultConfig {
applicationId "com.xinbida.wukongdemo"
minSdkVersion 19
targetSdkVersion 33
minSdkVersion 21
targetSdkVersion 34
versionCode 1
versionName "1.0"
multiDexEnabled true
@ -31,13 +29,11 @@ android {
dependencies {
implementation project(':wkim')
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'org.jetbrains:annotations:15.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
implementation 'com.google.android.material:material:1.12.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'org.jetbrains:annotations:23.0.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1'
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.7'
implementation 'com.github.li-xiaojun:XPopup:2.9.19'
implementation 'com.github.bigdongdong:ChatView:2.0' //

View File

@ -30,7 +30,7 @@ public class LoginActivity extends AppCompatActivity {
private void onListener() {
EditText urlET = findViewById(R.id.urlET);
String url = urlET.getText().toString();
if (!TextUtils.isEmpty(url)){
if (!TextUtils.isEmpty(url)) {
HttpUtil.getInstance().apiURL = url;
}

View File

@ -3,7 +3,6 @@ package com.xinbida.wukongdemo;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
@ -16,6 +15,7 @@ import androidx.recyclerview.widget.RecyclerView;
import com.lxj.xpopup.XPopup;
import com.xinbida.wukongim.WKIM;
import com.xinbida.wukongim.entity.WKChannel;
import com.xinbida.wukongim.entity.WKChannelType;
import com.xinbida.wukongim.entity.WKMsg;
import com.xinbida.wukongim.message.type.WKConnectStatus;
@ -72,7 +72,7 @@ public class MainActivity extends AppCompatActivity {
return;
}
WKIM.getInstance().getMsgManager().sendMessage(new WKTextContent(content), channelID, channelType);
WKIM.getInstance().getMsgManager().send(new WKTextContent(content), new WKChannel(channelID,channelType));
contentEt.setText("");
});

View File

@ -9,10 +9,10 @@
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:gravity="center"
android:textStyle="bold"
android:text="悟空IM登录"
android:textColor="@color/black"
android:textSize="28sp" />
android:textSize="28sp"
android:textStyle="bold" />
<TextView
android:id="@+id/descTv"
@ -22,7 +22,7 @@
android:layout_marginTop="10dp"
android:layout_marginEnd="30dp"
android:gravity="center"
android:text="悟空IM演示程序。当前SDK版本V1.0.0"
android:text="悟空IM演示程序。当前SDK版本"
android:textColor="@color/black"
android:textSize="18sp" />

View File

@ -7,7 +7,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.4.1'
classpath 'com.android.tools.build:gradle:8.5.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -23,10 +23,10 @@ afterEvaluate {
}
android {
compileSdk 33
compileSdk 34
defaultConfig {
minSdkVersion 19
targetSdkVersion 33
minSdkVersion 21
targetSdkVersion 34
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"

View File

@ -13,13 +13,12 @@ import com.xinbida.wukongim.manager.ReminderManager;
import com.xinbida.wukongim.manager.RobotManager;
import com.xinbida.wukongim.message.MessageHandler;
import com.xinbida.wukongim.utils.CryptoUtils;
import com.xinbida.wukongim.utils.WKLoggerUtils;
/**
* 5/20/21 5:25 PM
*/
public class WKIM {
private final String Version = "V1.1.7";
private final String Version = "V1.1.9";
private WKIM() {

View File

@ -22,7 +22,6 @@ import java.util.UUID;
public class WKIMApplication {
private final String sharedName = "wk_account_config";
//协议版本
public final byte defaultProtocolVersion = 4;
public byte protocolVersion = 4;
private WKIMApplication() {
@ -208,38 +207,6 @@ public class WKIMApplication {
}
}
return false;
//
// ConnectivityManager connectivity = (ConnectivityManager) mContext.get().getSystemService(Context.CONNECTIVITY_SERVICE);
// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
// if (connectivity != null) {
// Network networks = connectivity.getActiveNetwork();
// NetworkCapabilities networkCapabilities = connectivity.getNetworkCapabilities(networks);
// if (networkCapabilities != null) {
// if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
// success = true;
// } else if (networkCapabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) {
// success = true;
// }
// } else {
// success = false;
// }
// }
//
// } else {
// NetworkInfo.State state = connectivity.getNetworkInfo(
// ConnectivityManager.TYPE_WIFI).getState(); // 获取网络连接状态
// if (NetworkInfo.State.CONNECTED == state) {
// // 判断是否正在使用WIFI网络
// success = true;
// } else {
// state = connectivity.getNetworkInfo(
// ConnectivityManager.TYPE_MOBILE).getState(); // 获取网络连接状态
// if (NetworkInfo.State.CONNECTED == state) { // 判断是否正在使用GPRS网络
// success = true;
// }
// }
// }
}
public void setFileCacheDir(String fileDir) {

View File

@ -34,6 +34,29 @@ public class ChannelDBManager {
return ChannelDBManagerBinder.channelDBManager;
}
public List<WKChannel> queryWithChannelIds(List<String> channelIDs) {
List<WKChannel> list = new ArrayList<>();
if (WKIMApplication
.getInstance()
.getDbHelper() == null) {
return list;
}
try (Cursor cursor = WKIMApplication
.getInstance()
.getDbHelper()
.select(channel, "channel_id in (" + WKCursor.getPlaceholders(channelIDs.size()) + ")", channelIDs.toArray(new String[0]), null)) {
if (cursor == null) {
return list;
}
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
WKChannel channel = serializableChannel(cursor);
list.add(channel);
}
} catch (Exception ignored) {
}
return list;
}
public List<WKChannel> queryWithChannelIdsAndChannelType(List<String> channelIDs, byte channelType) {
List<WKChannel> list = new ArrayList<>();
if (WKIMApplication
@ -158,7 +181,7 @@ public class ChannelDBManager {
try {
cv = WKSqlContentValues.getContentValuesWithChannel(wkChannel);
} catch (Exception e) {
WKLoggerUtils.getInstance().e(TAG , "insert channel error");
WKLoggerUtils.getInstance().e(TAG, "insert channel error");
}
if (WKIMApplication.getInstance().getDbHelper() == null) {
return;
@ -175,7 +198,7 @@ public class ChannelDBManager {
try {
cv = WKSqlContentValues.getContentValuesWithChannel(wkChannel);
} catch (Exception e) {
WKLoggerUtils.getInstance().e(TAG , "update channel error");
WKLoggerUtils.getInstance().e(TAG, "update channel error");
}
if (WKIMApplication.getInstance().getDbHelper() == null) {
return;

View File

@ -16,6 +16,7 @@ import com.xinbida.wukongim.entity.WKChannelType;
import com.xinbida.wukongim.entity.WKConversationMsg;
import com.xinbida.wukongim.entity.WKConversationMsgExtra;
import com.xinbida.wukongim.entity.WKMsg;
import com.xinbida.wukongim.entity.WKMsgExtra;
import com.xinbida.wukongim.entity.WKUIConversationMsg;
import com.xinbida.wukongim.manager.ConversationManager;
import com.xinbida.wukongim.utils.WKCommonUtils;
@ -85,18 +86,88 @@ public class ConversationDbManager {
if (cursor == null) {
return list;
}
List<String> clientMsgNos = new ArrayList<>();
for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
WKConversationMsg msg = serializeMsg(cursor);
if (msg.isDeleted == 0) {
WKUIConversationMsg uiMsg = getUIMsg(msg, cursor);
list.add(uiMsg);
clientMsgNos.add(uiMsg.clientMsgNo);
}
}
} catch (Exception ignored) {
if (!clientMsgNos.isEmpty()) {
List<WKMsg> msgList = queryWithClientMsgNos(clientMsgNos);
List<String> msgIds = new ArrayList<>();
if (WKCommonUtils.isNotEmpty(msgList)) {
for (WKUIConversationMsg uiMsg : list) {
for (WKMsg msg : msgList) {
if (uiMsg.clientMsgNo.equals(msg.clientMsgNO)) {
uiMsg.setWkMsg(msg);
if (!TextUtils.isEmpty(msg.messageID)) {
msgIds.add(msg.messageID);
}
break;
}
}
}
}
List<WKMsgExtra> extraList = queryWithMsgIds(msgIds);
if (WKCommonUtils.isNotEmpty(extraList)) {
for (WKUIConversationMsg uiMsg : list) {
for (WKMsgExtra extra : extraList) {
if (uiMsg.getWkMsg() != null && !TextUtils.isEmpty(uiMsg.getWkMsg().messageID) && uiMsg.getWkMsg().messageID.equals(extra.messageID)) {
uiMsg.getWkMsg().remoteExtra = extra;
break;
}
}
}
}
}
} catch (Exception e) {
WKLoggerUtils.getInstance().e(TAG, "queryAll error");
}
return list;
}
private List<WKMsgExtra> queryWithMsgIds(List<String> msgIds) {
List<WKMsgExtra> msgExtraList = new ArrayList<>();
List<String> ids = new ArrayList<>();
for (int i = 0, size = msgIds.size(); i < size; i++) {
if (ids.size() == 200) {
List<WKMsgExtra> list = MsgDbManager.getInstance().queryMsgExtrasWithMsgIds(ids);
if (WKCommonUtils.isNotEmpty(list)) {
msgExtraList.addAll(list);
}
ids.clear();
}
ids.add(msgIds.get(i));
}
return msgExtraList;
}
private List<WKMsg> queryWithClientMsgNos(List<String> clientMsgNos) {
List<WKMsg> msgList = new ArrayList<>();
List<String> nos = new ArrayList<>();
for (int i = 0, size = clientMsgNos.size(); i < size; i++) {
if (nos.size() == 200) {
List<WKMsg> list = MsgDbManager.getInstance().queryWithClientMsgNos(nos);
if (WKCommonUtils.isNotEmpty(list)) {
msgList.addAll(list);
}
nos.clear();
}
nos.add(clientMsgNos.get(i));
}
if (!nos.isEmpty()) {
List<WKMsg> list = MsgDbManager.getInstance().queryWithClientMsgNos(nos);
if (WKCommonUtils.isNotEmpty(list)) {
msgList.addAll(list);
}
nos.clear();
}
return msgList;
}
public List<WKUIConversationMsg> queryWithChannelIds(List<String> channelIds) {
String sql = "select " + conversation + ".*," + channelCols + "," + extraCols + " from " + conversation + " left join " + channel + " on " + conversation + ".channel_id=" + channel + ".channel_id and " + conversation + ".channel_type=" + channel + ".channel_type left join " + conversationExtra + " on " + conversation + ".channel_id=" + conversationExtra + ".channel_id and " + conversation + ".channel_type=" + conversationExtra + ".channel_type where " + conversation + ".is_deleted=0 and " + conversation + ".channel_id in (" + WKCursor.getPlaceholders(channelIds.size()) + ")";
List<WKUIConversationMsg> list = new ArrayList<>();
@ -211,7 +282,7 @@ public class ConversationDbManager {
cv.put(WKDBColumns.WKCoverMessageColumns.last_msg_seq, lastMsgSeq);
cv.put(WKDBColumns.WKCoverMessageColumns.unread_count, count);
} catch (Exception e) {
WKLoggerUtils.getInstance().e(TAG , "updateMsg error");
WKLoggerUtils.getInstance().e(TAG, "updateMsg error");
}
WKIMApplication.getInstance().getDbHelper()
.update(conversation, cv, WKDBColumns.WKCoverMessageColumns.channel_id + "=? and " + WKDBColumns.WKCoverMessageColumns.channel_type + "=?", update);
@ -241,7 +312,7 @@ public class ConversationDbManager {
try {
cv.put(WKDBColumns.WKCoverMessageColumns.is_deleted, isDeleted);
} catch (Exception e) {
WKLoggerUtils.getInstance().e(TAG , "deleteWithChannel error");
WKLoggerUtils.getInstance().e(TAG, "deleteWithChannel error");
}
boolean result = WKIMApplication.getInstance().getDbHelper()
@ -294,7 +365,7 @@ public class ConversationDbManager {
try {
cv = WKSqlContentValues.getContentValuesWithCoverMsg(msg, false);
} catch (Exception e) {
WKLoggerUtils.getInstance().e(TAG,"insert error");
WKLoggerUtils.getInstance().e(TAG, "insert error");
}
long result = -1;
try {
@ -319,7 +390,7 @@ public class ConversationDbManager {
try {
cv = WKSqlContentValues.getContentValuesWithCoverMsg(msg, false);
} catch (Exception e) {
WKLoggerUtils.getInstance().e(TAG,"update error");
WKLoggerUtils.getInstance().e(TAG, "update error");
}
return WKIMApplication.getInstance().getDbHelper()
.update(conversation, cv, WKDBColumns.WKCoverMessageColumns.channel_id + "=? and " + WKDBColumns.WKCoverMessageColumns.channel_type + "=?", update);
@ -504,7 +575,7 @@ public class ConversationDbManager {
hashMap.put(key, jsonObject.opt(key));
}
} catch (JSONException e) {
WKLoggerUtils.getInstance().e(TAG , "serializeMsg error");
WKLoggerUtils.getInstance().e(TAG, "serializeMsg error");
}
msg.localExtraMap = hashMap;
}

View File

@ -21,9 +21,12 @@ import com.xinbida.wukongim.entity.WKMsg;
import com.xinbida.wukongim.entity.WKMsgExtra;
import com.xinbida.wukongim.entity.WKMsgReaction;
import com.xinbida.wukongim.entity.WKMsgSetting;
import com.xinbida.wukongim.entity.WKSyncChannelMsg;
import com.xinbida.wukongim.entity.WKSyncRecent;
import com.xinbida.wukongim.interfaces.IGetOrSyncHistoryMsgBack;
import com.xinbida.wukongim.manager.MsgManager;
import com.xinbida.wukongim.message.type.WKSendMsgResult;
import com.xinbida.wukongim.msgmodel.WKFormatErrorContent;
import com.xinbida.wukongim.msgmodel.WKMessageContent;
import com.xinbida.wukongim.utils.WKCommonUtils;
import com.xinbida.wukongim.utils.WKLoggerUtils;
@ -59,7 +62,8 @@ public class MsgDbManager {
}
private int requestCount;
// private int more = 1;
// private int more = 1;
private final HashMap<String, Long> channelMinMsgSeqs = new HashMap<>();
public void queryOrSyncHistoryMessages(String channelId, byte channelType, long oldestOrderSeq, boolean contain, int pullMode, int limit, final IGetOrSyncHistoryMsgBack iGetOrSyncHistoryMsgBack) {
//获取原始数据
@ -146,7 +150,7 @@ public class MsgDbManager {
if (max > startMsgSeq) {
startMsgSeq = max;
}
if (endMsgSeq ==0 || min < endMsgSeq) {
if (endMsgSeq == 0 || min < endMsgSeq) {
endMsgSeq = min;
}
} else {
@ -167,8 +171,16 @@ public class MsgDbManager {
startMsgSeq = 0;
endMsgSeq = 0;
}
String key = channelId + "_" + channelType;
if (!isSyncMsg) {
if (minMessageSeq == 1) {
long minSeq = 1;
if (channelMinMsgSeqs.containsKey(key)) {
Object s = channelMinMsgSeqs.get(key);
if (s != null) {
minSeq = Long.parseLong(s.toString());
}
}
if (minMessageSeq == minSeq) {
requestCount = 0;
// more = 1;
new Handler(Looper.getMainLooper()).post(() -> iGetOrSyncHistoryMsgBack.onResult(list));
@ -202,10 +214,9 @@ public class MsgDbManager {
requestCount++;
MsgManager.getInstance().setSyncChannelMsgListener(channelId, channelType, startMsgSeq, endMsgSeq, limit, pullMode, syncChannelMsg -> {
if (syncChannelMsg != null) {
if (oldestMsgSeq == 0) {
if (oldestMsgSeq == 0 || (syncChannelMsg.messages != null && syncChannelMsg.messages.size() < limit)) {
requestCount = 5;
}
// more = syncChannelMsg.more;
queryOrSyncHistoryMessages(channelId, channelType, oldestOrderSeq, contain, pullMode, limit, iGetOrSyncHistoryMsgBack);
} else {
requestCount = 0;
@ -218,7 +229,30 @@ public class MsgDbManager {
// more = 1;
new Handler(Looper.getMainLooper()).post(() -> iGetOrSyncHistoryMsgBack.onResult(list));
}
}
private long getMinSeq(WKSyncChannelMsg syncChannelMsg, List<WKMsg> tempList) {
long minSeq = 0;
if (WKCommonUtils.isNotEmpty(syncChannelMsg.messages)) {
for (WKSyncRecent recent : syncChannelMsg.messages) {
if (minSeq == 0) {
minSeq = recent.message_seq;
} else {
minSeq = Math.min(minSeq, recent.message_seq);
}
}
} else {
if (WKCommonUtils.isNotEmpty(tempList)) {
for (WKMsg msg : tempList) {
if (minSeq == 0) {
minSeq = msg.messageSeq;
} else {
minSeq = Math.min(minSeq, msg.messageSeq);
}
}
}
}
return minSeq;
}
public List<WKMsg> queryWithFlame() {
@ -888,7 +922,7 @@ public class MsgDbManager {
}
private List<WKMsgExtra> queryMsgExtrasWithMsgIds(List<String> msgIds) {
public List<WKMsgExtra> queryMsgExtrasWithMsgIds(List<String> msgIds) {
List<WKMsgExtra> list = new ArrayList<>();
try (Cursor cursor = WKIMApplication.getInstance().getDbHelper().select(messageExtra, "message_id in (" + WKCursor.getPlaceholders(msgIds.size()) + ")", msgIds.toArray(new String[0]), null)) {
if (cursor == null) {
@ -1638,6 +1672,7 @@ public class MsgDbManager {
jsonObject = new JSONObject(msg.content);
} catch (JSONException e) {
WKLoggerUtils.getInstance().e(TAG, "getMsgModel error content not json format");
return new WKFormatErrorContent();
}
}
return WKIM.getInstance()

View File

@ -34,6 +34,16 @@ public class ReminderDBManager {
return ReminderDBManagerBinder.binder;
}
public void doneWithReminderIds(List<Long> ids) {
ContentValues cv = new ContentValues();
cv.put("done", 1);
String[] strings = new String[ids.size()];
for (int i = 0; i < ids.size(); i++) {
strings[i] = ids.get(i) + "";
}
WKIMApplication.getInstance().getDbHelper().update(reminders, cv, "reminder_id in (" + WKCursor.getPlaceholders(ids.size()) + ")", strings);
}
public long queryMaxVersion() {
String sql = "select * from " + reminders + " order by version desc limit 1";
long version = 0;
@ -237,7 +247,7 @@ public class ReminderDBManager {
hashMap.put(key, jsonObject.opt(key));
}
} catch (JSONException e) {
WKLoggerUtils.getInstance().e(TAG , "serializeReminder error");
WKLoggerUtils.getInstance().e(TAG, "serializeReminder error");
}
reminder.data = hashMap;
}

View File

@ -233,7 +233,7 @@ class WKSqlContentValues {
cv.put("keep_message_seq", extra.keepMessageSeq);
cv.put("keep_offset_y", extra.keepOffsetY);
cv.put("draft", extra.draft);
cv.put("draft_updated_at", extra.version);
cv.put("draft_updated_at", extra.draftUpdatedAt);
cv.put("version", extra.version);
return cv;
}

View File

@ -9,4 +9,4 @@ public class WKMentionType {
public static final int WKReminderTypeMentionMe = 1;
//申请加群
public static final int WKApplyJoinGroupApprove = 2;
}
}

View File

@ -76,6 +76,7 @@ public class WKMsg implements Parcelable {
public int viewed;
// 查看时间戳
public long viewedAt;
public String robotID;
// 话题ID
public String topicID;
//消息设置
@ -97,6 +98,7 @@ public class WKMsg implements Parcelable {
this.expireTimestamp = 0;
status = WKSendMsgResult.send_loading;
clientMsgNO = WKIM.getInstance().getMsgManager().createClientMsgNO();
setting=new WKMsgSetting();
header = new WKMsgHeader();
remoteExtra = new WKMsgExtra();
}
@ -138,6 +140,7 @@ public class WKMsg implements Parcelable {
topicID = in.readString();
expireTime = in.readInt();
expireTimestamp = in.readLong();
robotID = in.readString();
}
public static final Creator<WKMsg> CREATOR = new Creator<WKMsg>() {
@ -192,6 +195,7 @@ public class WKMsg implements Parcelable {
dest.writeString(topicID);
dest.writeInt(expireTime);
dest.writeLong(expireTimestamp);
dest.writeString(robotID);
}
public String getLocalMapExtraString() {

View File

@ -4,7 +4,7 @@ import android.os.Parcel;
import android.os.Parcelable;
public class WKMsgHeader implements Parcelable {
//是否持久化[是否保存在数据库]
//是否持久化[是否保存在数据库]
public boolean noPersist;
//对方是否显示红点
public boolean redDot = true;

View File

@ -0,0 +1,11 @@
package com.xinbida.wukongim.entity;
public class WKSendOptions {
public int expire = 0;
public String topicID;
public int flame;
public int flameSecond;
public String robotID;
public WKMsgSetting setting = new WKMsgSetting();
public WKMsgHeader header = new WKMsgHeader();
}

View File

@ -271,6 +271,10 @@ public class ChannelManager extends BaseManager {
return ChannelDBManager.getInstance().queryWithChannelIdsAndChannelType(channelIds, channelType);
}
public List<WKChannel> getChannels(List<String> channelIds) {
return ChannelDBManager.getInstance().queryWithChannelIds(channelIds);
}
/**
* 搜索频道
*

View File

@ -1,6 +1,9 @@
package com.xinbida.wukongim.manager;
import android.text.TextUtils;
import android.util.Log;
import androidx.annotation.NonNull;
import com.xinbida.wukongim.WKIM;
import com.xinbida.wukongim.WKIMApplication;
@ -17,6 +20,7 @@ import com.xinbida.wukongim.entity.WKMsg;
import com.xinbida.wukongim.entity.WKMsgExtra;
import com.xinbida.wukongim.entity.WKMsgReaction;
import com.xinbida.wukongim.entity.WKMsgSetting;
import com.xinbida.wukongim.entity.WKSendOptions;
import com.xinbida.wukongim.entity.WKSyncExtraMsg;
import com.xinbida.wukongim.entity.WKSyncMsg;
import com.xinbida.wukongim.entity.WKSyncMsgReaction;
@ -39,13 +43,16 @@ import com.xinbida.wukongim.interfaces.IUploadAttachmentListener;
import com.xinbida.wukongim.interfaces.IUploadMsgExtraListener;
import com.xinbida.wukongim.message.MessageHandler;
import com.xinbida.wukongim.message.WKConnection;
import com.xinbida.wukongim.message.WKRead;
import com.xinbida.wukongim.message.type.WKMsgContentType;
import com.xinbida.wukongim.message.type.WKSendMsgResult;
import com.xinbida.wukongim.msgmodel.WKFormatErrorContent;
import com.xinbida.wukongim.msgmodel.WKImageContent;
import com.xinbida.wukongim.msgmodel.WKMessageContent;
import com.xinbida.wukongim.msgmodel.WKMsgEntity;
import com.xinbida.wukongim.msgmodel.WKReply;
import com.xinbida.wukongim.msgmodel.WKTextContent;
import com.xinbida.wukongim.msgmodel.WKUnknownContent;
import com.xinbida.wukongim.msgmodel.WKVideoContent;
import com.xinbida.wukongim.msgmodel.WKVoiceContent;
import com.xinbida.wukongim.utils.DateUtils;
@ -157,6 +164,9 @@ public class MsgManager extends BaseManager {
}
public WKMessageContent getMsgContentModel(String jsonStr) {
if (TextUtils.isEmpty(jsonStr)) {
return new WKFormatErrorContent();
}
JSONObject jsonObject = null;
try {
jsonObject = new JSONObject(jsonStr);
@ -164,77 +174,78 @@ public class MsgManager extends BaseManager {
WKLoggerUtils.getInstance().e(TAG, "getMsgContentModel The parameter is not a JSON");
}
if (jsonObject == null) {
return new WKMessageContent();
} else
return getMsgContentModel(jsonObject);
return new WKFormatErrorContent();
}
return getMsgContentModel(jsonObject);
}
public WKMessageContent getMsgContentModel(int contentType, JSONObject jsonObject) {
if (jsonObject == null) jsonObject = new JSONObject();
WKMessageContent baseContentMsgModel = getContentMsgModel(contentType, jsonObject);
if (baseContentMsgModel != null) {
//解析@成员列表
if (jsonObject.has("mention")) {
JSONObject tempJson = jsonObject.optJSONObject("mention");
if (tempJson != null) {
//是否@所有人
if (tempJson.has("all"))
baseContentMsgModel.mentionAll = tempJson.optInt("all");
JSONArray uidList = tempJson.optJSONArray("uids");
if (baseContentMsgModel == null) {
baseContentMsgModel = new WKUnknownContent();
}
//解析@成员列表
if (jsonObject.has("mention")) {
JSONObject tempJson = jsonObject.optJSONObject("mention");
if (tempJson != null) {
//是否@所有人
if (tempJson.has("all"))
baseContentMsgModel.mentionAll = tempJson.optInt("all");
JSONArray uidList = tempJson.optJSONArray("uids");
if (uidList != null && uidList.length() > 0) {
WKMentionInfo mentionInfo = new WKMentionInfo();
List<String> mentionInfoUIDs = new ArrayList<>();
for (int i = 0, size = uidList.length(); i < size; i++) {
String uid = uidList.optString(i);
if (uid.equals(WKIMApplication.getInstance().getUid())) {
mentionInfo.isMentionMe = true;
}
mentionInfoUIDs.add(uid);
}
mentionInfo.uids = mentionInfoUIDs;
if (baseContentMsgModel.mentionAll == 1) {
if (uidList != null && uidList.length() > 0) {
WKMentionInfo mentionInfo = new WKMentionInfo();
List<String> mentionInfoUIDs = new ArrayList<>();
for (int i = 0, size = uidList.length(); i < size; i++) {
String uid = uidList.optString(i);
if (uid.equals(WKIMApplication.getInstance().getUid())) {
mentionInfo.isMentionMe = true;
}
baseContentMsgModel.mentionInfo = mentionInfo;
mentionInfoUIDs.add(uid);
}
}
}
if (jsonObject.has("from_uid"))
baseContentMsgModel.fromUID = jsonObject.optString("from_uid");
if (jsonObject.has("flame"))
baseContentMsgModel.flame = jsonObject.optInt("flame");
if (jsonObject.has("flame_second"))
baseContentMsgModel.flameSecond = jsonObject.optInt("flame_second");
//判断消息中是否包含回复情况
if (jsonObject.has("reply")) {
baseContentMsgModel.reply = new WKReply();
JSONObject replyJson = jsonObject.optJSONObject("reply");
if (replyJson != null) {
baseContentMsgModel.reply = baseContentMsgModel.reply.decodeMsg(replyJson);
}
}
if (jsonObject.has("robot_id"))
baseContentMsgModel.robotID = jsonObject.optString("robot_id");
if (jsonObject.has("entities")) {
JSONArray jsonArray = jsonObject.optJSONArray("entities");
if (jsonArray != null && jsonArray.length() > 0) {
List<WKMsgEntity> list = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
WKMsgEntity entity = new WKMsgEntity();
JSONObject jo = jsonArray.optJSONObject(i);
entity.type = jo.optString("type");
entity.offset = jo.optInt("offset");
entity.length = jo.optInt("length");
entity.value = jo.optString("value");
list.add(entity);
mentionInfo.uids = mentionInfoUIDs;
if (baseContentMsgModel.mentionAll == 1) {
mentionInfo.isMentionMe = true;
}
baseContentMsgModel.entities = list;
baseContentMsgModel.mentionInfo = mentionInfo;
}
}
}
if (jsonObject.has("from_uid"))
baseContentMsgModel.fromUID = jsonObject.optString("from_uid");
if (jsonObject.has("flame"))
baseContentMsgModel.flame = jsonObject.optInt("flame");
if (jsonObject.has("flame_second"))
baseContentMsgModel.flameSecond = jsonObject.optInt("flame_second");
if (jsonObject.has("robot_id"))
baseContentMsgModel.robotID = jsonObject.optString("robot_id");
//判断消息中是否包含回复情况
if (jsonObject.has("reply")) {
baseContentMsgModel.reply = new WKReply();
JSONObject replyJson = jsonObject.optJSONObject("reply");
if (replyJson != null) {
baseContentMsgModel.reply = baseContentMsgModel.reply.decodeMsg(replyJson);
}
}
if (jsonObject.has("entities")) {
JSONArray jsonArray = jsonObject.optJSONArray("entities");
if (jsonArray != null && jsonArray.length() > 0) {
List<WKMsgEntity> list = new ArrayList<>();
for (int i = 0; i < jsonArray.length(); i++) {
WKMsgEntity entity = new WKMsgEntity();
JSONObject jo = jsonArray.optJSONObject(i);
entity.type = jo.optString("type");
entity.offset = jo.optInt("offset");
entity.length = jo.optInt("length");
entity.value = jo.optString("value");
list.add(entity);
}
baseContentMsgModel.entities = list;
}
}
return baseContentMsgModel;
}
@ -259,6 +270,7 @@ public class MsgManager extends BaseManager {
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException |
InvocationTargetException e) {
WKLoggerUtils.getInstance().e(TAG, "getContentMsgModel error" + e.getLocalizedMessage());
return new WKUnknownContent();
}
}
try {
@ -268,8 +280,9 @@ public class MsgManager extends BaseManager {
}
} catch (IllegalAccessException | InstantiationException e) {
WKLoggerUtils.getInstance().e(TAG, "getContentMsgModel decodeMsg error");
return new WKUnknownContent();
}
return null;
return new WKUnknownContent();
}
private long getOrNearbyMsgSeq(long orderSeq) {
@ -934,7 +947,6 @@ public class MsgManager extends BaseManager {
}
}
public void saveSyncChannelMSGs(List<WKSyncRecent> list) {
if (WKCommonUtils.isEmpty(list)) return;
List<WKMsg> msgList = new ArrayList<>();
@ -1122,29 +1134,11 @@ public class MsgManager extends BaseManager {
JSONObject jsonObject = new JSONObject(wkSyncRecent.payload);
msg.content = jsonObject.toString();
}
JSONObject jsonObject = null;
if (!TextUtils.isEmpty(msg.content)) {
try {
jsonObject = new JSONObject(msg.content);
if (jsonObject.has("type"))
msg.type = jsonObject.optInt("type");
jsonObject.put(WKDBColumns.WKMessageColumns.from_uid, msg.fromUID);
if (jsonObject.has("flame"))
msg.flame = jsonObject.optInt("flame");
if (jsonObject.has("flame_second"))
msg.flameSecond = jsonObject.optInt("flame_second");
msg.content = jsonObject.toString();
} catch (JSONException e) {
WKLoggerUtils.getInstance().e(TAG, "WKSyncRecent2WKMsg message content not a JSON");
}
}
// 处理消息回应
if (WKCommonUtils.isNotEmpty(wkSyncRecent.reactions)) {
msg.reactionList = getMsgReaction(wkSyncRecent);
}
if (msg.type != WKMsgContentType.WK_SIGNAL_DECRYPT_ERROR && msg.type != WKMsgContentType.WK_CONTENT_FORMAT_ERROR)
msg.baseContentMsgModel = WKIM.getInstance().getMsgManager().getMsgContentModel(msg.type, jsonObject);
msg = MessageHandler.getInstance().parsingMsg(msg);
return msg;
}
@ -1209,7 +1203,7 @@ public class MsgManager extends BaseManager {
@Override
public void run() {
List<WKMsgExtra> list = MsgDbManager.getInstance().queryMsgExtraWithNeedUpload(1);
if (list != null && list.size() > 0) {
if (WKCommonUtils.isNotEmpty(list)) {
for (WKMsgExtra extra : list) {
if (iUploadMsgExtraListener != null) {
iUploadMsgExtraListener.onUpload(extra);
@ -1236,7 +1230,7 @@ public class MsgManager extends BaseManager {
}
public void pushNewMsg(List<WKMsg> wkMsgList) {
if (newMsgListenerMap != null && newMsgListenerMap.size() > 0) {
if (newMsgListenerMap != null && !newMsgListenerMap.isEmpty()) {
runOnMainThread(() -> {
for (Map.Entry<String, INewMsgListener> entry : newMsgListenerMap.entrySet()) {
entry.getValue().newMsg(wkMsgList);
@ -1257,13 +1251,35 @@ public class MsgManager extends BaseManager {
pushNewMsg(msgs);
}
/**
* Deprecated 后续版本将会移除
*
* @param messageContent 消息体
* @param channelID 频道ID
* @param channelType 频道类型
*/
@Deprecated
public void sendMessage(WKMessageContent messageContent, String channelID, byte channelType) {
WKConnection.getInstance().sendMessage(messageContent, channelID, channelType);
send(messageContent, new WKChannel(channelID, channelType));
}
/**
* Deprecated 后续版本将会移除
*
* @param messageContent 消息体
* @param setting 消息设置
* @param channelID 频道ID
* @param channelType 频道类型
*/
@Deprecated
public void sendMessage(WKMessageContent messageContent, WKMsgSetting setting, String channelID, byte channelType) {
WKConnection.getInstance().sendMessage(messageContent, setting, channelID, channelType);
WKSendOptions options = new WKSendOptions();
options.setting = setting;
WKChannel channel = WKIM.getInstance().getChannelManager().getChannel(channelID, channelType);
if (channel == null) {
channel = new WKChannel(channelID, channelType);
}
sendWithOptions(messageContent, channel, options);
}
/**
@ -1271,10 +1287,47 @@ public class MsgManager extends BaseManager {
*
* @param msg 消息对象
*/
public void sendMessage(WKMsg msg) {
public void sendMessage(@NonNull WKMsg msg) {
WKConnection.getInstance().sendMessage(msg);
}
/**
* 发送消息
*
* @param contentModel 消息体
* @param channel 频道
*/
public void send(@NonNull WKMessageContent contentModel, @NonNull WKChannel channel) {
sendWithOptions(contentModel, channel, new WKSendOptions());
}
/**
* 发送消息
*
* @param contentModel 消息体
* @param channel 频道
* @param options 高级设置
*/
public void sendWithOptions(@NonNull WKMessageContent contentModel, @NonNull WKChannel channel, @NonNull WKSendOptions options) {
final WKMsg wkMsg = new WKMsg();
wkMsg.type = contentModel.type;
wkMsg.channelID = channel.channelID;
wkMsg.channelType = channel.channelType;
wkMsg.baseContentMsgModel = contentModel;
wkMsg.flame = options.flame;
wkMsg.flameSecond = options.flameSecond;
wkMsg.expireTime = options.expire;
if (!TextUtils.isEmpty(options.topicID)) {
wkMsg.topicID = options.topicID;
}
if (!TextUtils.isEmpty(options.robotID)) {
wkMsg.robotID = options.robotID;
}
wkMsg.setting = options.setting;
wkMsg.header = options.header;
sendMessage(wkMsg);
}
public String createClientMsgNO() {
return UUID.randomUUID().toString().replaceAll("-", "") + "1";
}

View File

@ -52,9 +52,9 @@ public class ReminderManager extends BaseManager {
/**
* 获取某个类型的提醒
*
* @param channelID 频道ID
* @param channelType 频道类型
* @param type 提醒类型
* @param channelID 频道ID
* @param channelType 频道类型
* @param type 提醒类型
* @return WKReminder
*/
public WKReminder getReminder(String channelID, byte channelType, int type) {
@ -81,7 +81,7 @@ public class ReminderManager extends BaseManager {
}
public List<WKReminder> getRemindersWithType(String channelID, byte channelType, int type) {
return ReminderDBManager.getInstance().queryWithChannelAndTypeAndDone(channelID, channelType, type,0);
return ReminderDBManager.getInstance().queryWithChannelAndTypeAndDone(channelID, channelType, type, 0);
}
public void saveOrUpdateReminders(List<WKReminder> reminderList) {
@ -95,4 +95,7 @@ public class ReminderManager extends BaseManager {
return ReminderDBManager.getInstance().queryMaxVersion();
}
public void done() {
}
}

View File

@ -114,7 +114,7 @@ public class MessageHandler {
System.arraycopy(available_bytes, 0, temp, cacheData.length, available_bytes.length);
cacheData = temp;
} catch (Exception e) {
WKLoggerUtils.getInstance().e(TAG,"cutBytes Merge message error" + e.getMessage());
WKLoggerUtils.getInstance().e(TAG, "cutBytes Merge message error" + e.getMessage());
}
}
@ -208,7 +208,7 @@ public class MessageHandler {
mIReceivedMsgListener
.sendAckMsg(sendAckMsg);
} else if (g_msg.packetType == WKMsgType.RECVEIVED) {
} else if (g_msg.packetType == WKMsgType.RECEIVED) {
//收到消息
WKMsg message = WKProto.getInstance().baseMsg2WKMsg(g_msg);
message.header.noPersist = no_persist == 1;
@ -328,22 +328,8 @@ public class MessageHandler {
if (lastMsg == null) {
continue;
}
JSONObject jsonObject = null;
if (!TextUtils.isEmpty(list.get(i).wkMsg.content)) {
try {
jsonObject = new JSONObject(list.get(i).wkMsg.content);
} catch (JSONException e) {
WKLoggerUtils.getInstance().e(TAG, "groupMsg content is not a JSON struct");
jsonObject = new JSONObject();
}
}
if (lastMsg.baseContentMsgModel == null) {
lastMsg.baseContentMsgModel = WKIM.getInstance().getMsgManager().getMsgContentModel(lastMsg.type, jsonObject);
if (lastMsg.baseContentMsgModel != null) {
lastMsg.flame = lastMsg.baseContentMsgModel.flame;
lastMsg.flameSecond = lastMsg.baseContentMsgModel.flameSecond;
}
}
lastMsg = parsingMsg(lastMsg);
boolean isSave = false;
if (lastMsg.baseContentMsgModel != null && lastMsg.baseContentMsgModel.mentionAll == 1 && list.get(i).red_dot == 1) {
isSave = true;
@ -390,29 +376,37 @@ public class MessageHandler {
}
public WKMsg parsingMsg(WKMsg message) {
JSONObject json = null;
if (message.type != WKMsgContentType.WK_SIGNAL_DECRYPT_ERROR) {
try {
if (TextUtils.isEmpty(message.content)) return message;
json = new JSONObject(message.content);
if (json.has(WKDBColumns.WKMessageColumns.type)) {
message.content = json.toString();
message.type = json.optInt(WKDBColumns.WKMessageColumns.type);
}
if (TextUtils.isEmpty(message.fromUID)) {
if (json.has(WKDBColumns.WKMessageColumns.from_uid)) {
message.fromUID = json.optString(WKDBColumns.WKMessageColumns.from_uid);
} else {
message.fromUID = message.channelID;
}
}
} catch (JSONException e) {
message.type = WKMsgContentType.WK_CONTENT_FORMAT_ERROR;
WKLoggerUtils.getInstance().e(TAG, "Parsing message error, message is not a JSON structure");
}
if (message.type == WKMsgContentType.WK_SIGNAL_DECRYPT_ERROR || message.type == WKMsgContentType.WK_CONTENT_FORMAT_ERROR) {
return message;
}
JSONObject json = null;
try {
if (TextUtils.isEmpty(message.content)) return message;
json = new JSONObject(message.content);
if (json.has("type")) {
message.content = json.toString();
message.type = json.optInt("type");
}
if (TextUtils.isEmpty(message.fromUID)) {
if (json.has("from_uid")) {
message.fromUID = json.optString("from_uid");
} else {
message.fromUID = message.channelID;
}
}
if (json.has("flame")) {
message.flame = json.optInt("flame");
}
if (json.has("flame_second")) {
message.flameSecond = json.optInt("flame_second");
}
if (json.has("root_id")) {
message.robotID = json.optString("root_id");
}
} catch (JSONException e) {
message.type = WKMsgContentType.WK_CONTENT_FORMAT_ERROR;
WKLoggerUtils.getInstance().e(TAG, "Parsing message error, message is not a JSON structure");
}
if (json == null) {
if (message.type != WKMsgContentType.WK_SIGNAL_DECRYPT_ERROR)
@ -421,15 +415,10 @@ public class MessageHandler {
if (message.type == WKMsgContentType.WK_INSIDE_MSG) {
CMDManager.getInstance().handleCMD(json, message.channelID, message.channelType);
}
if (message.type != WKMsgContentType.WK_SIGNAL_DECRYPT_ERROR && message.type != WKMsgContentType.WK_CONTENT_FORMAT_ERROR) {
message.baseContentMsgModel = WKIM.getInstance().getMsgManager().getMsgContentModel(message.type, json);
if (message.baseContentMsgModel != null) {
message.flame = message.baseContentMsgModel.flame;
message.flameSecond = message.baseContentMsgModel.flameSecond;
}
return message;
}
message.baseContentMsgModel = WKIM.getInstance().getMsgManager().getMsgContentModel(message.type, json);
//如果是单聊先将channelId改成发送者ID
if (!TextUtils.isEmpty(message.channelID)
&& !TextUtils.isEmpty(message.fromUID)

View File

@ -25,7 +25,6 @@ import com.xinbida.wukongim.message.type.WKSendMsgResult;
import com.xinbida.wukongim.message.type.WKSendingMsg;
import com.xinbida.wukongim.msgmodel.WKImageContent;
import com.xinbida.wukongim.msgmodel.WKMediaMessageContent;
import com.xinbida.wukongim.msgmodel.WKMessageContent;
import com.xinbida.wukongim.msgmodel.WKVideoContent;
import com.xinbida.wukongim.protocol.WKBaseMsg;
import com.xinbida.wukongim.protocol.WKConnectMsg;
@ -379,33 +378,6 @@ public class WKConnection {
}
}
public void sendMessage(WKMessageContent baseContentModel, WKMsgSetting wkMsgSetting, String channelID, byte channelType) {
final WKMsg wkMsg = new WKMsg();
wkMsg.type = baseContentModel.type;
wkMsg.setting = wkMsgSetting;
//设置会话信息
wkMsg.channelID = channelID;
wkMsg.channelType = channelType;
//检查频道信息
wkMsg.baseContentMsgModel = baseContentModel;
wkMsg.baseContentMsgModel.fromUID = wkMsg.fromUID;
wkMsg.flame = baseContentModel.flame;
wkMsg.flameSecond = baseContentModel.flameSecond;
wkMsg.topicID = baseContentModel.topicID;
sendMessage(wkMsg);
}
/**
* 发送消息
*
* @param baseContentModel 消息model
* @param channelID 频道ID
* @param channelType 频道类型
*/
public void sendMessage(WKMessageContent baseContentModel, String channelID, byte channelType) {
WKMsgSetting setting = new WKMsgSetting();
sendMessage(baseContentModel, setting, channelID, channelType);
}
public void sendMessage(WKMsg msg) {
if (TextUtils.isEmpty(msg.fromUID)) {

View File

@ -1,6 +1,7 @@
package com.xinbida.wukongim.message;
import android.text.TextUtils;
import android.util.Log;
import com.xinbida.wukongim.WKIM;
import com.xinbida.wukongim.WKIMApplication;
@ -33,6 +34,7 @@ import org.json.JSONObject;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.util.Arrays;
/**
* 5/21/21 11:28 AM
@ -57,6 +59,8 @@ class WKProto {
if (msg.packetType == WKMsgType.CONNECT) {
// 连接
bytes = WKProto.getInstance().enConnectMsg((WKConnectMsg) msg);
String str = Arrays.toString(bytes);
WKLoggerUtils.getInstance().e(str);
} else if (msg.packetType == WKMsgType.REVACK) {
// 收到消息回执
bytes = WKProto.getInstance().enReceivedAckMsg((WKReceivedAckMsg) msg);
@ -72,7 +76,6 @@ class WKProto {
}
byte[] enConnectMsg(WKConnectMsg connectMsg) {
WKIMApplication.getInstance().protocolVersion = WKIMApplication.getInstance().defaultProtocolVersion;
byte[] remainingBytes = WKTypeUtils.getInstance().getRemainingLengthByte(connectMsg.getRemainingLength());
int totalLen = connectMsg.getTotalLen();
WKWrite wkWrite = new WKWrite(totalLen);
@ -252,7 +255,7 @@ class WKProto {
return deSendAckMsg(wkRead);
} else if (packetType == WKMsgType.DISCONNECT) {
return deDisconnectMsg(wkRead);
} else if (packetType == WKMsgType.RECVEIVED) {
} else if (packetType == WKMsgType.RECEIVED) {
return deReceivedMsg(wkRead);
} else if (packetType == WKMsgType.PONG) {
return new WKPongMsg();
@ -306,6 +309,9 @@ class WKProto {
if (!TextUtils.isEmpty(msg.baseContentMsgModel.robotID)) {
jsonObject.put("robot_id", msg.baseContentMsgModel.robotID);
}
if (!TextUtils.isEmpty(msg.robotID)) {
jsonObject.put("robot_id", msg.robotID);
}
if (WKCommonUtils.isNotEmpty(msg.baseContentMsgModel.entities)) {
JSONArray jsonArray = new JSONArray();
for (WKMsgEntity entity : msg.baseContentMsgModel.entities) {
@ -322,10 +328,10 @@ class WKProto {
jsonObject.put("flame_second", msg.flameSecond);
jsonObject.put("flame", msg.flame);
}
if (msg.baseContentMsgModel.flame != 0) {
jsonObject.put("flame_second", msg.baseContentMsgModel.flameSecond);
jsonObject.put("flame", msg.baseContentMsgModel.flame);
}
// if (msg.baseContentMsgModel.flame != 0) {
// jsonObject.put("flame_second", msg.baseContentMsgModel.flameSecond);
// jsonObject.put("flame", msg.baseContentMsgModel.flame);
// }
} catch (JSONException e) {
WKLoggerUtils.getInstance().e(TAG, "getSendPayload error");
}

View File

@ -16,7 +16,7 @@ public class WKMsgType {
//收到消息确认的报文(s2c)
public static final short SENDACK = 4;
//收取消息(s2c)
public static final short RECVEIVED = 5;
public static final short RECEIVED = 5;
//收取消息确认(c2s)
public static final short REVACK = 6;
//ping请求

View File

@ -0,0 +1,14 @@
package com.xinbida.wukongim.msgmodel;
import com.xinbida.wukongim.message.type.WKMsgContentType;
public class WKFormatErrorContent extends WKMessageContent {
public WKFormatErrorContent() {
this.type = WKMsgContentType.WK_CONTENT_FORMAT_ERROR;
}
@Override
public String getDisplayContent() {
return "[消息格式错误]";
}
}

View File

@ -16,9 +16,15 @@ import java.util.List;
public class WKMessageContent implements Parcelable {
//内容
public String content;
//发送者id
/**
* Deprecated 后续版本将删除该字段
*/
@Deprecated
public String fromUID;
//发送者名称
/**
* Deprecated 后续版本将删除该字段
*/
@Deprecated
public String fromName;
//消息内容类型
public int type;
@ -31,11 +37,25 @@ public class WKMessageContent implements Parcelable {
//搜索关键字
public String searchableWord;
//最近会话提示文字
public String displayContent;
// public int isDelete;
private String displayContent;
/**
* Deprecated 后续版本将删除该字段
*/
@Deprecated
public String robotID;
/**
* Deprecated 后续版本将删除该字段
*/
@Deprecated
public int flame;
/**
* Deprecated 后续版本将删除该字段
*/
@Deprecated
public int flameSecond;
/**
* Deprecated 后续版本将删除该字段
*/
@Deprecated
public String topicID;
public List<WKMsgEntity> entities;
@ -54,7 +74,6 @@ public class WKMessageContent implements Parcelable {
searchableWord = in.readString();
displayContent = in.readString();
reply = in.readParcelable(WKReply.class.getClassLoader());
// isDelete = in.readInt();
robotID = in.readString();
entities = in.createTypedArrayList(WKMsgEntity.CREATOR);
flame = in.readInt();
@ -73,7 +92,6 @@ public class WKMessageContent implements Parcelable {
dest.writeString(searchableWord);
dest.writeString(displayContent);
dest.writeParcelable(reply, flags);
// dest.writeInt(isDelete);
dest.writeString(robotID);
dest.writeTypedList(entities);
dest.writeInt(flame);

View File

@ -0,0 +1,14 @@
package com.xinbida.wukongim.msgmodel;
import com.xinbida.wukongim.message.type.WKMsgContentType;
public class WKUnknownContent extends WKMessageContent{
public WKUnknownContent(){
this.type = WKMsgContentType.WK_CONTENT_FORMAT_ERROR;
}
@Override
public String getDisplayContent() {
return "[未知消息]";
}
}

View File

@ -1,6 +1,5 @@
package com.xinbida.wukongim.protocol;
import com.xinbida.wukongim.WKIMApplication;
import com.xinbida.wukongim.message.type.WKMsgType;
/**

View File

@ -55,7 +55,7 @@ public class WKReceivedMsg extends WKBaseMsg {
public int topicIDContentLength = 0;
public WKReceivedMsg() {
packetType = WKMsgType.RECVEIVED;
packetType = WKMsgType.RECEIVED;
}
public int getPayloadLength(int remainingLength) {