-
<static> ab2str(ab) → {string}
-
Convert an array buffer in UTF8 to string
Parameters:
Name |
Type |
Description |
ab |
ArrayBuffer
|
array buffer to be converted |
- Source:
Returns:
s - converted string
-
Type
-
string
-
<static> addReadyCallback(c, onError)
-
Add a callback to be called when Quiet is ready for use, e.g. when transmitters and receivers can be created.
Parameters:
Name |
Type |
Argument |
Description |
c |
function
|
|
The user function which will be called |
onError |
onError
|
<optional>
|
User errback function |
- Source:
Example
addReadyCallback(function() { console.log("ready!"); });
-
<static> mergeab(ab1, ab2) → {ArrayBuffer}
-
Merge 2 ArrayBuffers
This is a convenience function to assist user receiver functions that
want to aggregate multiple payloads.
Parameters:
Name |
Type |
Description |
ab1 |
ArrayBuffer
|
beginning ArrayBuffer |
ab2 |
ArrayBuffer
|
ending ArrayBuffer |
- Source:
Returns:
buf - ab1 merged with ab2
-
Type
-
ArrayBuffer
-
<static> receiver(profile, onReceive, onCreateFail, onReceiveFail)
-
Create a new receiver with the profile specified by profile (should match profile of transmitter).
Parameters:
Name |
Type |
Argument |
Description |
profile |
string
|
|
name of profile to use, must be a key in quiet-profiles.json |
onReceive |
onReceive
|
|
callback which receiver will call to send user received data |
onCreateFail |
onReceiverCreateFail
|
<optional>
|
callback to notify user that receiver could not be created |
onReceiveFail |
onReceiveFail
|
<optional>
|
callback to notify user that receiver received corrupted data |
- Source:
Example
receiver("robust", function(payload) { console.log("received chunk of data: " + Quiet.ab2str(payload)); });
-
<static> setLibfecPrefix(prefix)
-
Set the path prefix of libfec.js.
Although not strictly required, it is highly recommended to include this library.
This function, if used, must be called before quiet-emscripten.js has started loading.
If it is not called first, then emscripten will not load libfec.js.
Parameters:
Name |
Type |
Description |
prefix |
string
|
The path prefix where emscripten will fetch libfec.js |
- Source:
Example
setLibfecPrefix("/"); // fetches /libfec.js
-
<static> setMemoryInitializerPrefix(prefix)
-
Set the path prefix of quiet-emscripten.js.mem.
This file is used to initialize the memory state of emscripten.
This function must be called before quiet-emscripten.js has started loading.
If it is not called first, then emscripten will default to a prefix of "".
Parameters:
Name |
Type |
Description |
prefix |
string
|
The path prefix where emscripten will fetch quiet-emscripten.js.mem |
- Source:
Example
setMemoryInitializerPrefix("/"); // fetches /quiet-emscripten.js.mem
-
<static> setProfilesPrefix(prefix)
-
Set the path prefix of quiet-profiles.json and do an async fetch of that path.
This file is used to configure transmitter and receiver parameters.
This function must be called before creating a transmitter or receiver.
Parameters:
Name |
Type |
Description |
prefix |
string
|
The path prefix where Quiet will fetch quiet-profiles.json |
- Source:
Example
setProfilesPrefix("/js/"); // fetches /js/quiet-profiles.json
-
<static> str2ab(s) → {ArrayBuffer}
-
Convert a string to array buffer in UTF8
Parameters:
Name |
Type |
Description |
s |
string
|
string to be converted |
- Source:
Returns:
buf - converted arraybuffer
-
Type
-
ArrayBuffer
-
<static> transmitter(profile) → {transmit}
-
Create a new transmitter configured by the given profile name.
Parameters:
Name |
Type |
Description |
profile |
string
|
name of profile to use, must be a key in quiet-profiles.json |
- Source:
Returns:
transmit - transmit callback which user calls to start transmission
-
Type
-
transmit
Example
var transmit = transmitter("robust");
transmit(Quiet.str2ab("Hello, World!"), function() { console.log("transmission complete"); });