-
Notifications
You must be signed in to change notification settings - Fork 6
IntroConnections
ASAP is a protocol designed for information routing in large scale loosely coupled especially ad-hoc networks. An ASAP peer is a protocol engine.
Application developers can use ASAP peers to send messages. Applications can subscribe to receive incoming messages. Messenge routing is as opaque to application developers as they want it to be.
ASAP is a routing protocol based stream based point-to-point connection. This can be
- layer 2 protocols e.g. based on Bluetooth, Wifi, LoRaWan etc.
- layer 4 protocols, namely TCP or protocols on top.
ASAP peers are not aware of specific protocols which makes ASAP based applications independent from the underlying infrastructure, the unique feature of the whole ASAP/Shark project.
This part of our documentation is not for application developers, though. It is for developers who actually deal with specific connections. Especially our ASAPAndroid project makes heavy use of tools and features described here.
Each peer has - in general two sides: one to application developers the other to network connection. Methods provided to the first are summarized in the ASAPPeer interface
Interface ASAPConnectionHandler describes a single method (in different variants) that can deal with a connection.
It is assumed that other parts of an application create connection and ask peers (more specific ASAPConnectionHandler) to run an handle that connection which finally leads to an ASAP session.
The minimal parameter set consists of a pair of Input- and Outputstream objects.
ASAPPeerFS peer = new ASAPPeerFS(owner, rootFolder, supportedFormats);
// focus on its role as connection handler
ASAPConnectionHandler connectionHandler = (ASAPConnectionHandler)peer;
// streams
InputStream is; // must be created somewhere
OutputStream os; // must be created somewhere
connectionHandler.handleConnection(is, os);This code sniplet does not reveal that much. A filesystem based peer is instantiated. It is used as communication handler. It would run an ASAP session of a given connection (represented by a stream pair) after calling handleConnection(is, os);.
This core project offers only rudimentary tools to create connections.
It offers a set of tools to deal single, multiple connection based applications, though. It offers also tool to deal with multiple protocol environments which are standard when it comes to applications running on mobile phones and often even in IoT scenarios.
Let's start with simple single connection based applications.