KiCad PCB EDA Suite
Loading...
Searching...
No Matches
KICAD_API_CLIENT Class Reference

#include <api_client.h>

Public Member Functions

 KICAD_API_CLIENT (int aTimeoutMs=1000, bool aBlock=true)
 
 ~KICAD_API_CLIENT ()
 
bool Connect (const wxString &aSocketUrl)
 
void Disconnect ()
 
bool IsConnected () const
 
bool Send (const google::protobuf::Message &aRequest, kiapi::common::ApiResponse &aResponse, const std::string &aClientName="kicad")
 Send a protobuf request to the KiCad API server and wait for a response.
 
const wxString & GetLastError () const
 

Private Attributes

nng_socket m_socket
 
bool m_isOpen
 
bool m_isConnected
 
wxString m_lastError
 
bool m_block
 

Detailed Description

Definition at line 34 of file api_client.h.

Constructor & Destructor Documentation

◆ KICAD_API_CLIENT()

KICAD_API_CLIENT::KICAD_API_CLIENT ( int aTimeoutMs = 1000,
bool aBlock = true )
explicit

Definition at line 29 of file api_client.cpp.

References m_block, m_isConnected, m_isOpen, m_lastError, and m_socket.

◆ ~KICAD_API_CLIENT()

KICAD_API_CLIENT::~KICAD_API_CLIENT ( )

Definition at line 50 of file api_client.cpp.

References m_isOpen, and m_socket.

Member Function Documentation

◆ Connect()

bool KICAD_API_CLIENT::Connect ( const wxString & aSocketUrl)

Definition at line 57 of file api_client.cpp.

References m_isConnected, m_isOpen, m_lastError, and m_socket.

Referenced by CROSS_PROBE_CLIENT::AnnounceToPrimary(), and sendRequest().

◆ Disconnect()

void KICAD_API_CLIENT::Disconnect ( )

Definition at line 78 of file api_client.cpp.

References m_isConnected, m_isOpen, and m_socket.

◆ GetLastError()

const wxString & KICAD_API_CLIENT::GetLastError ( ) const
inline

Definition at line 56 of file api_client.h.

References m_lastError.

◆ IsConnected()

bool KICAD_API_CLIENT::IsConnected ( ) const
inline

Definition at line 43 of file api_client.h.

References m_isConnected, and m_isOpen.

Referenced by Send().

◆ Send()

bool KICAD_API_CLIENT::Send ( const google::protobuf::Message & aRequest,
kiapi::common::ApiResponse & aResponse,
const std::string & aClientName = "kicad" )

Send a protobuf request to the KiCad API server and wait for a response.

Parameters
aRequestis the command-specific protobuf message.
aResponsereceives the ApiResponse envelope.
aClientNameis an optional client identifier for the request header.
Returns
true if the request was sent and a valid ApiResponse was received.

Definition at line 98 of file api_client.cpp.

References IsConnected(), m_block, m_lastError, and m_socket.

Referenced by sendRequest().

Member Data Documentation

◆ m_block

bool KICAD_API_CLIENT::m_block
private

Definition at line 63 of file api_client.h.

Referenced by KICAD_API_CLIENT(), and Send().

◆ m_isConnected

bool KICAD_API_CLIENT::m_isConnected
private

Definition at line 61 of file api_client.h.

Referenced by Connect(), Disconnect(), IsConnected(), and KICAD_API_CLIENT().

◆ m_isOpen

bool KICAD_API_CLIENT::m_isOpen
private

Definition at line 60 of file api_client.h.

Referenced by Connect(), Disconnect(), IsConnected(), KICAD_API_CLIENT(), and ~KICAD_API_CLIENT().

◆ m_lastError

wxString KICAD_API_CLIENT::m_lastError
private

Definition at line 62 of file api_client.h.

Referenced by Connect(), GetLastError(), KICAD_API_CLIENT(), and Send().

◆ m_socket

nng_socket KICAD_API_CLIENT::m_socket
private

Definition at line 59 of file api_client.h.

Referenced by Connect(), Disconnect(), KICAD_API_CLIENT(), Send(), and ~KICAD_API_CLIENT().


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