Fawkes API  Fawkes Development Version
fawkes::OpenPRSServerProxy Class Reference

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...
 

Detailed Description

Proxy for the OpenPRS server communication.

Using this proxy allows to inject commands into the communication between oprs-server and oprs (or xoprs).

Author
Tim Niemueller

Definition at line 41 of file openprs_server_proxy.h.

Constructor & Destructor Documentation

◆ OpenPRSServerProxy()

fawkes::OpenPRSServerProxy::OpenPRSServerProxy ( unsigned short  tcp_port,
const std::string &  server_host,
unsigned short  server_port,
fawkes::Logger logger 
)

Constructor.

Parameters
tcp_portport to listen on for incoming connections
server_hosthost of oprs-server to connect to
server_portTCP port that oprs-server listens on
loggerlogger for informational messages

Definition at line 62 of file openprs_server_proxy.cpp.

◆ ~OpenPRSServerProxy()

fawkes::OpenPRSServerProxy::~OpenPRSServerProxy ( )
virtual

Destructor.

Definition at line 75 of file openprs_server_proxy.cpp.

Member Function Documentation

◆ has_kernel()

bool fawkes::OpenPRSServerProxy::has_kernel ( const std::string &  kernel_name)

Check if a kernel connected to the proxy.

Parameters
kernel_namename of the kernel to look for
Returns
true if the kernel connected, false otherwise

Definition at line 87 of file openprs_server_proxy.cpp.

Referenced by fawkes::OpenPRSAspectIniFin::init().

◆ read_int_from_socket()

int fawkes::OpenPRSServerProxy::read_int_from_socket ( boost::asio::ip::tcp::socket &  socket)
static

Read an int from a given socket.

Parameters
socketsocket to read from
Returns
read value

Definition at line 378 of file openprs_server_proxy.cpp.

Referenced by transmit_command_v().

◆ read_string_from_socket()

std::string fawkes::OpenPRSServerProxy::read_string_from_socket ( boost::asio::ip::tcp::socket &  socket)
static

Read a string from a given socket.

Parameters
socketsocket to read from
Returns
read value

Definition at line 395 of file openprs_server_proxy.cpp.

Referenced by transmit_command_v().

◆ transmit_command()

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.

Parameters
recipientOpenPRS kernel name to send to
commandcommand 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().

◆ transmit_command_f()

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.

Parameters
recipientOpenPRS kernel name to send to
formatformat 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().

◆ transmit_command_v()

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.

Parameters
recipientOpenPRS kernel name to send to
formatformat string for the command, must be followed by the appropriate number and types of arguments.
argargument 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().

◆ write_int_to_socket()

void fawkes::OpenPRSServerProxy::write_int_to_socket ( boost::asio::ip::tcp::socket &  socket,
int  i 
)
static

Write an int to a given socket.

Parameters
socketsocket to write to
ivalue to write

Definition at line 421 of file openprs_server_proxy.cpp.

Referenced by transmit_command_v().

◆ write_string_newline_to_socket()

void fawkes::OpenPRSServerProxy::write_string_newline_to_socket ( boost::asio::ip::tcp::socket &  socket,
const std::string &  str 
)
static

Write a string followed by a newline character to a given socket.

Parameters
socketsocket to write to
strstring value to write

Definition at line 457 of file openprs_server_proxy.cpp.

Referenced by transmit_command_v().

◆ write_string_to_socket()

void fawkes::OpenPRSServerProxy::write_string_to_socket ( boost::asio::ip::tcp::socket &  socket,
const std::string &  str 
)
static

Write a string to a given socket.

Parameters
socketsocket to write to
strstring value to write

Definition at line 436 of file openprs_server_proxy.cpp.

Referenced by transmit_command_v().


The documentation for this class was generated from the following files: