You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+91-75Lines changed: 91 additions & 75 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,36 +12,38 @@ This is an npm-package and you can add it to your project by using npm with:
12
12
## Usage
13
13
Below you find a minimum usage example on how to use our message-library. First you need to import the required packages. Afterwards you can create a provider and a stream. With your created message-stream you can then send and fetch messages. Every message will be sent and fetched to and from the tangle, regardless of which provider you are using.
This packages contains some different classes that you need to know, to use it properly.
@@ -54,9 +56,11 @@ One importent component of this package are the providers. In this version there
54
56
55
57
You can use both of these providers to send and fetch messages through the tangle. If you'd like to create your own provider, you can simply create your own provider class by extending the class `provider`.
To create a working own provider, you can have a look into our provided providers that you can find in [./src/providers](./src/providers).
62
66
But normally the two providers mentioned above should work for you in most cases.
@@ -72,34 +76,38 @@ A Provider basically has four different methods, that you can use:
72
76
73
77
This is everything a provider does for you. And even better: in most use cases you do not even have to call this messages on your own, because the stream will do that for you. You only have to initialize the providers as follows:
The most important parameter that every provider has is the `fullnode-url` that you can set to any fullnode you have access to.
94
100
95
101
### Mode
96
102
A second small building block in this package is the `Mode` class. In MAM messaging there are three different modes for sending and receiving messages. This class simply represents the three different methods:
A stream is the core component of this package. A stream simply is a specified channel of MAM messages on the tangle. You can use a stream to publish and receive messages. There are two different types of streams:
@@ -111,39 +119,45 @@ Like the names suggest is the PublisherStream for sending **and** receiving mess
111
119
112
120
For a ListenerStream you only need the `provider` (fullnode api-url), one of the above `mode`s, the `root` of the stream and optionally a `sideKey` for:
provider, // your message provider that should be used for all actions made with this stream
118
-
root,
119
-
mode,
120
-
security,
121
-
sideKey
122
-
);
125
+
conststream=awaitStream.createListenerStream (
126
+
provider, // your message provider that should be used for all actions made with this stream
127
+
root,
128
+
mode,
129
+
security,
130
+
sideKey
131
+
);
132
+
```
123
133
124
134
To create a new PublisherStream you have to call the method `Stream.createPublisherStream` with you `provider` (fullnode api-url), your `seed` (will only stored locally on your device regardless of the provider!), the `mode` and optionally the `sideKey` for encrypting and decrypting messages.
provider, // your message provider that should be used for all actions made with this stream
130
-
seed,
131
-
mode,
132
-
security,
133
-
sideKey
134
-
);
139
+
conststream=awaitStream.createPublisherStream (
140
+
provider, // your message provider that should be used for all actions made with this stream
141
+
seed,
142
+
mode,
143
+
security,
144
+
sideKey
145
+
);
146
+
```
135
147
136
148
If you have already create a PublisherStream and you want to initialize the stream with an up to date state, you have to call the method `Stream.initializePublisherStream`. With this method you should use the same properties that you used previously with the above method.
provider, // your message provider that should be used for all actions made with this stream
155
+
seed,
156
+
mode,
157
+
security,
158
+
sideKey
159
+
);
160
+
```
147
161
148
162
All these three methods will create a `stream`-object for you, that you can now use for further actions:
149
163
@@ -160,16 +174,18 @@ The [mam.client.js](https://github.com/iotaledger/mam.client.js) from the iota f
160
174
### Messages
161
175
The last but not least component is the `Message` class. Each MAM message is represented by a own message object. You can create own messages like in the following example:
0 commit comments