Skip to content

How to implement msgpack deserialized with Timestamp #1130

Open
@NickLin910221

Description

With C++ 11 https://github.com/msgpack/msgpack-c.git branch:cpp_master

std::cout << message << std::endl;
msgpack::object_handle oh = msgpack::unpack(message.data(), message.size());

msgpack::object deserialized = oh.get();

std::cout << deserialized << std::endl;

Tick tick;
deserialized.convert(tick);

std::cout << "Received Tick: " 
          << "exchange=" << tick.exchange
          << ", code=" << tick.code
          << ", timestamp=" << tick.timestamp.seconds << "." << tick.timestamp.nanoseconds
          << ", close=" << tick.close
          << ", volume=" << tick.volume
          << std::endl;

I sent the msgpack packet with python in
{'exchange': 'TFE', 'code': 'TXFR1', 'timestamp': Timestamp(seconds=1718040379, nanoseconds=767436000), 'close': 21000.0, 'volume': 1.0, 'tick_Type': 0, 'simtrade': 1}

And I can receive msg payload in C++ as
{"method":"Publish","exchange":"TFE","code":"TXFR1","timestamp":"EXT(type:-1,size:8)","close":21000,"volume":1,"tick_Type":0,"simtrade":1}

And How to deserialized with the ext. type with Timestamp.

I use origin msgpack support msgpack.Timestamp to encode the packet

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions