summaryrefslogtreecommitdiff
path: root/src/session_base.cpp
diff options
context:
space:
mode:
authorMartin Lucina <martin@lucina.net>2012-05-20 10:40:36 +0200
committerMartin Lucina <martin@lucina.net>2012-05-20 10:40:36 +0200
commit2601b302685c48e6aa8f507d200f148397811fae (patch)
tree5103e3fab82394585df96be9892600ecfd55accc /src/session_base.cpp
parent1d76284dee8e9b0735a26ee98a3edcd9f5208f09 (diff)
[WIP] UDP supportudp
Signed-off-by: Martin Lucina <martin@lucina.net>
Diffstat (limited to 'src/session_base.cpp')
-rw-r--r--src/session_base.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/session_base.cpp b/src/session_base.cpp
index da9ee8e..f8a1cd1 100644
--- a/src/session_base.cpp
+++ b/src/session_base.cpp
@@ -30,6 +30,8 @@
#include "ipc_connecter.hpp"
#include "pgm_sender.hpp"
#include "pgm_receiver.hpp"
+#include "udp_sender.hpp"
+#include "udp_receiver.hpp"
#include "req.hpp"
#include "xreq.hpp"
@@ -484,6 +486,42 @@ void xs::session_base_t::start_connecting (bool wait_)
}
#endif
+ // UDP support.
+ if (protocol == "udp") {
+
+ // At this point we'll create message pipes to the session straight
+ // away. There's no point in delaying it as no concept of 'connect'
+ // exists with UDP anyway.
+ if (options.type == XS_PUB || options.type == XS_XPUB) {
+
+ // UDP sender.
+ udp_sender_t *udp_sender = new (std::nothrow) udp_sender_t (
+ io_thread, options);
+ alloc_assert (udp_sender);
+
+ int rc = udp_sender->init (address.c_str ());
+ xs_assert (rc == 0);
+
+ send_attach (this, udp_sender);
+ }
+ else if (options.type == XS_SUB || options.type == XS_XSUB) {
+
+ // UDP receiver.
+ udp_receiver_t *udp_receiver = new (std::nothrow) udp_receiver_t (
+ io_thread, options);
+ alloc_assert (udp_receiver);
+
+ int rc = udp_receiver->init (address.c_str ());
+ xs_assert (rc == 0);
+
+ send_attach (this, udp_receiver);
+ }
+ else
+ xs_assert (false);
+
+ return;
+ }
+
xs_assert (false);
}