PdCom  5.0
Process data communication client
Loading...
Searching...
No Matches
Process.h
Go to the documentation of this file.
1/*****************************************************************************
2 * vim:tw=78
3 *
4 * Copyright (C) 2021 Richard Hacker (lerichi at gmx dot net),
5 * Florian Pose (fp at igh dot de),
6 * Bjarne von Horn (vh at igh dot de).
7 *
8 * This file is part of the PdCom library.
9 *
10 * The PdCom library is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or (at your
13 * option) any later version.
14 *
15 * The PdCom library is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with the PdCom library. If not, see <http://www.gnu.org/licenses/>.
22 *
23 *****************************************************************************/
24
27#ifndef PDCOM5_PROCESS_H
28#define PDCOM5_PROCESS_H
29
30#include "ClientStatistics.h"
31#include "pdcom5_export.h"
32
33#include <chrono>
34#include <memory>
35#include <stddef.h>
36#include <stdint.h>
37#include <string>
38#include <vector>
39
40namespace PdCom {
41namespace impl {
42class Process;
43}
44
45class SecureProcess;
46class Variable;
47class Sasl;
48class MessageManagerBase;
49
83class PDCOM5_PUBLIC Process
84{
85 friend class impl::Process;
86 friend class SecureProcess;
87
88 public:
91 Process(Process &&) = delete;
92 Process(Process const &) = delete;
93 Process &operator=(Process &&) = delete;
94 Process &operator=(Process const &) = delete;
95
96 protected:
101 virtual ~Process();
102
103 public:
105 std::string name() const;
106
108 std::string version() const;
109
121 void asyncData();
122
131
137 void
138 broadcast(const std::string &message, const std::string &attr = "text");
139
140 protected:
142 void reset();
143
151 virtual std::string applicationName() const { return "pdcom5"; }
152
163 virtual std::string hostname() const { return {}; }
164
190 virtual int read(char *buf, int count) = 0;
191
220 virtual void write(const char *buf, size_t count) = 0;
221
241 virtual void flush() = 0;
242
256 virtual void connected() = 0;
257
288 bool list(const std::string &path = "");
289
303 virtual void
304 listReply(std::vector<Variable> variables, std::vector<std::string> dirs);
305
322 bool find(const std::string &path);
323
333 virtual void findReply(const Variable &variable);
334
340
343 virtual void
344 clientStatisticsReply(std::vector<ClientStatistics> statistics);
345
347 void ping();
348
354 virtual void pingReply() {}
355
364 virtual bool alive() { return true; }
365
373
381
393 virtual void broadcastReply(
394 const std::string &message,
395 const std::string &attr,
396 std::chrono::nanoseconds time_ns,
397 const std::string &user);
398
399 private:
400 std::shared_ptr<impl::Process> pimpl;
401};
402} // namespace PdCom
403
404#endif // PDCOM5_PROCESS_H
Definition: MessageManagerBase.h:68
Base class for PdCom protocol handler.
Definition: Process.h:84
void asyncData()
Library entry point for new data.
virtual void write(const char *buf, size_t count)=0
Write data to server.
virtual int read(char *buf, int count)=0
Read data from server.
void broadcast(const std::string &message, const std::string &attr="text")
Send a broadcast message to the server and other clients.
std::string version() const
Remote process version string.
void reset()
Reset communications and clean up internal buffers.
virtual std::string hostname() const
Host name of remote server.
Definition: Process.h:163
Process()
Constructor.
virtual bool alive()
Test from process whether client is alive.
Definition: Process.h:364
virtual void broadcastReply(const std::string &message, const std::string &attr, std::chrono::nanoseconds time_ns, const std::string &user)
Recieve a broadcast message from other clients.
virtual void clientStatisticsReply(std::vector< ClientStatistics > statistics)
Reply for getClientStatistics().
virtual void connected()=0
Protocol initialization completed.
virtual void findReply(const Variable &variable)
Reply to find()
virtual std::string applicationName() const
Name of application user application.
Definition: Process.h:151
void callPendingCallbacks()
Call delayed callbacks.
void getClientStatistics()
Request client statistics from the server.
virtual void pingReply()
Ping reply.
Definition: Process.h:354
virtual ~Process()
Destructor.
void setAuthManager(Sasl *)
Register a SASL handler.
bool find(const std::string &path)
Find a variable with a corresponding path.
virtual void flush()=0
Flush unsent data in output buffer.
virtual void listReply(std::vector< Variable > variables, std::vector< std::string > dirs)
Reply to list() call.
void setMessageManager(MessageManagerBase *)
Register a Message handler.
std::string name() const
Remote process name string.
void ping()
Ping server.
bool list(const std::string &path="")
List a directory path.
SASL Interface for PdCom.
Definition: Sasl.h:42
Definition: SecureProcess.h:41
PdCom Variable interface.
Definition: Variable.h:67
library version string as "major.minor.patch"
Definition: ClientStatistics.h:31