March 2013
Intermediate to advanced
516 pages
15h 11m
English
One of the nice things about the multithreaded API model we’re using is that it’s essentially message-based. This makes it ideal for returning events back to the caller. A more conventional API approach would be to use callbacks, but callbacks that cross thread boundaries are somewhat delicate. Here’s how the client sends a message back when it has received a complete file:
zstr_sendm(self->pipe,"DELIVER");zstr_sendm(self->pipe,filename);zstr_sendf(self->pipe,"%s/%s",inbox,filename);
We can now add a _recv() method to the API that
waits for events back from the client. It makes a clean style for the
caller: create the client object, configure it, and then receive and
process any events it returns.
Read now
Unlock full access