Skip to content

Commit

Permalink
Small tweak to middleware docs (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmcconnell authored Mar 9, 2021
1 parent c87e298 commit 44b912b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/middlewares/datachannel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func SubscriberAPI(next sfu.MessageProcessor) sfu.MessageProcessor {
### Init middlewares

To initialize the middlewares you need to declare them after sfu initialization:

```go
s := sfu.NewSFU(conf)
dc := s.NewDatachannel(sfu.APIChannelLabel)
Expand All @@ -27,4 +28,5 @@ dc.Use(datachannel.KeepAlive(5*time.Second), datachannel.SubscriberAPI)
dc.OnMessage(func(ctx context.Context, msg webrtc.DataChannelMessage, in *webrtc.DataChannel, out []*webrtc.DataChannel) {
})
```
The datachannels will be negotiated on peer join in the `Subscriber` peer connection.

Datachannels created in this way will be negotiated on peer join in the `Subscriber` peer connection. Clients can then get a reference to the channel by using the `ondatachannel` event handler.

0 comments on commit 44b912b

Please sign in to comment.