websocketprovider module

binaryninja.websocketprovider.WebsocketClient(...)

binaryninja.websocketprovider.WebsocketProvider([...])

class WebsocketClient(provider, handle=None)[source]

Bases: object

connect(url, headers=None, on_connected=<function nop>, on_disconnected=<function nop>, on_error=<function nop>, on_data=<function nop>)[source]

Connect to a given url, asynchronously. The connection will be run in a separate thread managed by the websocket provider. Client callbacks are set according to whichever on_ callback parameters you pass.

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

If the connection succeeds, on_connected will be called. On normal termination, on_disconnected will be called. If the connection succeeds, but later fails, on_disconnected will not be called, and on_error will be called instead. If the connection fails, neither on_connected nor on_disconnected will be called, and on_error will be called instead.

If on_connected or on_data return false, the connection will be aborted.

Parameters
  • url (str) – full url with scheme, domain, optionally port, and path

  • headers (dict) – dictionary of string header keys to string header values

  • on_connected (function() -> bool) – function to call when connection succeeds

  • on_disconnected (function() -> void) – function to call when connection is closed normally

  • on_error (function(str) -> void) – function to call when connection is closed with an error

  • on_data (function(bytes) -> bool) – function to call when data is read from the websocket

Returns

if the connection has started, but not necessarily if it succeeded

Return type

bool

disconnect()[source]

Disconnect the websocket

Returns

true if successful

Return type

bool

abstract perform_connect(host, headers)[source]
abstract perform_destroy_client()[source]
abstract perform_disconnect()[source]
abstract perform_write(data)[source]
write(data)[source]

Send some data to the websocket

Parameters

data (bytes) – data to write

Returns

true if successful

Return type

bool

class WebsocketProvider(handle=None)[source]

Bases: object

create_instance()[source]
register()[source]
instance_class = None
name = None
nop(*args, **kwargs)[source]
to_bytes(field)[source]