summaryrefslogtreecommitdiff
path: root/src/session.cpp
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@fastmq.commkdir>2009-08-21 14:29:22 +0200
committerMartin Sustrik <sustrik@fastmq.commkdir>2009-08-21 14:29:22 +0200
commit6be4b0143793ab5ceebc5d9d6bbe5c2f1333a0d2 (patch)
treea785065e54317d1d360e2e4b3a4acf1d6e5669f1 /src/session.cpp
parenta801b6d8b37557ccfb53030dca22f89a3f99b59c (diff)
session management implemented
Diffstat (limited to 'src/session.cpp')
-rw-r--r--src/session.cpp39
1 files changed, 30 insertions, 9 deletions
diff --git a/src/session.cpp b/src/session.cpp
index 2bb4ff6..fc1f858 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -22,9 +22,10 @@
#include "err.hpp"
zmq::session_t::session_t (object_t *parent_, socket_base_t *owner_,
- zmq_engine_t *engine_) :
+ const char *name_) :
owned_t (parent_, owner_),
- engine (engine_)
+ engine (NULL),
+ name (name_)
{
}
@@ -32,12 +33,12 @@ zmq::session_t::~session_t ()
{
}
-bool zmq::session_t::read (::zmq_msg *msg_)
+bool zmq::session_t::read (::zmq_msg_t *msg_)
{
return false;
}
-bool zmq::session_t::write (::zmq_msg *msg_)
+bool zmq::session_t::write (::zmq_msg_t *msg_)
{
return false;
}
@@ -48,14 +49,34 @@ void zmq::session_t::flush ()
void zmq::session_t::process_plug ()
{
- zmq_assert (engine);
- engine->plug (this);
+ // Register the session with the socket.
+ bool ok = owner->register_session (name.c_str (), this);
+
+ // There's already a session with the specified identity.
+ // We should syslog it and drop the session. TODO
+ zmq_assert (ok);
+
owned_t::process_plug ();
}
void zmq::session_t::process_unplug ()
{
- zmq_assert (engine);
- engine->unplug ();
- delete engine;
+ // Unregister the session from the socket.
+ bool ok = owner->unregister_session (name.c_str ());
+ zmq_assert (ok);
+
+ if (engine) {
+ engine->unplug ();
+ delete engine;
+ engine = NULL;
+ }
+}
+
+void zmq::session_t::process_attach (class zmq_engine_t *engine_)
+{
+ zmq_assert (engine_);
+ engine = engine_;
+ engine->plug (this);
+
+ owned_t::process_attach (engine_);
}