snaplock: snaplock_tool.cpp Source File

snaplock  1.7.14
The multi-computer lock service.
snaplock_tool.cpp
Go to the documentation of this file.
1 /*
2  * Text:
3  * snaplock/src/snaplock_tool.cpp
4  *
5  * Description:
6  * A daemon to synchronize processes between any number of computers
7  * by blocking all of them but one.
8  *
9  * The tool implementation is used to send messages to the running
10  * daemon to get information such as the list of tickets and
11  * statistics.
12  *
13  * License:
14  * Copyright (c) 2016-2019 Made to Order Software Corp. All Rights Reserved
15  *
18  *
19  * Permission is hereby granted, free of charge, to any person obtaining a
20  * copy of this software and associated documentation files (the
21  * "Software"), to deal in the Software without restriction, including
22  * without limitation the rights to use, copy, modify, merge, publish,
23  * distribute, sublicense, and/or sell copies of the Software, and to
24  * permit persons to whom the Software is furnished to do so, subject to
25  * the following conditions:
26  *
27  * The above copyright notice and this permission notice shall be included
28  * in all copies or substantial portions of the Software.
29  *
30  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
31  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
33  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
34  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
35  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
36  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
37  */
38 
39 
40 // self
41 //
42 #include "snaplock.h"
43 
44 
45 // snapwebsites lib
46 //
47 #include <snapwebsites/log.h>
48 
49 
50 // last include
51 //
52 #include <snapdev/poison.h>
53 
54 
55 
56 namespace snaplock
57 {
58 
84 snaplock_tool::snaplock_tool(snaplock * sl, std::string const & addr, int port)
85  : snaplock_messenger(sl, addr, port)
86 {
87  set_name("snaplock tool");
88 }
89 
90 
100 void snaplock_tool::process_message(snap::snap_communicator_message const & message)
101 {
102  f_snaplock->tool_message(message);
103 }
104 
105 
119 void snaplock_tool::process_connection_failed(std::string const & error_message)
120 {
121  SNAP_LOG_ERROR("The connection to snapcommunicator and/or snaplock failed. ")(error_message);
122 
123  snap_timer::process_error();
124 }
125 
126 
136 {
137  snap_tcp_client_permanent_message_connection::process_connected();
138 
139  snap::snap_communicator_message register_snaplock;
140  register_snaplock.set_command("REGISTER");
141  register_snaplock.add_parameter("service", "snaplocktool");
142  register_snaplock.add_parameter("version", snap::snap_communicator::VERSION);
143  send_message(register_snaplock);
144 }
145 
146 
147 }
148 // snaplock namespace
149 // vim: ts=4 sw=4 et
void tool_message(snap::snap_communicator_message const &message)
Process a message received from Snap! Communicator.
Definition: snaplock.cpp:4153
virtual void process_message(snap::snap_communicator_message const &message)
Pass messages to Snap Lock.
virtual void process_connection_failed(std::string const &error_message)
The connection failed, cancel everything.
virtual void process_connected()
The connection was established with Snap! Communicator.
snaplock_tool(snaplock *sl, std::string const &addr, int port)
The messenger initialization.
Handle messages from the Snap Communicator server.
Definition: snaplock.h:153

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