0

外部設定ファイルが不要になるように、イニシエーターとアクセプターの設定をハードコーディングするにはどうすればよいですか?

これは私がこれまでに試したことです:

FIX::SessionSettings serverSettings;
FIX::Dictionary serverDictionary;

serverDictionary.setString("BeginString", "FIX.4.4");
serverDictionary.setString("UseDataDictionary", "Y");
serverDictionary.setString("DataDictionary", "../../../spec/FIX.4.4.xml");
serverDictionary.setString("SenderCompID", "SRVR");
serverDictionary.setString("TargetCompID", "CLNT");
serverDictionary.setString("SocketAcceptHost", "localhost");
serverDictionary.setLong("SocketAcceptPort", 2024);

FIX::SessionID serverSessionID;
serverSettings.set(serverSessionID, serverDictionary);

Server server; // Extends FIX::Application

FIX::FileStoreFactory serverStoreFactory("server/fileStore/");
FIX::FileLogFactory serverLogFactory("server/logs/");

FIX::SocketAcceptor acceptor(server, serverStoreFactory, serverSettings, serverLogFactory);

私は正しい道を進んでいると思いますが、このエラーが発生します:Configuration failed: BeginString must be FIX.4.0 to FIX.4.4 or FIXT.1.1

何か案は?

4

2 に答える 2

1

多くの闘争の後、私はついにこれを正しくすることができました。以下は、アクセプターの設定をハードコーディングする機能コードで、イニシエーターにも適用できます。

try {
    FIX::SessionSettings serverSettings;
    FIX::Dictionary serverDictionary;

    serverDictionary.setString("ConnectionType", "acceptor");
    serverDictionary.setString("DataDictionary", "FIX.4.4.xml");
    serverDictionary.setString("StartTime", "00:00:00");
    serverDictionary.setString("EndTime", "00:00:00");
    serverDictionary.setString("SocketAcceptHost", "localhost");
    serverDictionary.setString("SocketAcceptPort", "2024");

    FIX::SessionID serverSessionID("FIX.4.4", "SRVR", "CLNT");
    serverSettings.set(serverSessionID, serverDictionary);

    Server server;
    FIX::FileStoreFactory serverStoreFactory("server/fileStore/");
    FIX::FileLogFactory serverLogFactory("server/logs/");
    FIX::SocketAcceptor acceptor(server, serverStoreFactory, serverSettings, serverLogFactory);
    acceptor.start();
    // do something
    acceptor.stop();

    return 0;
} catch (FIX::ConfigError& e) {
    std::cout << e.what() << std::endl;
    return 1;
}
于 2012-11-20T18:27:32.423 に答える
1

「FIX.4.4」の値とは関係ありませんsetString。定義に関するものです。

void Dictionary::setString( const std::string& キー、 const std::string& value )

setStringこれらの文字列は参照によって取得され、値にアクセスしようとするまでに解放される一時変数を渡しています。関数定義を変更することはできないため、行う必要があります。

std::string key = "current key";
std::string value = "current value";
serverDictionary.setString(key, value);

setStringこれが機能するためには、すべての呼び出しに対して。少なくとも私にとっては、私がこの道を行くのを止めるでしょう.

于 2012-11-19T18:16:42.400 に答える