From 19894e0a1b6fbbcb62028fc6513ef3904a6f5c76 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Fri, 13 Apr 2012 09:34:13 +0200 Subject: Separate subscription forwarding from SUB-side filtering - subscription forwarding is handled by XSUB socket - filtering is handled by SUB sockets - subscriptions are decoupled from filter engines - filter doesn't have to be able to enumarate the subscriptions (no sf_enumerate function) Signed-off-by: Martin Sustrik --- src/sub.hpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/sub.hpp') diff --git a/src/sub.hpp b/src/sub.hpp index 47b1877..4c3bf7f 100644 --- a/src/sub.hpp +++ b/src/sub.hpp @@ -22,6 +22,10 @@ #ifndef __XS_SUB_HPP_INCLUDED__ #define __XS_SUB_HPP_INCLUDED__ +#include + +#include "../include/xs.h" + #include "xsub.hpp" namespace xs @@ -43,10 +47,33 @@ namespace xs int xsetsockopt (int option_, const void *optval_, size_t optvallen_); int xsend (xs::msg_t *msg_, int flags_); + int xrecv (xs::msg_t *msg_, int flags_); + bool xhas_in (); bool xhas_out (); + // The repository of subscriptions. + struct filter_t + { + xs_filter_t *type; + void *instance; + }; + typedef std::vector filters_t; + filters_t filters; + + // If true, part of a multipart message was already received, but + // there are following parts still waiting. + bool more; + + // If true, 'message' contains a matching message to return on the + // next recv call. + bool has_message; + msg_t message; + private: + // Check whether the message matches at least one subscription. + bool match (xs::msg_t *msg_); + sub_t (const sub_t&); const sub_t &operator = (const sub_t&); }; -- cgit v1.2.3