snaplock: snaplock::snaplock_tool Class Reference

snaplock::snaplock_tool Class Reference

Handle snaplock command line commands. More...

#include <snaplock.h>

Inheritance diagram for snaplock::snaplock_tool:
Collaboration diagram for snaplock::snaplock_tool:
Public Types typedef std::shared_ptr< snaplock_toolpointer_t   Public Member Functions  snaplock_tool (snaplock *sl, std::string const &addr, int port)  The messenger initialization. More...
   snaplock_tool (snaplock_tool const &rhs)=delete   virtual ~snaplock_tool () override   snaplock_tooloperator= (snaplock_tool const &rhs)=delete   virtual void process_connected ()  The connection was established with Snap! Communicator. More...
  virtual void process_connection_failed (std::string const &error_message)  The connection failed, cancel everything. More...
  virtual void process_message (snap::snap_communicator_message const &message)  Pass messages to Snap Lock. More...
  Protected Attributes snaplockf_snaplock = nullptr   Detailed Description

This class is an implementation of the TCP client message connection so we can handle incoming messages.

Definition at line 176 of file snaplock.h.

Member Typedef Documentation
typedef std::shared_ptr<snaplock_tool> snaplock::snaplock_tool::pointer_t

Definition at line 180 of file snaplock.h.

Constructor & Destructor Documentation
snaplock::snaplock_tool::snaplock_tool ( snaplocksl, std::string const &  addr, int  port  )

The messenger is a connection to the snapcommunicator server.

From the outside, we receive STOP and QUITTING messages. We implement a few other generic messages too (HELP, READY...) Then we support "internal" messages used to gather statistics from a running snaplock daemon.

We use a permanent connection so if the snapcommunicator restarts for whatever reason, we reconnect automatically.

[in]slThe snaplock server we are listening for. [in]addrThe address to connect to. Most often it is [in]portThe port to listen on (4040).

Definition at line 84 of file snaplock_tool.cpp.

snaplock::snaplock_tool::snaplock_tool ( snaplock_tool const &  rhs) delete
virtual snaplock::snaplock_tool::~snaplock_tool ( ) inlineoverridevirtual

Definition at line 184 of file snaplock.h.

Member Function Documentation
snaplock_tool& snaplock::snaplock_tool::operator= ( snaplock_tool const &  rhs) delete
void snaplock::snaplock_tool::process_connected ( ) virtual

Whenever the connection is established with the Snap! Communicator, this callback function is called.

The tool reacts by REGISTERing as snaplocktool with the Snap! Communicator.

Reimplemented from snaplock::snaplock_messenger.

Definition at line 135 of file snaplock_tool.cpp.

void snaplock::snaplock_tool::process_connection_failed ( std::string const &  error_message) virtual

In case of the snaplock tools, we do not want to go on when the connection fails. But since we derive from the snaplock_messenger, we inherit the permanent connection which by default goes on "forever".

This function reimplementation allows us to ignore the error.

In terms of permanent connection, this is similar to having the f_done flag set to true.

[in]error_messageAn error message about what happened.

Reimplemented from snaplock::snaplock_messenger.

Definition at line 119 of file snaplock_tool.cpp.

void snaplock::snaplock_tool::process_message ( snap::snap_communicator_message const &  message) virtual

This callback is called whenever a message is received from Snap! Communicator. The message is immediately forwarded to the snaplock object which is expected to process it and reply if required.

[in]messageThe message we just received.

Definition at line 100 of file snaplock_tool.cpp.

References snaplock::snaplock_messenger::f_snaplock, and snaplock::snaplock::tool_message().

Member Data Documentation
The documentation for this class was generated from the following files:

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly