Better signature to send string from ROUTER to DEALER
AntiTenzor opened this issue · comments
I heavily use ROUTER <--> DEALER communication and I see a very common pattern like this:
`
// Somewhere at the beginning of a program execution
ZSocket clrZmqRouter = new ZSocket(clrZmqContext, ZSocketType.ROUTER);
// Many minutes later IN ANOTHER THREAD
lock (clrZmqRouter)
{
string added = "serialized message with a command";
if (clrZmqRouter.SendFrameMore(new ZFrame(dealerIdentity), ZSocketFlags.More | ZSocketFlags.DontWait, out error) &&
clrZmqRouter.SendFrame(new ZFrame(added), ZSocketFlags.DontWait, out error))
{
// All good. We are happy.
}
else
{
// Log an error.
}
}
`
q1) Is it the best and CORRECT way to make NON-BLOCKING send to the dealer?
q2) Is it possible to implement special method in ZSocket for this operation?
Something like this:
bool ZSocket.SendToDealer(string dealerIdentity, string message, ZSocketFlags flags = ZSocketFlags.DontWait, out ZError error)
q3) Is it possible to make a special class ZRouter : object that will contain ZSocket as its private field ?
And provide only some special methods to simplify ROUTER <--> DEALER communication?
Also I would like to make this ZRouter class absolutely thread safe for external callers.
Is it possible?