mirror of
https://github.com/openlibrecommunity/olcrtc.git
synced 2026-05-26 15:13:40 +00:00
refactor: describe transport delivery features
This commit is contained in:
@@ -9,6 +9,8 @@ import (
|
||||
"github.com/openlibrecommunity/olcrtc/internal/transport"
|
||||
)
|
||||
|
||||
const defaultMaxPayloadSize = 12 * 1024
|
||||
|
||||
type streamTransport struct {
|
||||
stream carrier.ByteStream
|
||||
}
|
||||
@@ -79,3 +81,13 @@ func (p *streamTransport) WatchConnection(ctx context.Context) {
|
||||
func (p *streamTransport) CanSend() bool {
|
||||
return p.stream.CanSend()
|
||||
}
|
||||
|
||||
// Features describes the current datachannel transport semantics.
|
||||
func (p *streamTransport) Features() transport.Features {
|
||||
return transport.Features{
|
||||
Reliable: true,
|
||||
Ordered: true,
|
||||
MessageOriented: true,
|
||||
MaxPayloadSize: defaultMaxPayloadSize,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,14 @@ var (
|
||||
ErrTransportNotFound = errors.New("transport not found")
|
||||
)
|
||||
|
||||
// Features describes the delivery semantics of a transport.
|
||||
type Features struct {
|
||||
Reliable bool
|
||||
Ordered bool
|
||||
MessageOriented bool
|
||||
MaxPayloadSize int
|
||||
}
|
||||
|
||||
// Transport defines a byte transport independent of the underlying carrier.
|
||||
type Transport interface {
|
||||
Connect(ctx context.Context) error
|
||||
@@ -21,6 +29,7 @@ type Transport interface {
|
||||
SetEndedCallback(cb func(string))
|
||||
WatchConnection(ctx context.Context)
|
||||
CanSend() bool
|
||||
Features() Features
|
||||
}
|
||||
|
||||
// Config holds common transport configuration.
|
||||
|
||||
Reference in New Issue
Block a user