The stream verb: atProtocol

Search for a command to run...

No comments yet. Be the first to comment.
For a long while we ran The atPlatform on Ubuntu Linux, but we found that doing stuff with nodes on a large Docker Swarm spiked CPU usage for cloud-init. Every start or stop of a container was a change to networking, and every change to networking ca...

In this step-by-step guide I will walk you through all steps required to setup your own private dess using AWS.

Do you wish to store and share objects on Flutter without worrying about databases, infrastructure and other annoyances? What would these objects look like and how would you make them? The atPlatform already has you covered! Let’s take a deep dive in...

On running tests that are expected to fail
GitHub recently launched a beta for their new project boards, which provide a lot more flexibility than the old Kanban boards. I've been excited about the new functionality ever since I heard of the 'Memex' project. With the new boards comes a new A...
The stream verb in the atPlatform is used to send and receive files between two atSigns. A secure socket is created between the sender and receiver atSign 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.
await AtClientImpl.createClient(
'@alice', '@mosphere', preference);
var atClient = await AtClientImpl.getClient('@alice');
var streamResult =
await atClient.stream('@bob', 'sample_image.jpg');
The receiver app or client makes use of the monitor verb to receive file transfer notifications. The receiver accepts the stream transfer by sending an ack back to the sender.
await AtClientImpl.createClient(
'@bob', '@mosphere', preference);
var atClient = await AtClientImpl.getClient('@bob’);
await atClient.startMonitor(preference.privateKey, _notificationCallBack)
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.
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.