I'm working on a project consisting on Client/Server. Client is written in Python (will run on linux) and server in C#. I'm communicating through standard sockets and I'm using protobuf-net for protocol definition. However, I'm wondering how would protobuf-net handle DateTime serialization. Unix datetime differs from .net standard datetime, so how should I handle this situation?
Thanks
The Protobuf serialization mechanism is given through the protoc application, this compiler will parse the . proto file and will generate as output, source files according to the configured language by its arguments, in this case, C++. You can also obtain more information about, reading the section compiler invocation.
Protobufs serialize data into binary formats which are then transmitted in bytes, the data looks very dense and smaller. It's faster to transmit over wire, serialize and deserialize them. But it is not intended to use them, if the underlying application is a web browser, and the data is fed directly to it.
Messages are not compressed.
protobuf-net is a contract based serializer for . NET code, that happens to write data in the "protocol buffers" serialization format engineered by Google.
DateTime is spoofed via a multi-field message that is not trivial, but not impossible to understand. In hindsight, I wish I had done it a different way, but it is what it is. The definition is available in bcl.proto in the protobuf-net project.
However! If you are targering multiple platforms, I strongly recommend you simply use a long
etc in your DTO model, representing some time granularity into some epoch (seconds or milliseconds since 1970, for example).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With