BinaryNinja::WebsocketClient Class Referenceabstract

Public Member Functions

bool Connect (const std::string &host, const std::unordered_map< std::string, std::string > &headers, BNWebsocketClientOutputCallbacks *callbacks)
 Connect to a given url, asynchronously. More...
 
virtual bool Write (const std::vector< uint8_t > &data)=0
 Write some data to the websocket. More...
 
virtual bool Disconnect ()=0
 Disconnect the websocket. More...
 
- Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNWebsocketClient, BNNewWebsocketClientReference, BNFreeWebsocketClient >
 CoreRefCountObject ()
 
virtual ~CoreRefCountObject ()
 
BNWebsocketClient * GetObject () const
 
void AddRef ()
 
void Release ()
 
void AddRefForRegistration ()
 
void ReleaseForRegistration ()
 

Protected Member Functions

 WebsocketClient (WebsocketProvider *provider)
 
 WebsocketClient (BNWebsocketClient *instance)
 
bool ReadData (uint8_t *data, uint64_t len)
 
virtual void DestroyClient ()
 Cleanup any resources created by the client. More...
 
virtual bool Connect (const std::string &host, const std::unordered_map< std::string, std::string > &headers)=0
 Virtual method for performing the connection, overridden by a subclass. More...
 

Static Protected Member Functions

static void DestroyClientCallback (void *ctxt)
 
static bool ConnectCallback (void *ctxt, const char *host, uint64_t headerCount, const char *const *headerKeys, const char *const *headerValues)
 
static bool WriteCallback (const uint8_t *data, uint64_t len, void *ctxt)
 
static bool DisconnectCallback (void *ctxt)
 
static void ErrorCallback (const char *msg, void *ctxt)
 

Additional Inherited Members

- Static Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNWebsocketClient, BNNewWebsocketClientReference, BNFreeWebsocketClient >
static BNWebsocketClient * GetObject (CoreRefCountObject *obj)
 
- Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNWebsocketClient, BNNewWebsocketClientReference, BNFreeWebsocketClient >
std::atomic< int > m_refs
 
bool m_registeredRef
 
BNWebsocketClient * m_object
 

Constructor & Destructor Documentation

◆ WebsocketClient() [1/2]

WebsocketClient::WebsocketClient ( WebsocketProvider provider)
protected

◆ WebsocketClient() [2/2]

WebsocketClient::WebsocketClient ( BNWebsocketClient *  instance)
protected

Member Function Documentation

◆ Connect() [1/2]

virtual bool BinaryNinja::WebsocketClient::Connect ( const std::string &  host,
const std::unordered_map< std::string, std::string > &  headers 
)
protectedpure virtual

Virtual method for performing the connection, overridden by a subclass.

Parameters
hostFull url with scheme, domain, optionally port, and path
headersHTTP header keys and values
Returns
True if the connection has started, but not necessarily if it succeeded

Implemented in BinaryNinja::CoreWebsocketClient.

◆ Connect() [2/2]

bool WebsocketClient::Connect ( const std::string &  host,
const std::unordered_map< std::string, std::string > &  headers,
BNWebsocketClientOutputCallbacks callbacks 
)

Connect to a given url, asynchronously.

The connection will be run in a separate thread managed by the websocket provider.

Callbacks will be called on the thread of the connection, so be sure to ExecuteOnMainThread any long-running or gui operations in the callbacks.

If the connection succeeds, connectedCallback will be called. On normal termination, disconnectedCallback will be called. If the connection succeeds, but later fails, disconnectedCallback will not be called, and errorCallback will be called instead. If the connection fails, neither connectedCallback nor disconnectedCallback will be called, and errorCallback will be called instead.

If connectedCallback or readCallback return false, the connection will be aborted.

Parameters
hostFull url with scheme, domain, optionally port, and path
headersHTTP header keys and values
callbacksStructure with callbacks for various websocket events
Returns
True if the connection has started, but not necessarily if it succeeded

◆ ConnectCallback()

bool WebsocketClient::ConnectCallback ( void *  ctxt,
const char *  host,
uint64_t  headerCount,
const char *const *  headerKeys,
const char *const *  headerValues 
)
staticprotected

◆ DestroyClient()

void WebsocketClient::DestroyClient ( )
protectedvirtual

Cleanup any resources created by the client.

◆ DestroyClientCallback()

void WebsocketClient::DestroyClientCallback ( void *  ctxt)
staticprotected

◆ Disconnect()

virtual bool BinaryNinja::WebsocketClient::Disconnect ( )
pure virtual

Disconnect the websocket.

Returns
True if successful

Implemented in BinaryNinja::CoreWebsocketClient.

◆ DisconnectCallback()

bool WebsocketClient::DisconnectCallback ( void *  ctxt)
staticprotected

◆ ErrorCallback()

void WebsocketClient::ErrorCallback ( const char *  msg,
void *  ctxt 
)
staticprotected

◆ ReadData()

bool WebsocketClient::ReadData ( uint8_t *  data,
uint64_t  len 
)
protected

◆ Write()

virtual bool BinaryNinja::WebsocketClient::Write ( const std::vector< uint8_t > &  data)
pure virtual

Write some data to the websocket.

Parameters
dataData to write
Returns
True if successful

Implemented in BinaryNinja::CoreWebsocketClient.

◆ WriteCallback()

bool WebsocketClient::WriteCallback ( const uint8_t *  data,
uint64_t  len,
void *  ctxt 
)
staticprotected

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