refactor: describe transport delivery features

This commit is contained in:
zarazaex69
2026-04-20 20:25:43 +03:00
parent d3b2cc4e67
commit 0e4dea928a
2 changed files with 21 additions and 0 deletions

View File

@@ -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,
}
}

View File

@@ -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.