| 40 | } |
| 41 | |
| 42 | void zmq::xpub_t::xattach_pipe (pipe_t *pipe_, |
| 43 | bool subscribe_to_all_, |
| 44 | bool locally_initiated_) |
| 45 | { |
| 46 | LIBZMQ_UNUSED (locally_initiated_); |
| 47 | |
| 48 | zmq_assert (pipe_); |
| 49 | _dist.attach (pipe_); |
| 50 | |
| 51 | // If subscribe_to_all_ is specified, the caller would like to subscribe |
| 52 | // to all data on this pipe, implicitly. |
| 53 | if (subscribe_to_all_) |
| 54 | _subscriptions.add (NULL, 0, pipe_); |
| 55 | |
| 56 | // if welcome message exists, send a copy of it |
| 57 | if (_welcome_msg.size () > 0) { |
| 58 | msg_t copy; |
| 59 | copy.init (); |
| 60 | const int rc = copy.copy (_welcome_msg); |
| 61 | errno_assert (rc == 0); |
| 62 | const bool ok = pipe_->write (©); |
| 63 | zmq_assert (ok); |
| 64 | pipe_->flush (); |
| 65 | } |
| 66 | |
| 67 | // The pipe is active when attached. Let's read the subscriptions from |
| 68 | // it, if any. |
| 69 | xread_activated (pipe_); |
| 70 | } |
| 71 | |
| 72 | void zmq::xpub_t::xread_activated (pipe_t *pipe_) |
| 73 | { |