null_mechanism.hpp 2.08 KB
Newer Older
1
/*
2
    Copyright (c) 2007-2014 Contributors as noted in the AUTHORS file
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

    This file is part of 0MQ.

    0MQ is free software; you can redistribute it and/or modify it under
    the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    0MQ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef __ZMQ_NULL_MECHANISM_HPP_INCLUDED__
#define __ZMQ_NULL_MECHANISM_HPP_INCLUDED__

#include "mechanism.hpp"
#include "options.hpp"

namespace zmq
{

    class msg_t;
30
    class session_base_t;
31 32 33 34 35

    class null_mechanism_t : public mechanism_t
    {
    public:

36 37 38
        null_mechanism_t (session_base_t *session_,
                          const std::string &peer_address,
                          const options_t &options_);
39 40 41
        virtual ~null_mechanism_t ();

        // mechanism implementation
42 43
        virtual int next_handshake_command (msg_t *msg_);
        virtual int process_handshake_command (msg_t *msg_);
44
        virtual int zap_msg_available ();
45
        virtual status_t status () const;
46 47 48

    private:

49 50
        session_base_t * const session;

51 52
        char status_code [3];

53 54
        const std::string peer_address;

55
        bool ready_command_sent;
56
        bool error_command_sent;
57
        bool ready_command_received;
58
        bool error_command_received;
59 60 61 62
        bool zap_connected;
        bool zap_request_sent;
        bool zap_reply_received;

63 64 65 66 67
        int process_ready_command (
            const unsigned char *cmd_data, size_t data_size);
        int process_error_command (
            const unsigned char *cmd_data, size_t data_size);

68 69
        void send_zap_request ();
        int receive_and_process_zap_reply ();
70 71 72 73 74
    };

}

#endif