The stream verb : @ protocol

Subscribe to our newsletter and never miss any upcoming articles

Listen to this article


The stream verb in the @platform is used to send and receive files between two @ signs. A secure socket is created between the sender and receiver @ sign in order to transfer a file. Once the file transfer is complete, the stream verb makes use of the notification verb to inform the sender when the file transfer is done.


1. Sample Stream Sender:

await AtClientImpl.createClient(
   '@alice', '@mosphere', preference);
var atClient = await AtClientImpl.getClient('@alice');
var streamResult =
   await'@bob', 'sample_image.jpg');

2. Sample Stream Receiver:

The receiver app or client makes use of the monitor verb in order to receive file transfer notifications. The receiver accepts the stream transfer by sending an ack back to the sender.

2.1 Initiate receiver with monitor:

await AtClientImpl.createClient(
   '@bob', '@mosphere', preference);
var atClient = await AtClientImpl.getClient('@bob’);
await atClient.startMonitor(preference.privateKey, _notificationCallBack)

2.2 Implement the callback to send ack to receiver:

Future<void> _notificationCallBack(var notification) async {
 response = notification.replaceFirst('notification:', '');
 var responseJson = jsonDecode(response);
 var notificationKey = responseJson['key'];
 var senderAtSign = responseJson['from'];
 var atKey = notificationKey.split(':')[1];
 atKey = atKey.replaceFirst(senderAtSign, '').trim();
 if (atKey == 'stream_id') {
   var valueObject = responseJson['value'];
   var streamId = valueObject.split(':')[0];
   var fileName = valueObject.split(':')[1];
   var fileLength = int.parse(valueObject.split(':')[2]);
   fileName = utf8.decode(base64.decode(fileName));     
   print('user accepted transfer.Sending ack back');
   await atClient.sendStreamAck(streamId, fileName, fileLength, fromAtSign,
         _streamCompletionCallBack, _streamReceiveCallBack);

void _streamReceiveCallBack(var bytesReceived) {
 print('Receive callback bytes received: ${bytesReceived}');

void _streamCompletionCallBack(var streamId) {
 print('Transfer done for stream: ${streamId}');

Refer to the StreamVerbHandler to learn more.

Coming Soon

In the future, we will implement a store and forward approach to transfer files when the stream receiver is offline. We are changing the Internet for good. Join us on

and code with us.

No Comments Yet