From 0381a78c0484012e760d61051f325c71136df17e Mon Sep 17 00:00:00 2001 From: malosek Date: Tue, 15 Sep 2009 13:47:15 +0200 Subject: added reset method into zmq_decoder_t class --- src/zmq_decoder.cpp | 10 ++++++++++ src/zmq_decoder.hpp | 2 ++ 2 files changed, 12 insertions(+) (limited to 'src') diff --git a/src/zmq_decoder.cpp b/src/zmq_decoder.cpp index 53811a1..ccaad0d 100644 --- a/src/zmq_decoder.cpp +++ b/src/zmq_decoder.cpp @@ -36,6 +36,16 @@ zmq::zmq_decoder_t::~zmq_decoder_t () zmq_msg_close (&in_progress); } +void zmq::zmq_decoder_t::reset () +{ + // Free and reinit message buffer. + zmq_msg_close (&in_progress); + zmq_msg_init (&in_progress); + + // Restart the FSM. + next_step (tmpbuf, 1, &zmq_decoder_t::one_byte_size_ready); +} + void zmq::zmq_decoder_t::set_inout (i_inout *destination_) { destination = destination_; diff --git a/src/zmq_decoder.hpp b/src/zmq_decoder.hpp index 16b5312..6bc373b 100644 --- a/src/zmq_decoder.hpp +++ b/src/zmq_decoder.hpp @@ -37,6 +37,8 @@ namespace zmq void set_inout (struct i_inout *destination_); + // Clears any partially decoded messages. + void reset (); private: bool one_byte_size_ready (); -- cgit v1.2.3