Ejemplo n.º 1
0
        public int responseService(string toUserJID, ServiceResponseData responseData, string id, string mode, bool bCrc)
        {
            if (!(((responseData == null) || (responseData.attributes == null)) || responseData.attributes.Contains("AUTH_CODE")))
            {
                responseData.attributes.Add("AUTH_CODE", "");
            }
            if (string.IsNullOrEmpty(responseData.source))
            {
                object obj2 = this.m_keyAndSource[id];
                if (obj2 != null)
                {
                    responseData.source = obj2.ToString();
                    this.m_keyAndSource.Remove(id);
                }
            }
            string jsonData = JsonConvert.SerializeObject(responseData);
            int    crc      = 0;

            if (bCrc)
            {
                crc = this.getDataCrc(jsonData);
            }
            try
            {
                if (IsXmppOK)
                {
                    IqType result = IqType.Result;
                    this.m_xmppClient.IqResponseJieShun(result, id, jsonData, crc, responseData.resultCode, mode, toUserJID, this.m_stringUserName + "@" + this.m_stringDomain + "/" + this.m_stringResource, null);
                    return(1);
                }
                WriteConnectingStatusLog();
            }
            catch (Exception exception)
            {
                CommonConfig.Logger.WriteError("响应数据错误", exception);
            }
            return(0);
        }
Ejemplo n.º 2
0
        public int syncRequestService(string toUserJID, ServiceRequestParam requestParam, int mode, bool bCrc, int timeout, ref ServiceResponseData responseData)
        {
            string jsonData = JsonConvert.SerializeObject(requestParam);
            int    crc      = 0;
            int    result   = 1;

            if (bCrc)
            {
                crc = this.getDataCrc(jsonData);
            }
            string str2 = "SYNC";

            if (mode == 0)
            {
                str2 = "NOTIFY";
            }
            try
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                if ((mode != 0) && (timeout < 0x1388))
                {
                    timeout = 0x1388;
                }

                responseData            = new ServiceResponseData();
                responseData.resultCode = result;

                if (this.IsXmppOK)
                {
                    Iq iq = this.m_xmppClient.IqRequestJieShun(toUserJID, jsonData, crc, str2, IqType.Get, timeout, requestParam.seqId);
                    stopwatch.Stop();
                    CommonConfig.Logger.WriteInfo("syncRequestService发送完成,耗时:" + stopwatch.ElapsedMilliseconds);
                    string str3 = iq.Data.Attributes["type"].Value;

                    if (str3.ToLower().Equals("error"))
                    {
                        responseData.message = iq.Data.InnerXml;
                        return(result);
                    }
                    XmlElement data = iq.Data;
                    if (data["dres"] != null)
                    {
                        if (data["dres"]["rc"] != null)
                        {
                            int.TryParse(data["dres"]["rc"].InnerText, out result);
                        }
                        if (data["dres"]["cnt"] != null)
                        {
                            responseData = JsonConvert.DeserializeObject <ServiceResponseData>(data["dres"]["cnt"].InnerText);
                        }
                        else
                        {
                            responseData.message = data.InnerXml;
                        }
                    }
                    this.m_sendErrorTimes = 0;
                    return(result);
                }
                responseData.resultCode = 0x194;
                CommonConfig.Logger.WriteInfo("未连接状态,不发送数据");
                WriteConnectingStatusLog();
            }
            catch (Exception exception)
            {
                if (mode != 0)
                {
                    this.m_sendErrorTimes++;
                    CommonConfig.Logger.WriteError("发送数据过程出错。超时时间:" + timeout, exception);
                }
                else
                {
                    CommonConfig.Logger.WriteError("发送数据过程出错", exception);
                }
            }
            return(result);
        }
Ejemplo n.º 3
0
        public int requestService(string toUserJID, ServiceRequestParam requestParam, int mode, bool bCrc)
        {
            ServiceResponseData responseData = new ServiceResponseData();

            return(this.syncRequestService(toUserJID, requestParam, mode, bCrc, -1, ref responseData));
        }
 public virtual void execute(string fromUser, ServiceResponseData responseData)
 {
 }