StreamnoteManager
import {Streamnote, StreamnoteManager} from "blocknote"
// Create a new Streamnote instance and save it into the store.
// Returns the UUID of the stored Streamnote instance & its payload_transaction_id
app.post('/create-new-stream', async (req, res) => {
const options = req.body?.options; // title, compression, encryption ...
options.onFinish = (result) => {
//Do something with the result when stream ends.
}
options.onError = (error) => {
//Do something when an error happened.
}
const sender_mnemonic = "gorilla shiver hood theory letter absorb arctic ...";
const stream = new Streamnote(sender_mnemonic, options);
const uuid = StreamnoteManager.store(stream);
const payload_transaction_id = await StreamnoteManager.getPayloadTransactionId(uuid);
res.send({uuid, payload_transaction_id});
});
// Send data on the given stream identified by the UUID.
app.post('/send/:uuid', (req, res) => {
const uuid = req.params.uuid;
const data = req.body.data;
StreamnoteManager.send(uuid, data);
res.send(true);
});
// Stop the stream identified by the UUID.
app.post('/stop/:uuid', (req, res) => {
const uuid = req.params.uuid;
StreamnoteManager.stop(uuid);
res.send(true);
});
// List all the stored Streamnote instance(s).
app.get('/list', async (req, res) => {
const list = await StreamnoteManager.list();
res.send(list);
});
Methods
store
Parameters
Name
Description
Type
Return
get
Parameters
Name
Description
Type
Return
send
Parameters
Name
Description
Type
Return
stop
Parameters
Name
Description
Type
Return
Last updated