Beispiel #1
0
        /// <summary>
        /// 接收到消息请求
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_xmppClient_IqRequestEvents(object sender, S22.Xmpp.Im.IqEventArgs e)
        {
            string innerText = e.IqInfo.Data["dreq"]["cnt"].InnerText;
            string message   = "业务平台未实现,未处理结果";
            int    num       = 1;
            ServiceRequestParam requestParam = null;

            try
            {
                string iqID = "";
                if (e != null && e.IqInfo != null)
                {
                    iqID = e.IqInfo.Id;
                }
                CommonConfig.Logger.WriteInfo("接收到的数据推送,IqID=:" + iqID);
                requestParam = JsonConvert.DeserializeObject <ServiceRequestParam>(XmlHelper.ResumeChar(innerText));
                if (requestParam != null)
                {
                    if (this.m_reqHandler != null && requestParam.serviceId != m_serviceIdForSelf)
                    {
                        if (!this.m_keyAndSource.Contains(e.IqInfo.Id))
                        {
                            this.m_keyAndSource.Add(e.IqInfo.Id, requestParam.source);
                        }
                        this.m_reqHandler.execute(e.Jid.ToString(), requestParam, e.IqInfo.Id, "SYNC");
                        return;
                    }
                    else if (requestParam.serviceId == m_serviceIdForSelf)   //直接返回成功
                    {
                        CommonConfig.Logger.WriteInfo("接收到自发自收心跳");
                        ServiceResponseData responseData = new ServiceResponseData
                        {
                            seqId      = requestParam.seqId,
                            message    = "",
                            resultCode = 0,
                            serviceId  = m_serviceIdForSelf
                        };
                        this.responseService(e.Jid.ToString(), responseData, e.IqInfo.Id, "", true);
                    }
                    else
                    {
                        //直接回复,返回失败,未实现
                        ServiceResponseData responseData = new ServiceResponseData
                        {
                            seqId      = (requestParam != null) ? requestParam.seqId : "0",
                            message    = message,
                            resultCode = num
                        };
                        this.responseService(e.Jid.ToString(), responseData, e.IqInfo.Id, "", true);
                    }
                }
            }
            catch (Exception exception)
            {
                CommonConfig.Logger.WriteError("接收到消息返回给业务系统出错", exception);
                message = exception.Message;
                num     = 0x65;
            }
        }
Beispiel #2
0
        /// <summary>
        /// xmpp异步响应
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_xmppClient_IqResponseEvents(object sender, S22.Xmpp.Im.IqEventArgs e)
        {
            string innerText = e.IqInfo.Data["dreq"]["cnt"].InnerText;

            if (this.m_respHandler != null)
            {
                ServiceResponseData responseData = JsonConvert.DeserializeObject <ServiceResponseData>(XmlHelper.ResumeChar(innerText));
                this.m_respHandler.execute(e.Jid.ToString(), responseData);
            }
        }