Verified Commit 010af261 authored by Aral Balkan's avatar Aral Balkan
Browse files

Update readme

parent 43446f77
......@@ -16,30 +16,30 @@ var mySwarm = discoverySwarm(swarmDefaults({
extensions: ['ephemeral']
})
// ...
return stream
return streams
}
}))
/**
* Step 2. Wire up each dat you create
*/
datEphemeralExtMsg.watchDat(archiveOrHypercore) // can give a hyperdrive or hypercore
// datEphemeralExtMsg.unwatchDat(archiveOrHypercore) when done
datEphemeralExtMsg.watchDat(database) // can pass a hypercore, hyperdb, or hyperdrive reference as the database
// datEphemeralExtMsg.unwatchDat(database) when done
/**
* Step 3. Listen to events
*/
datEphemeralExtMsg.on('message', (archiveOrHypercore, peer, {contentType, payload}) => {
// `peer` has sent `payload` of mimetype `contentType` for `archiveOrHypercore`
datEphemeralExtMsg.on('message', (database, peer, {contentType, payload}) => {
// `peer` has sent `payload` of mimetype `contentType` for `database`
})
datEphemeralExtMsg.on('received-bad-message', (err, archiveOrHypercore, peer, messageBuffer) => {
datEphemeralExtMsg.on('received-bad-message', (err, database, peer, messageBuffer) => {
// there was an error parsing a received message
})
/**
* Step 4. Use the API
*/
datEphemeralExtMsg.hasSupport(archiveOrHypercore, peerId)
datEphemeralExtMsg.broadcast(archiveOrHypercore, {contentType, payload})
datEphemeralExtMsg.send(archiveOrHypercore, peerId, {contentType, payload})
datEphemeralExtMsg.hasSupport(database, peerId)
datEphemeralExtMsg.broadcast(database, {contentType, payload})
datEphemeralExtMsg.send(database, peerId, {contentType, payload})
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment