-
Notifications
You must be signed in to change notification settings - Fork 7
Channel
Channel is... TODO
Channels are conceptually close to resources. An identity -- the creator -- creates channels to exchange end-to-end encrypted messages with other identities.
As with resources each channel has a sharing group associated with it. A sharing group is a list of identities -- sharers -- that can use the channel. The sharing group is defined during the channel creation; sharers can extend it afterwards. Only sharers can use the channel for data encryption/decryption. The creator of a channel is not automatically included in the channel's sharing group.
When an identity sends a message via the channel, another identity can receive it by listening to new messages in the channel.
An identity creates a channel like this:
let aliceChannel = aliceSession.Channel.create([alice.login, bob.login])
The resource creator can determine the mode of messages encryption/decryption, see this for details.
The channel creator or a sharer can get the channel with the use of the channel's ID:
let aliceChannel = await bobSession.Channel.get(aliceChannelId)
Identities use channels to exchange end-to-end encrypted messages. The client does not need to manually encrypt messages before sending and decrypt them after receiving: the DataPeps' SDK does it transparently.
An identity sends a message like this:
let message = "??? TODO"
await aliceChannel.send(message)
To receive a message an identity gets the channel from DataPeps first. Then the identity starts listening to the channel by specifying a function to process incoming messages. When a message enters a channel, the identity consumes the message with the use of the processing function:
let messageProcessingFunction = (message => {
...
})
await aliceChannel.listen(messageProcessingFunction)