-
Notifications
You must be signed in to change notification settings - Fork 28
Get Notifications
dez1337 edited this page Oct 7, 2017
·
3 revisions
A Steem Node provides a feature to notify you about every new block. This Wiki-Page describes how to setup those notifications in SteemJ.
The first thing you need is your own implementation of the BlockAppliedCallback class.
import eu.bittrade.libs.steemj.base.models.SignedBlockHeader;
import eu.bittrade.libs.steemj.communication.BlockAppliedCallback;
public class MyCustomCallback extends BlockAppliedCallback {
@Override
public void onNewBlock(SignedBlockHeader signedBlockHeader) {
System.out.println(signedBlockHeader.toString());
}
}
As you can see, extending the BlockAppliedCallback class forces you to implement the onNewBlock method. This method is automatically called by SteemJ if a notification is received from the Steem Node.
The last thing you need to do is to make the Steem Node and SteemJ aware of your implementation by passing it to the API.
MyCustomCallback myCallback = new MyCustomCallback();
steemJ.setBlockAppliedCallback(myCallback);
This project is developed by dez1337