discord_ipc_cpp
1.0.0
C++ library for interfacing with Discord IPC socket.
Toggle main menu visibility
Loading...
Searching...
No Matches
socket_client.hpp
1
/*
2
Copyright 2026 Peter Duanmu
3
4
You should have received a copy of the GNU General Public License along
5
with discord_ipc_cpp. If not, see <https://www.gnu.org/licenses/>.
6
*/
7
8
#ifndef DISCORD_IPC_CPP_INCLUDE_DISCORD_IPC_CPP_SOCKET_CLIENT_HPP_
9
#define DISCORD_IPC_CPP_INCLUDE_DISCORD_IPC_CPP_SOCKET_CLIENT_HPP_
10
11
#include <poll.h>
12
#include <sys/socket.h>
13
#include <sys/un.h>
14
15
#include <string>
16
#include <optional>
17
#include <vector>
18
26
namespace
discord_ipc_cpp::websockets
{
35
class
SocketClient
{
36
private
:
40
std::string _socket_file;
41
45
int
_client_socket;
49
struct
sockaddr_un _server_addr;
50
54
struct
pollfd _fds[1];
55
56
public
:
60
explicit
SocketClient
(
const
std::string& socket_file);
66
~SocketClient
();
67
73
bool
connect
();
79
bool
close
();
80
90
bool
send_data
(
const
std::vector<char>& data);
104
std::optional<std::vector<char>>
recv_data
(
int
buffer_size);
119
std::optional<std::vector<char>>
recv_data
(
int
buffer_size,
int
timeout);
120
};
121
}
// namespace discord_ipc_cpp::websockets
122
123
#endif
// DISCORD_IPC_CPP_INCLUDE_DISCORD_IPC_CPP_SOCKET_CLIENT_HPP_
discord_ipc_cpp::websockets::SocketClient::connect
bool connect()
Attempts to connect to the socket file.
discord_ipc_cpp::websockets::SocketClient::~SocketClient
~SocketClient()
Cleans up socket the socket connection.
discord_ipc_cpp::websockets::SocketClient::SocketClient
SocketClient(const std::string &socket_file)
Creates socket connection precursor information.
discord_ipc_cpp::websockets::SocketClient::recv_data
std::optional< std::vector< char > > recv_data(int buffer_size, int timeout)
Receive data from socket on timeout.
discord_ipc_cpp::websockets::SocketClient::send_data
bool send_data(const std::vector< char > &data)
Sends data to socket.
discord_ipc_cpp::websockets::SocketClient::recv_data
std::optional< std::vector< char > > recv_data(int buffer_size)
Receive data from socket.
discord_ipc_cpp::websockets::SocketClient::close
bool close()
Attempts to close connection to socket file.
discord_ipc_cpp::websockets
Underlying websocket communications.
include
discord_ipc_cpp
socket_client.hpp
Generated by
1.18.0