title | keywords | last_updated | sidebar | permalink | folder |
---|---|---|---|---|---|
Receiving WebSocket Events |
sdk, web socket |
mydoc_sidebar |
/essentials/sdk/websocket |
essentials/sdk |
Realtime event triggering is trending in modern application development. It helps application to always be up to date and so provides better user experiences. Bitmark SDK offers Web Socket event triggering so that the application can be notified immediately when anything changes.
- New block: Sent when the Bitmark blockchain has a new block.
blockNumber
: new block number
- Bitmark changed: Sent when users issue new bitmarks, receive new bitmarks, or send them to a new owner.
bitmarkId
: the id of the bitmark that changedtxId
: the corresponding transaction idpresence
: whether the bitmark is owned or not by the correspondingAccount
- New transfer offer: Sent when users receive new transfer offers, for two-signatures transfer.
bitmarkId
: the id of the bitmark that's offered.
- New pending issuance: Sent when users issue new bitmarks.
bitmarkId
: the id of the bitmark that's issuing.
- New pending transfer: Sent when a transfer occurs, to both sender and receiver.
txId
: the transaction idowner
: the recipient of this transferprevTxId
: the previous transaction idprevOwner
: the sender who made the transfer
Note: The attribute names could be different depending on the SDK used. This document refers specifically to the Java SDK.
{% codetabs %} {% codetab Java %}
WebSocket.ConnectionEvent connEvent = new WebSocket.ConnectionEvent() {
@Override
public void onConnected() {
}
@Override
public void onDisconnected() {
}
@Override
public void onConnectionError(Throwable e) {
}
}
BitmarkWebSocket ws = new BitmarkWebSocketService();
// connect
ws.connect(authKeyPair);
// disconnect
ws.disconnect();
{% endcodetab %} {% codetab Swift %}
// TODO
{% endcodetab %} {% endcodetabs %}
{% codetabs %} {% codetab Java %}
// subscribe
ws.subscribeBitmarkChanged(
address,
new BitmarkWebSocket.BitmarkChangedEvent() {
@Override
public void onChanged(
String bitmarkId,
String txId,
boolean presence
) {
}
@Override
public void onSubscribeSuccess(SubscribeSuccessEvent event) {
}
@Override
public void onSubscribeError(SubscribeErrorEvent event) {
}
}
);
// unsubscribe
ws.unsubscribeBitmarkChanged(address);
{% endcodetab %} {% codetab Swift %}
// TODO
{% endcodetab %} {% endcodetabs %}