如何使登录部分在QuickFIX [英] How to make the login part in QuickFIX

查看:1447
本文介绍了如何使登录部分在QuickFIX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在c ++中的QuickFIX中登录部分?
我发现了许多关于如何在c#或java上做这些的教程和文章,但在c ++上没有。

How can I make the login part in QuickFIX in c++? I found tons of tutorials and articles on how to do this on c# or java, but nothing on c++.

我有一个服务器客户端(启动器)。客户端的用户名和密码存储在设置文件中,并在服务器程序中硬编码。

I have a server (acceptor), and a client (initiator). The username and password of the client are stored in the settings file, and are hardcoded in the server program.

根据我在客户端中读取的内容,我设置了用户名和 fromAdmin()中的密码和读取并检查服务器中 toAdmin()

From what I've read in the client I set the username and password in fromAdmin() and read and check the in the server in the toAdmin(), but how do I do that?

这里是我到目前为止所尝试的:

Here's what I've tried so far:


  • p>使用以下命令将消息转换为 FIX44 :: Logon& 对象:
FIX44::Logon& logon_message = dynamic_cast<FIX44::Logon&>(message);


  • 如下所示设置登录对象的用户名和密码:

  • Set the Username and password to the logon object like this:

    if(session_settings.has("Username"))
    {
        FIX::Username username = session_settings.getString("Username");
        logon_message.set(username);
    }
    


  • 并发送以下讯息:

  • And send the message like this:

    FIX::Message messageToSend = logon_message;
    FIX::Session::sendToTarget(messageToSend);
    


  • cannot dynamic_cast 'message' (of type 'class FIX::Message') to type 'struct FIX44::Logon&' (target is not pointer or reference to complete type)
    

    我试过我的灵感来自< a href =http://niki.code-karma.com/2011/01/quickfix-logon-support-for-username-password/comment-page-1/ =nofollow> http:// niki .code-karma.com / 2011/01 / quickfix-logon-support-for-username-password / comment-page-1 / 。

    任何人都可以帮助我吗?

    Can anyone help me?

    推荐答案

    可能的错误:

    1)我认为你有 fromAdmin() / toAdmin()向后。前者在传出管理消息时调用,后者在传入时调用。对于启动器,您必须设置 toAdmin()回调中的字段。您的接受者将检查 fromAdmin()中的用户/传票。

    1) I think you have fromAdmin()/toAdmin() backward. The former is called on outgoing admin messages, the latter is called on incoming. For the Initiator, you must set the fields within the toAdmin() callback. Your Acceptor will check the user/pass in fromAdmin().

    2)您尝试 dynamic_cast ,无需先检查它是否为登录消息? toAdmin()回调处理所有管理消息;该消息可能是心跳,登录,注销等。这可能解释你的转换错误。

    2) Are you trying to dynamic_cast without first checking to see if it was a Logon message? The toAdmin() callback handles all admin messages; the message could be a Heartbeat, Logon, Logout, etc. That might explain your cast error.

    对于什么代码应该看起来,我的C ++是生锈,但基本模式是:

    As to what the code should look like, my C++ is rusty, but the basic pattern is this:

    void YourMessageCracker::toAdmin( FIX::Message& message, const FIX::SessionID& sessionID)
    {
        if (FIX::MsgType_Logon == message.getHeader().getField(FIX::FIELD::MsgType))
        {
            FIX44::Logon& logon_message = dynamic_cast<FIX44::Logon&>(message);
            logon_message.setField(FIX::Username("my_username"));
            logon_message.setField(FIX::Password("my_password"));
        }
    }
    

    d从Admin()中输入类似的,您将得到这些字段,而不是设置它们。

    From there, I think you can see how you'd write a similar fromAdmin() where you'd get the fields instead of setting them.

    硬编码的用户/ pass,但你可能想从配置文件中拉。我认为你对 session_settings.getString(str)的调用是正确的。

    The above uses hard-coded user/pass, but you probably want to pull it from the config file. I think your calls to session_settings.getString(str) are correct for that.

    (请原谅任何编码错误。我更加流利的QF引擎的Java / C#版本,虽然基本原则是一样的。)

    (Please forgive any coding errors. I'm much more fluent in the Java/C# versions of the QF engine, though the basic principles are the same.)

    我看到您的第一个网络引用使用 FIELD_GET_REF 宏。它可能优于 message.getHeader()。getField(),但我不熟悉。

    I see that your first web reference uses the FIELD_GET_REF macro. It may be better than message.getHeader().getField(), but I'm not familiar with it.

    EDIT:我希望您在完成我的45次修改之后才开始阅读此文章。我认为现在很好。

    I hope you didn't start reading this until I finished my 45 edits of it. I think it's good now.

    这篇关于如何使登录部分在QuickFIX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆