public static EMMessage json2message(JSONNode jd) { EMMessage message = new EMMessage(); message.mMsgId = jd ["mMsgId"].Value; message.mFrom = jd ["mFrom"].Value; message.mTo = jd ["mTo"].Value; message.mIsUnread = (jd ["mIsUnread"].Value).Equals("true"); message.mIsListened = (jd ["mIsListened"].Value).Equals("true"); message.mIsAcked = (jd ["mIsAcked"].Value).Equals("true"); message.mIsDelivered = (jd ["mIsDelivered"].Value).Equals("true"); message.mLocalTime = (long)jd ["mLocalTime"].AsInt; message.mServerTime = (long)jd ["mServerTime"].AsInt; message.mDirection = jd ["mDirection"].AsInt; message.mStatus = jd ["mStatus"].AsInt; message.mChatType = jd ["mChatType"].AsInt; int mType = jd ["mType"].AsInt; MessageType type = (MessageType)mType; message.mType = type; message.ext = jd ["mExtJsonStr"].Value; if (type == MessageType.VIDEO || type == MessageType.FILE || type == MessageType.IMAGE || type == MessageType.VOICE) { message.mDisplayName = jd ["mDisplayName"].Value; message.mSecretKey = jd ["mSecretKey"].Value; message.mLocalPath = jd ["mLocalPath"].Value; message.mRemotePath = jd ["mRemotePath"].Value; } if (type == MessageType.TXT) { message.mTxt = jd ["mTxt"]; } else if (type == MessageType.IMAGE) { message.mThumbnailLocalPath = jd ["mThumbnailLocalPath"].Value; message.mThumbnailRemotePath = jd ["mThumbnailRemotePath"].Value; message.mThumbnailSecretKey = jd ["mThumbnailSecretKey"].Value; message.mWidth = jd ["mWidth"].AsInt; message.mHeight = jd ["mHeight"].AsInt; } else if (type == MessageType.VOICE) { message.mDuration = jd ["mDuration"].AsInt; } return(message); }
public static EMMessage json2message(JsonData jd) { EMMessage message = new EMMessage(); message.mMsgId = (string)jd ["mMsgId"]; message.mFrom = (string)jd ["mFrom"]; message.mTo = (string)jd ["mTo"]; message.mIsUnread = ((string)jd ["mIsUnread"]).Equals("true"); message.mIsListened = ((string)jd ["mIsListened"]).Equals("true"); message.mIsAcked = ((string)jd ["mIsAcked"]).Equals("true"); message.mIsDelivered = ((string)jd ["mIsDelivered"]).Equals("true"); message.mLocalTime = (long)jd ["mLocalTime"]; message.mServerTime = (long)jd ["mServerTime"]; message.mDirection = (int)jd ["mDirection"]; message.mStatus = (int)jd ["mStatus"]; message.mChatType = (int)jd ["mChatType"]; int mType = (int)jd ["mType"]; MessageType type = (MessageType)mType; message.mType = type; if (type == MessageType.VIDEO || type == MessageType.FILE || type == MessageType.IMAGE || type == MessageType.VOICE) { message.mDisplayName = (string)jd ["mDisplayName"]; message.mSecretKey = (string)jd ["mSecretKey"]; message.mLocalPath = (string)jd ["mLocalPath"]; message.mRemotePath = (string)jd ["mRemotePath"]; Debug.LogError("image"); } if (type == MessageType.TXT) { message.mTxt = (string)jd ["mTxt"]; } else if (type == MessageType.IMAGE) { message.mThumbnailLocalPath = (string)jd ["mThumbnailLocalPath"]; message.mThumbnailRemotePath = (string)jd ["mThumbnailRemotePath"]; message.mThumbnailSecretKey = (string)jd ["mThumbnailSecretKey"]; message.mWidth = (int)jd ["mWidth"]; message.mHeight = (int)jd ["mHeight"]; } else if (type == MessageType.VOICE) { message.mDuration = (int)jd ["mDuration"]; } return(message); }