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 |
|
protected |
|
protected |
|
protectedpure virtual |
Virtual method for performing the connection, overridden by a subclass.
host | Full url with scheme, domain, optionally port, and path |
headers | HTTP header keys and values |
Implemented in BinaryNinja::CoreWebsocketClient.
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.
host | Full url with scheme, domain, optionally port, and path |
headers | HTTP header keys and values |
callbacks | Structure with callbacks for various websocket events |
|
staticprotected |
|
protectedvirtual |
Cleanup any resources created by the client.
|
staticprotected |
|
pure virtual |
Disconnect the websocket.
Implemented in BinaryNinja::CoreWebsocketClient.
|
staticprotected |
|
staticprotected |
|
protected |
|
pure virtual |
Write some data to the websocket.
data | Data to write |
Implemented in BinaryNinja::CoreWebsocketClient.
|
staticprotected |