Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
  • Loading branch information
vasco-santos and jacobheun committed Sep 23, 2019
1 parent 8639867 commit 21c2ebd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ new Connection({
- `<Map> conn.registry`
- `Array<Stream> conn.streams`
- `Promise<object> conn.newStream(Array<protocols>)`
- `<void> conn.removeStream(id)`
- `<Stream> conn.addStream(stream, protocol, metadata)`
- `Promise<> conn.close()`

Expand Down Expand Up @@ -159,13 +160,22 @@ The stream property contains the muxed stream, while the protocol contains the p

#### Add stream metadata

- `JavaScript` - `conn.addStream(stream, protocol, metadata)`
- `JavaScript` - `conn.addStream(stream, { protocol, ...metadata })`

Add a new stream to the connection registry.

`stream` is a muxed stream.
`protocol` is the string codec for the protocol used by the stream. Example: `/echo/1.0.0`
`metadata` is an object containing the stream metadata (such as its `tags`).
`metadata` is an object containing any additional, optional, stream metadata that you wish to track (such as its `tags`).

#### Remove a from the registry

- `JavaScript` - `conn.removeStream(id)`

Removes the stream with the given id from the connection registry.

`id` is the unique id of the stream for this connection.


#### Close connection

Expand Down
2 changes: 1 addition & 1 deletion src/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ class Connection {
* @param {object} metadata metadata of the stream
* @return {void}
*/
addStream (muxedStream, protocol, metadata = {}) {
addStream (muxedStream, { protocol, metadata = {} }) {
// Add metadata for the stream
this.registry.set(muxedStream.id, {
protocol,
Expand Down

0 comments on commit 21c2ebd

Please sign in to comment.