Binary Ninja API C++: Websocket Provider
◆ BinaryNinja::WebsocketClient
class BinaryNinja::WebsocketClient
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. | |
| virtual bool | Write (const std::vector< uint8_t > &data)=0 |
| Write some data to the websocket. | |
| virtual bool | Disconnect ()=0 |
| Disconnect the websocket. | |
| Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNWebsocketClient, BNNewWebsocketClientReference, BNFreeWebsocketClient > | |
| CoreRefCountObject () | |
| virtual | ~CoreRefCountObject () |
| BNWebsocketClient * | GetObject () const |
| void | AddRef () |
| void | Release () |
| void | AddRefForRegistration () |
| void | ReleaseForRegistration () |
| void | AddRefForCallback () |
| void | ReleaseForCallback () |
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. | |
| 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. | |
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) |
◆ WebsocketClient() [1/2]
|
protected |
◆ WebsocketClient() [2/2]
◆ DestroyClientCallback()
|
staticprotected |
◆ ConnectCallback()
|
staticprotected |
◆ WriteCallback()
|
staticprotected |
◆ DisconnectCallback()
|
staticprotected |
◆ ErrorCallback()
|
staticprotected |
◆ ReadData()
|
protected |
◆ DestroyClient()
|
protectedvirtual |
Cleanup any resources created by the client.
◆ Connect() [1/2]
|
protectedpure virtual |
Virtual method for performing the connection, overridden by a subclass.
- Parameters
-
host Full url with scheme, domain, optionally port, and path headers HTTP 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
-
host Full url with scheme, domain, optionally port, and path headers HTTP header keys and values callbacks Structure with callbacks for various websocket events
- Returns
- True if the connection has started, but not necessarily if it succeeded
◆ Write()
|
pure virtual |
Write some data to the websocket.
- Parameters
- Returns
- True if successful
Implemented in BinaryNinja::CoreWebsocketClient.
◆ Disconnect()
|
pure virtual |
Disconnect the websocket.
- Returns
- True if successful
Implemented in BinaryNinja::CoreWebsocketClient.
◆ BinaryNinja::CoreWebsocketClient
class BinaryNinja::CoreWebsocketClient
Public Member Functions | |
| CoreWebsocketClient (BNWebsocketClient *instance) | |
| virtual | ~CoreWebsocketClient () |
| virtual bool | Connect (const std::string &host, const std::unordered_map< std::string, std::string > &headers) override |
| Virtual method for performing the connection, overridden by a subclass. | |
| virtual bool | Write (const std::vector< uint8_t > &data) override |
| Write some data to the websocket. | |
| virtual bool | Disconnect () override |
| Disconnect the websocket. | |
| Public Member Functions inherited from BinaryNinja::WebsocketClient | |
| bool | Connect (const std::string &host, const std::unordered_map< std::string, std::string > &headers, BNWebsocketClientOutputCallbacks *callbacks) |
| Connect to a given url, asynchronously. | |
| Public Member Functions inherited from BinaryNinja::CoreRefCountObject< BNWebsocketClient, BNNewWebsocketClientReference, BNFreeWebsocketClient > | |
| CoreRefCountObject () | |
| virtual | ~CoreRefCountObject () |
| BNWebsocketClient * | GetObject () const |
| void | AddRef () |
| void | Release () |
| void | AddRefForRegistration () |
| void | ReleaseForRegistration () |
| void | AddRefForCallback () |
| void | ReleaseForCallback () |
Additional Inherited Members | |
| Public Attributes inherited from BinaryNinja::CoreRefCountObject< BNWebsocketClient, BNNewWebsocketClientReference, BNFreeWebsocketClient > | |
| std::atomic< int > | m_refs |
| bool | m_registeredRef |
| BNWebsocketClient * | m_object |
| Protected Member Functions inherited from BinaryNinja::WebsocketClient | |
| WebsocketClient (WebsocketProvider *provider) | |
| WebsocketClient (BNWebsocketClient *instance) | |
| bool | ReadData (uint8_t *data, uint64_t len) |
| virtual void | DestroyClient () |
| Cleanup any resources created by the client. | |
| Static Protected Member Functions inherited from BinaryNinja::WebsocketClient | |
| 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) |
◆ CoreWebsocketClient()
◆ ~CoreWebsocketClient()
|
inlinevirtual |
◆ Connect()
|
overridevirtual |
Virtual method for performing the connection, overridden by a subclass.
- Parameters
-
host Full url with scheme, domain, optionally port, and path headers HTTP header keys and values
- Returns
- True if the connection has started, but not necessarily if it succeeded
Implements BinaryNinja::WebsocketClient.
◆ Write()
|
overridevirtual |
Write some data to the websocket.
- Parameters
- Returns
- True if successful
Implements BinaryNinja::WebsocketClient.
◆ Disconnect()
|
overridevirtual |
◆ BinaryNinja::WebsocketProvider
class BinaryNinja::WebsocketProvider