Bredbandskollen CLI  1.2
Asynchronous network task engine
unixdomainbridge.h
1 // Copyright (c) 2019 Internetstiftelsen
2 // Written by Göran Andersson <initgoran@gmail.com>
3 
4 #pragma once
5 
6 #include "bridgetask.h"
8 
12 class UnixDomainBridge : public BridgeTask {
13 public:
14 
20  UnixDomainBridge(Task *agent = nullptr);
21 
23  void sendMsgToClient(const std::string &msg) override;
24 
32  int getClientSocket() const;
33 
35  int getAgentSocket() const;
36 
38  PollState connectionReady(SocketConnection * /* conn */) override;
39 
42  const std::string &msg) override;
43 
45  double start() override;
46 
47 private:
48  ShortMessageConnection *msg_conn;
49 };
Tasks may use a bridge to communicate with an application running outside the event loop.
Definition: bridgetask.h:43
Simple protocol for exchanging messages.
Definition: shortmessageconnection.h:19
This class implements low-level socket connection operations. Inherit from it to implement protocols ...
Definition: socketconnection.h:47
The purpose of a task is to manage socket connections, and/or to execute timers.
Definition: task.h:39
Bridge using a pair of Unix domain sockets to enable communication between agent and client.
Definition: unixdomainbridge.h:12
double start() override
See Task::start.
Definition: unixdomainbridge.cpp:12
PollState msgFromConnection(SocketConnection *, const std::string &msg) override
Will be called when client has sent a message.
Definition: unixdomainbridge.cpp:38
int getClientSocket() const
Get client's socket descriptor.
Definition: unixdomainbridge.cpp:22
int getAgentSocket() const
Close in child after fork.
Definition: unixdomainbridge.cpp:28
UnixDomainBridge(Task *agent=nullptr)
Create a bridge to the given agent task.
Definition: unixdomainbridge.cpp:7
PollState connectionReady(SocketConnection *) override
See Task::connectionReady.
Definition: unixdomainbridge.cpp:34
void sendMsgToClient(const std::string &msg) override
Pass message to the client.
Definition: unixdomainbridge.cpp:18
PollState
Definition: pollstate.h:11