datachannel

package
v1.10.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2021 License: MIT Imports: 7 Imported by: 0

README

Datachannels middlewares

ion-sfu supports datachannels middlewares similar to the net/http standard library handlers.

API

Middleware

To create a datachannel middleware, just follow below pattern:

func SubscriberAPI(next sfu.MessageProcessor) sfu.MessageProcessor {
	return sfu.ProcessFunc(func(ctx context.Context, args sfu.ProcessArgs) {
              next.Process(ctx,args)
	}
}
Init middlewares

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

s := sfu.NewSFU(conf)
dc := s.NewDatachannel(sfu.APIChannelLabel)
dc.Use(datachannel.KeepAlive(5*time.Second), datachannel.SubscriberAPI)
// This callback is optional
dc.OnMessage(func(ctx context.Context, msg webrtc.DataChannelMessage, in *webrtc.DataChannel, out []*webrtc.DataChannel) {
})

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.

Documentation

Index

Constants

View Source
const (
	ActiveLayerMethod = "activeLayer"
)

Variables

This section is empty.

Functions

func KeepAlive

func KeepAlive(timeout time.Duration) func(next sfu.MessageProcessor) sfu.MessageProcessor

func SubscriberAPI

func SubscriberAPI(next sfu.MessageProcessor) sfu.MessageProcessor

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL