summaryrefslogtreecommitdiff
path: root/src/sub.hpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2012-04-14 14:33:59 +0200
committerMartin Sustrik <sustrik@250bpm.com>2012-04-15 06:56:54 +0200
commite86827511b35231679085dc236e9744184ed4609 (patch)
treec8aea816ed2c5ed6b1d383367c6e34576b2c3d7c /src/sub.hpp
parent71cf5791422c7a461520fce8225342c27821e774 (diff)
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 <sustrik@250bpm.com>
Diffstat (limited to 'src/sub.hpp')
-rw-r--r--src/sub.hpp12
1 files changed, 8 insertions, 4 deletions
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_);