Ejemplo n.º 1
0
        public static NIMReceivedMessage Deserialize(Newtonsoft.Json.Linq.JObject obj)
        {
            NIMReceivedMessage msg = new NIMReceivedMessage();
            var resCode            = obj.SelectToken(NIMReceivedMessage.ResCodePath);
            var feature            = obj.SelectToken(NIMReceivedMessage.FeaturePath);
            var token = obj.SelectToken(NIMReceivedMessage.MessageContentPath);

            if (resCode != null)
            {
                msg.ResponseCode = resCode.ToObject <ResponseCode>();
            }
            if (feature != null)
            {
                msg.Feature = feature.ToObject <NIMMessageFeature>();
            }

            if (token != null && token.Type == Newtonsoft.Json.Linq.JTokenType.Object)
            {
                var contentObj = token.ToObject <Newtonsoft.Json.Linq.JObject>();
                msg.TeamPushMsg = TeamForecePushMessage.Deserialize(contentObj);
                var realMsg = MessageFactory.CreateMessage(contentObj);
                msg.MessageContent = realMsg;
            }
            return(msg);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 向群组强制推送消息
        /// </summary>
        /// <param name="message">消息对象</param>
        /// <param name="forceMsg">强制推送内容</param>
        /// <param name="action">文件类消息附件上传进度</param>
        public static void SendTeamFrocePushMessage(NIMIMMessage message, TeamForecePushMessage forceMsg, ReportUploadProgressDelegate action = null)
        {
            System.Diagnostics.Debug.Assert(message != null && message.SessionType == Session.NIMSessionType.kNIMSessionTypeTeam);
            var    msgJson = forceMsg.Serialize(message);
            IntPtr ptr     = IntPtr.Zero;

            if (action != null)
            {
                NimUploadProgressData data = new NimUploadProgressData();
                data.Message        = message;
                data.ProgressAction = action;
                ptr = NimUtility.DelegateConverter.ConvertToIntPtr(data);
            }
            TalkNativeMethods.nim_talk_send_msg(msgJson, null, _uploadFileProgressChanged, ptr);
        }
Ejemplo n.º 3
0
        public static TeamForecePushMessage Deserialize(JObject obj)
        {
            TeamForecePushMessage result = null;

            JToken token = obj.SelectToken(ForcePushEnabledKey);

            if (token != null)
            {
                result             = new TeamForecePushMessage();
                result.IsForcePush = token.ToObject <int>() == 0 ? false : true;
                token          = obj.SelectToken(PushContentKey);
                result.Content = token == null ? null : token.ToObject <string>();
                token          = obj.SelectToken(PushListKey);
                if (token != null)
                {
                    var list = token.ToObject <string>();
                    result.ReceiverList = JsonParser.Deserialize <List <string> >(list);
                }
            }
            return(result);
        }