snaplock: snaplock_messenger.cpp Source File

snaplock  1.7.14
The multi-computer lock service.
snaplock_messenger.cpp
Go to the documentation of this file.
1 /*
2  * Text:
3  * snaplock/src/snaplock_messenger.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 messenger implementation listens for messages from other
10  * services. It understands the basic messages as well as the
11  * LOCK and other messages implemented by the snaplock implementation
12  * (since snaplock daemons communicate between each others.)
13  *
14  * License:
15  * Copyright (c) 2016-2019 Made to Order Software Corp. All Rights Reserved
16  *
19  *
20  * Permission is hereby granted, free of charge, to any person obtaining a
21  * copy of this software and associated documentation files (the
22  * "Software"), to deal in the Software without restriction, including
23  * without limitation the rights to use, copy, modify, merge, publish,
24  * distribute, sublicense, and/or sell copies of the Software, and to
25  * permit persons to whom the Software is furnished to do so, subject to
26  * the following conditions:
27  *
28  * The above copyright notice and this permission notice shall be included
29  * in all copies or substantial portions of the Software.
30  *
31  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
32  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
34  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
35  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
36  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
37  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38  */
39 
40 
41 // ourselves
42 //
43 #include "snaplock.h"
44 
45 // our lib
46 //
47 #include <snapwebsites/log.h>
48 
49 
50 
51 namespace snaplock
52 {
78 snaplock_messenger::snaplock_messenger(snaplock * sl, std::string const & addr, int port)
79  : snap_tcp_client_permanent_message_connection(addr, port)
80  , f_snaplock(sl)
81 {
82  set_name("snaplock messenger");
83 }
84 
85 
95 void snaplock_messenger::process_connection_failed(std::string const & error_message)
96 {
97  SNAP_LOG_ERROR("connection to snapcommunicator failed (")(error_message)(")");
98 
99  // also call the default function, just in case
100  //
101  snap_tcp_client_permanent_message_connection::process_connection_failed(error_message);
102 }
103 
104 
114 {
115  snap_tcp_client_permanent_message_connection::process_connected();
116 
117  snap::snap_communicator_message register_snaplock;
118  register_snaplock.set_command("REGISTER");
119  register_snaplock.add_parameter("service", "snaplock");
120  register_snaplock.add_parameter("version", snap::snap_communicator::VERSION);
121  send_message(register_snaplock);
122 }
123 
124 
125 }
126 // snaplock namespace
127 // vim: ts=4 sw=4 et
virtual void process_connection_failed(std::string const &error_message) override
The messenger could not connect to snapcommunicator.
virtual void process_connected() override
The connection was established with Snap! Communicator.
snaplock_messenger(snaplock *sl, std::string const &addr, int port)
The messenger initialization.

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