-
Notifications
You must be signed in to change notification settings - Fork 0
LaunchComponent
Thomas Schwotzer edited this page Mar 21, 2023
·
2 revisions
The first method that is called on your component after starting a peer is onStart(ASAPPeer peer);
Your component get a reference of a running ASAP peer. The whole system is initialized at this moment. From that moment on, it is no longer different then programming a standalone ASAP app.
Following code is copied from our Shark PKI component implementation.
It is just an example.
@Override
public void onStart(ASAPPeer asapPeer) throws SharkException {
this.asapPeer = asapPeer;
try {
ASAPStorage asapStorage = asapPeer.getASAPStorage(ASAPCertificateStorage.PKI_APP_NAME);
CharSequence peerName = this.ownerName != null ? this.ownerName : asapPeer.getPeerID();
this.asapCertificateStorage =
new ASAPAbstractCertificateStore(asapStorage, asapPeer.getPeerID(), peerName);
if(this.asapKeyStore == null) {
this.asapKeyStore = new InMemoASAPKeyStore(asapPeer.getPeerID());
}
this.asapPKIStorage = new FullAsapPKIStorage(this.asapCertificateStorage, this.asapKeyStore);
// get notified about new peer in the neighbourhood
this.asapPeer.addASAPEnvironmentChangesListener(this);
} catch (IOException | ASAPException e) {
throw new SharkException(e);
}
}
Details are of less interest but the bigger picture.
Once we have access to a peer we have also access to its storage. In that case a ASAPStorage is accessed.
Our software can (and in most cases must) add itself as listener to incoming messages.
That's plain ASAP programming again.
- What's a hub
- hub information management
- connection management