Fawkes API
Fawkes Development Version
|
Proxy for the OpenPRS server communication. More...
#include "openprs_server_proxy.h"
Public Member Functions | |
OpenPRSServerProxy (unsigned short tcp_port, const std::string &server_host, unsigned short server_port, fawkes::Logger *logger) | |
Constructor. More... | |
virtual | ~OpenPRSServerProxy () |
Destructor. More... | |
void | transmit_command (const std::string &client_name, const std::string &command) |
Transmit a command to an OpenPRS kernel. More... | |
void | transmit_command_f (const std::string &client_name, const char *format,...) |
Transmit a command to an OpenPRS kernel. More... | |
void | transmit_command_v (const std::string &client_name, const char *format, va_list arg) |
Transmit a command to an OpenPRS kernel. More... | |
bool | has_kernel (const std::string &kernel_name) |
Check if a kernel connected to the proxy. More... | |
Static Public Member Functions | |
static int | read_int_from_socket (boost::asio::ip::tcp::socket &socket) |
Read an int from a given socket. More... | |
static std::string | read_string_from_socket (boost::asio::ip::tcp::socket &socket) |
Read a string from a given socket. More... | |
static void | write_int_to_socket (boost::asio::ip::tcp::socket &socket, int i) |
Write an int to a given socket. More... | |
static void | write_string_to_socket (boost::asio::ip::tcp::socket &socket, const std::string &str) |
Write a string to a given socket. More... | |
static void | write_string_newline_to_socket (boost::asio::ip::tcp::socket &socket, const std::string &str) |
Write a string followed by a newline character to a given socket. More... | |
Proxy for the OpenPRS server communication.
Using this proxy allows to inject commands into the communication between oprs-server and oprs (or xoprs).
Definition at line 41 of file openprs_server_proxy.h.
fawkes::OpenPRSServerProxy::OpenPRSServerProxy | ( | unsigned short | tcp_port, |
const std::string & | server_host, | ||
unsigned short | server_port, | ||
fawkes::Logger * | logger | ||
) |
Constructor.
tcp_port | port to listen on for incoming connections |
server_host | host of oprs-server to connect to |
server_port | TCP port that oprs-server listens on |
logger | logger for informational messages |
Definition at line 62 of file openprs_server_proxy.cpp.
|
virtual |
Destructor.
Definition at line 75 of file openprs_server_proxy.cpp.
bool fawkes::OpenPRSServerProxy::has_kernel | ( | const std::string & | kernel_name | ) |
Check if a kernel connected to the proxy.
kernel_name | name of the kernel to look for |
Definition at line 87 of file openprs_server_proxy.cpp.
Referenced by fawkes::OpenPRSAspectIniFin::init().
|
static |
Read an int from a given socket.
socket | socket to read from |
Definition at line 378 of file openprs_server_proxy.cpp.
Referenced by transmit_command_v().
|
static |
Read a string from a given socket.
socket | socket to read from |
Definition at line 395 of file openprs_server_proxy.cpp.
Referenced by transmit_command_v().
void fawkes::OpenPRSServerProxy::transmit_command | ( | const std::string & | recipient, |
const std::string & | command | ||
) |
Transmit a command to an OpenPRS kernel.
This works equivalent to the transmit oprs-server console command.
recipient | OpenPRS kernel name to send to |
command | command to send, cf. OpenPRS manual for valid commands |
Definition at line 115 of file openprs_server_proxy.cpp.
References fawkes::LockList< Type >::mutex().
Referenced by fawkes::OpenPRSComm::transmit_command().
void fawkes::OpenPRSServerProxy::transmit_command_f | ( | const std::string & | recipient, |
const char * | format, | ||
... | |||
) |
Transmit a command to an OpenPRS kernel.
This works equivalent to the transmit oprs-server console command. This function allows to pass a format according to the sprintf() format and its arguments.
recipient | OpenPRS kernel name to send to |
format | format string for the command, must be followed by the appropriate number and types of arguments. |
Definition at line 132 of file openprs_server_proxy.cpp.
References fawkes::LockList< Type >::mutex().
void fawkes::OpenPRSServerProxy::transmit_command_v | ( | const std::string & | recipient, |
const char * | format, | ||
va_list | arg | ||
) |
Transmit a command to an OpenPRS kernel.
This works equivalent to the transmit oprs-server console command. This function allows to pass a format according to the sprintf() format and its arguments. The arguments are read from the arg
list.
recipient | OpenPRS kernel name to send to |
format | format string for the command, must be followed by the appropriate number and types of arguments. |
arg | argument list for the string format |
Definition at line 161 of file openprs_server_proxy.cpp.
References fawkes::Logger::log_info(), fawkes::LockList< Type >::mutex(), read_int_from_socket(), read_string_from_socket(), write_int_to_socket(), write_string_newline_to_socket(), and write_string_to_socket().
Referenced by fawkes::OpenPRSComm::transmit_command_f().
|
static |
Write an int to a given socket.
socket | socket to write to |
i | value to write |
Definition at line 421 of file openprs_server_proxy.cpp.
Referenced by transmit_command_v().
|
static |
Write a string followed by a newline character to a given socket.
socket | socket to write to |
str | string value to write |
Definition at line 457 of file openprs_server_proxy.cpp.
Referenced by transmit_command_v().
|
static |
Write a string to a given socket.
socket | socket to write to |
str | string value to write |
Definition at line 436 of file openprs_server_proxy.cpp.
Referenced by transmit_command_v().