.. _api_javascript_client: ======================== JavaScript API Reference ======================== ---------- ---------- DimeClient ---------- .. code:: javascript new dime.DimeClient(hostname, port) Creates a new DiME instance and connects to the server. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | hostname | string | The hostname of the server | +------------------+--------------------------------+-------------------------------------------------------------------------+ | port | number | The port the server is running on. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | +-----------------------------------------------------------------------------------------------------+ | Returns | +================================+====================================================================+ | Type | Description | +--------------------------------+--------------------------------------------------------------------+ | DimeClient | The newly created DimeClient. | +--------------------------------+--------------------------------------------------------------------+ ----- close ----- .. code:: javascript DimeClient.close() Performs cleanup on the DimeClient connection. ---- join ---- .. code:: javascript DimeClient.join(varargin) Instructs the DiME server to add the client to the specified groups. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | varargin | string, string, ... | Strings containing the group names for the client to join. | +------------------+--------------------------------+-------------------------------------------------------------------------+ ----- leave ----- .. code:: javascript DimeClient.leave(varargin) Instructs the DiME server to remove the client from the specified groups. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | varargin | string, string, ... | Strings containing the group names for the client to leave. | +------------------+--------------------------------+-------------------------------------------------------------------------+ ---- send ---- .. code:: javascript DimeClient.send(name, varargin) Sends one or more variables to the specified group. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | name | string | The name of the group to send the variables to. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | varargin | string, string, ... | The names of the variables being sent. | +------------------+--------------------------------+-------------------------------------------------------------------------+ ------ send_r ------ .. code:: javascript DimeClient.send_r(name, kvpairs) Sends one or more variables to all clients in a specified group. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | name | string | The name of the group to send the variables to. | +------------------+--------------------------------+-------------------------------------------------------------------------+ | varargin | associative array | Key value pairs to be sent to the server. | +------------------+--------------------------------+-------------------------------------------------------------------------+ --------- broadcast --------- .. code:: javascript DimeClient.broadcast(varargin) Sends one or more variables to all other clients. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | varargin | string, string, ... | The names of the variables being sent. | +------------------+--------------------------------+-------------------------------------------------------------------------+ ----------- broadcast_r ----------- .. code:: javascript DimeClient.broadcast_r(kvpairs) Sends one or more key value pairs to all other clients. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | kvpairs | associative array | Key value pairs to be sent to the server. | +------------------+--------------------------------+-------------------------------------------------------------------------+ ---- sync ---- .. code:: javascript DimeClient.sync(n) Requests all variables that have been sent to this client by other clients. Sync will retrieve all variables if n is left unspecified or set to a negative value. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | n | number | The number of variables to retrieve from the server. | +------------------+--------------------------------+-------------------------------------------------------------------------+ ------ sync_r ------ .. code:: javascript DimeClient.sync_r(n) Requests all variables that have been sent to this client by other clients. Sync will retrieve all variables if n is left unspecified or set to a negative value. +-----------------------------------------------------------------------------------------------------------------------------+ | Parameters | +==================+================================+=========================================================================+ | Name | Type | Description | +------------------+--------------------------------+-------------------------------------------------------------------------+ | n | number | The number of variables to retrieve from the server. | +------------------+--------------------------------+-------------------------------------------------------------------------+ ---- wait ---- .. code:: javascript DimeClient.wait() Requests that the server sends a message to the client once a message has been received for said client. This call will block the current thread until the message is received. ------- devices ------- .. code:: javascript DimeClient.devices() Requests a list of all named, nonempty groups from the server. +-----------------------------------------------------------------------------------------------------+ | Returns | +================================+====================================================================+ | Type | Description | +--------------------------------+--------------------------------------------------------------------+ | string[] | An array containing names of all the groups connected to the | | | DiME server. | +--------------------------------+--------------------------------------------------------------------+