Beispiel #1
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);
            }
        }