From e86827511b35231679085dc236e9744184ed4609 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sat, 14 Apr 2012 14:33:59 +0200 Subject: Filters can transform user subscriptions to wire subscription Till now the subscription, as specified by the user, was send upstream. This patch allows SUB-side filter to transform the user subscription into wire subscription. For example, only a has can be sent upstream instead of a perfect subscription. Signed-off-by: Martin Sustrik --- src/sub.hpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/sub.hpp') diff --git a/src/sub.hpp b/src/sub.hpp index 4c3bf7f..c50c0bd 100644 --- a/src/sub.hpp +++ b/src/sub.hpp @@ -27,6 +27,7 @@ #include "../include/xs.h" #include "xsub.hpp" +#include "core.hpp" namespace xs { @@ -36,21 +37,26 @@ namespace xs class io_thread_t; class socket_base_t; - class sub_t : public xsub_t + class sub_t : public xsub_t, public core_t { public: sub_t (xs::ctx_t *parent_, uint32_t tid_, int sid_); ~sub_t (); - protected: + private: + // Overloaded functions from socket_base_t. 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 (); + // Overloaded functions from core_t. + int filter_subscribed (const unsigned char *data_, size_t size_); + int filter_unsubscribed (const unsigned char *data_, size_t size_); + // The repository of subscriptions. struct filter_t { @@ -69,8 +75,6 @@ namespace xs bool has_message; msg_t message; - private: - // Check whether the message matches at least one subscription. bool match (xs::msg_t *msg_); -- cgit v1.2.3