Exemplo n.º 1
0
        public int SendAsync(CT2BizMessage message)
        {
            int iRet = _conn.SendBizMsg(message, 1);

            if (iRet < 0)
            {
                logger.Error(string.Format("异步发送数据失败! 错误码:{0}, 错误消息:{1}", iRet, _conn.GetErrorMsg(iRet)));
                return(iRet);
            }

            return(iRet);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 通过调用UFX接口异步发送请求,调用前必须确保已经注册了功能号和回调代理,即调用Register函数注册。
        /// 同一功能号注册多次只会保留最后一次结果。
        /// </summary>
        /// <param name="message">CT2BizMessage对象的实例,包含用户信息,功能号,请求参数等信息</param>
        /// <returns>返回正值表示发送句柄,否则表示失败。</returns>
        public int SendAsync(CT2BizMessage message)
        {
            int hSend = _conn.SendBizMsg(message, (int)SendType.Async);

            if (hSend < 0)
            {
                string msg = string.Format("一般交易业务异步发送数据失败! 错误码:{0}, 错误消息:{1}", hSend, _conn.GetErrorMsg(hSend));
                logger.Error(msg);
                return(hSend);
            }

            return(hSend);
        }
Exemplo n.º 3
0
        public override void OnReceivedBizMsg(CT2Connection lpConnection, int hSend, CT2BizMessage lpMsg)
        {
            int iRetCode   = lpMsg.GetErrorNo();    //获取返回码
            int iErrorCode = lpMsg.GetReturnCode(); //获取错误码
            int iFunction  = lpMsg.GetFunction();

            if (iRetCode != 0)
            {
                Debug.Print("异步接收出错:" + lpMsg.GetErrorNo().ToString() + lpMsg.GetErrorInfo());
            }
            else
            {
                if (iFunction == 620000)//1.0消息中心心跳
                {
                    Debug.Print("收到心跳!==>" + iFunction);
                    lpMsg.ChangeReq2AnsMessage();
                    connMain.SendBizMsg(lpMsg, 1);
                    return;
                }
                else if (iFunction == 620003 || iFunction == 620025) //收到发布过来的行情
                {
                    Debug.Print("收到主推消息!==>" + iFunction);
                    int         iKeyInfo  = 0;
                    void *      lpKeyInfo = lpMsg.GetKeyInfo(&iKeyInfo);
                    CT2UnPacker unPacker  = new CT2UnPacker(lpKeyInfo, (uint)iKeyInfo);
                    //this.ShowUnPacker(unPacker);
                    unPacker.Dispose();
                }
                else if (iFunction == 620001)
                {
                    Debug.Print("收到订阅应答!==>");
                    return;
                }
                else if (iFunction == 620002)
                {
                    Debug.Print("收到取消订阅应答!==>");
                    return;
                }

                CT2UnPacker unpacker = null;
                unsafe
                {
                    int   iLen   = 0;
                    void *lpdata = lpMsg.GetContent(&iLen);
                    unpacker = new CT2UnPacker(lpdata, (uint)iLen);
                }
                if (iFunction == 10001)
                {
                    int code = unpacker.GetInt("ErrCode");
                    if (code == 0)
                    {
                        unpacker.SetCurrentDatasetByIndex(1);
                        token = unpacker.GetStr("user_token");
                    }
                }
                //this.ShowUnPacker(unpacker);
            }
        }