From 443d06f894751062da6d69238ce09f6fbfc27577 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sun, 15 Apr 2012 13:10:41 +0200 Subject: "Survey" pattern implemented Survey pattern is "multicast with reply". There are two roles: surveyor and respondent. Surveyor publishes a survey which gets delivered to all connected respondents. Each repondent can send a response to the survey. All the responses are delivered to the original surveyor. Once the surveyor decides that the survey is over (e.g. deadline was reached) it can send initiate survey. Late responses from old surveys are automatically discarded by the surveyor socket. Socket types: SURVEYOR, XSURVEYOR, RESPONDENT, XRESPONDENT Patch also includes a test program with surveoyr, two respondents and an intermediary device. Signed-off-by: Martin Sustrik --- src/socket_base.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/socket_base.cpp') diff --git a/src/socket_base.cpp b/src/socket_base.cpp index eb9b491..df182f1 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -61,6 +61,10 @@ #include "xrep.hpp" #include "xpub.hpp" #include "xsub.hpp" +#include "surveyor.hpp" +#include "xsurveyor.hpp" +#include "respondent.hpp" +#include "xrespondent.hpp" bool xs::socket_base_t::check_tag () { @@ -106,6 +110,18 @@ xs::socket_base_t *xs::socket_base_t::create (int type_, class ctx_t *parent_, case XS_XSUB: s = new (std::nothrow) xsub_t (parent_, tid_, sid_); break; + case XS_SURVEYOR: + s = new (std::nothrow) surveyor_t (parent_, tid_, sid_); + break; + case XS_XSURVEYOR: + s = new (std::nothrow) xsurveyor_t (parent_, tid_, sid_); + break; + case XS_RESPONDENT: + s = new (std::nothrow) respondent_t (parent_, tid_, sid_); + break; + case XS_XRESPONDENT: + s = new (std::nothrow) xrespondent_t (parent_, tid_, sid_); + break; default: errno = EINVAL; return NULL; -- cgit v1.2.3