Conversation
use re-entrant safe gmtime in Message::timestamp
|
Some of the indentation is a little funny, and some of the comments might be not quite right, but those are because I was trying to make changes only where necessary to show what little of camerad had to be changed (if I had properly indented code then a lot of lines would have been flagged as changed, obscuring the meaningful changes). |
| zmq::message_t routing_frame, messageid_frame, payload_frame; | ||
|
|
||
| // received the frames from the router | ||
| auto frame1 = router.recv(routing_frame, zmq::recv_flags::none); |
There was a problem hiding this comment.
My recommendation would be to have some sort of Message class
class Message {
public:
std::string id;
std::string type;
std::string payload;
};
That will allow us to shift the message from
[routing][message_id][payload] to serialized messages [routing][message_id][serialized message]
That will allow us to not have to parse for things like
ACK
DONE
ERROR something bad
So we can use type
REQUEST
ACK
DONE
ERROR
PING
PONG
PROGRESS
EVENT
and then our payload would be
{
"id": "42",
"type": "DONE",
"payload": "focus set to 2.5"
}
then we go from if (payload==Message::MSG_PING) to if (msg.type == "PING")
There was a problem hiding this comment.
That's a great idea.
I wrote a stand-alone ZMQ message library to replace the daemon server sockets. I've been wanting to do this for awhile because I think it will help NGPS inter-daemon communication reliability, and it makes sense (to me) that camera2 daemon uses the new method.
This is a header-only library.
It currently defines
Message::ServerandMessage::Clientwhich use the ROUTER-DEALER pattern.I will eventually move my existing
Common::PubSubclass (currently only in NGPS) from common.h to this message.hThe
Networkcode remains in the repo because it is needed for other things (like Archon communication, for example).