In this example we will show how to create Identities, Channels and how to subscribe to a channel, authorize a Subscriber and write data into a Channel.
Create json files
First create two files
identitiyB.json for creating these Identities with the CLI in the next step. Rename the
username field in
Create the Identities
is create-identity -i examples/identityA.json -o identityA.json
is create-identity -i examples/identityB.json -o identityB.json
Create a Channel
Next we will create a private Channel with a topic
logs and the source
device and save the created Channel in a file called
channelA.json. For public Channels add the option
-pC. For public Channels a subscriber is automatically authorized to the Channel but can't write into it. The user can read the history of this channel with the command
is create-channel -i identityA.json -t logs -s device -o channelA.json test-channel
Write to Channel
The creator of the Channel can directly write into it.
is write-channel -i identityA.json -p "hello world" -c channelA.json
Other users need to subscribe to a Channel first.
is subscribe-channel -i identityB.json -c channelA.json
The creator of the Channel authorizes a subscriber.
is authorize-subscription -i identityA.json -c channelA.json <Id of identityB>
Write Message as a Subscriber
After the authorization the subscriber can write into the Channel.
is write-channel -i identityB.json -p "Can you hear me?" -c channelA.json
The subscriber can read the Channel entries but only ones created after he/she was authorized to the Channel.
is read-channel -i identityB.json -c channelA.json
Read History of Channel
The user can also read the history of a Channel.
is read-channel-history -i identityB.json -c channelA.json -sK <preshared key of channelA>
Especially if the Channel is
public it is the only way for the subscriber to read from the Channel. For that add the option
-pC and remove the option for the preshared Key
is read-channel-history -i identityB.json -c channelA.json -pC
At any time the creator of a Channel can revoke the Subscription of other users.
is revoke-subscription -i identityA.json -c channelA.json -sI <Id of identityB>
We can also double check if the Subscription is revoked by simply trying to find it.
is find-subscription -i identityA.json -c channelA.json -sI <Id of identityB>
For one specific command
is <command> --help