datachannel

package
v1.9.1-0...-015e2d1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: MIT Imports: 6 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) {
})

The datachannels will be negotiated on peer join in the Subscriber peer connection.

Documentation

Index

Constants

This section is empty.

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