signaling

package
v0.4.8 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package signaling implements various signaling backends to exchange encrypted messages between peers

Index

Constants

This section is empty.

Variables

View Source
var (
	Backends = map[BackendType]*BackendPlugin{} //nolint:gochecknoglobals

	ErrInvalidBackend = errors.New("unknown backend type")
	ErrClosed         = errors.New("backend is closed")
)
View Source
var (
	ErrNotSubscribed = errors.New("missing subscription")
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	io.Closer

	// Publish a signaling message to a specific peer
	Publish(ctx context.Context, kp *crypto.KeyPair, msg *Message) error

	// Subscribe to messages send by a specific peer
	Subscribe(ctx context.Context, kp *crypto.KeyPair, h MessageHandler) (bool, error)

	// Unsubscribe from messages send by a specific peer
	Unsubscribe(ctx context.Context, kp *crypto.KeyPair, h MessageHandler) (bool, error)

	// Returns the backends type identifier
	Type() signalingproto.BackendType
}

func NewBackend

func NewBackend(cfg *BackendConfig) (Backend, error)

type BackendConfig

type BackendConfig struct {
	URI *url.URL

	OnReady []BackendReadyHandler
}

type BackendFactory

type BackendFactory func(*BackendConfig, *log.Logger) (Backend, error)

type BackendPlugin

type BackendPlugin struct {
	New         BackendFactory
	Description string
}

type BackendReadyHandler

type BackendReadyHandler interface {
	OnSignalingBackendReady(b Backend)
}

type BackendType

type BackendType string // URL schemes

type Envelope

type Envelope = signalingproto.Envelope

type EnvelopeHandler

type EnvelopeHandler interface {
	OnSignalingEnvelope(*Envelope)
}

type Message

type Message = signalingproto.Message

type MessageHandler

type MessageHandler interface {
	OnSignalingMessage(*crypto.PublicKeyPair, *Message)
}

type MultiBackend

type MultiBackend struct {
	Backends []Backend
}

func NewMultiBackend

func NewMultiBackend(uris []url.URL, cfg *BackendConfig) (*MultiBackend, error)

func (*MultiBackend) ByType

func (*MultiBackend) Close

func (mb *MultiBackend) Close() error

func (*MultiBackend) Publish

func (mb *MultiBackend) Publish(ctx context.Context, kp *crypto.KeyPair, msg *Message) error

func (*MultiBackend) Subscribe

func (mb *MultiBackend) Subscribe(ctx context.Context, kp *crypto.KeyPair, h MessageHandler) (bool, error)

func (*MultiBackend) Type

func (*MultiBackend) Unsubscribe

func (mb *MultiBackend) Unsubscribe(ctx context.Context, kp *crypto.KeyPair, h MessageHandler) (bool, error)

type Subscription

type Subscription struct {
	// contains filtered or unexported fields
}

func (*Subscription) AddMessageHandler

func (s *Subscription) AddMessageHandler(pk *crypto.Key, h MessageHandler)

func (*Subscription) NewMessage

func (s *Subscription) NewMessage(env *Envelope) error

func (*Subscription) RemoveMessageHandler

func (s *Subscription) RemoveMessageHandler(pk *crypto.Key, h MessageHandler)

type SubscriptionsRegistry

type SubscriptionsRegistry struct {
	// contains filtered or unexported fields
}

func NewSubscriptionsRegistry

func NewSubscriptionsRegistry() SubscriptionsRegistry

func (*SubscriptionsRegistry) GetOrCreateSubscription

func (s *SubscriptionsRegistry) GetOrCreateSubscription(sk *crypto.Key) (bool, *Subscription, error)

func (*SubscriptionsRegistry) GetSubscription

func (s *SubscriptionsRegistry) GetSubscription(pk *crypto.Key) (*Subscription, error)

func (*SubscriptionsRegistry) NewMessage

func (s *SubscriptionsRegistry) NewMessage(env *Envelope) error

func (*SubscriptionsRegistry) NewSubscription

func (s *SubscriptionsRegistry) NewSubscription(k *crypto.Key) (*Subscription, error)

func (*SubscriptionsRegistry) Subscribe

func (s *SubscriptionsRegistry) Subscribe(kp *crypto.KeyPair, h MessageHandler) (bool, error)

func (*SubscriptionsRegistry) Unsubscribe

func (s *SubscriptionsRegistry) Unsubscribe(kp *crypto.KeyPair, h MessageHandler) (bool, error)

Directories

Path Synopsis
Package grpc implements a signaling backend using a central gRPC service
Package grpc implements a signaling backend using a central gRPC service
Package inprocess implements an in-process signaling backend using Go channels
Package inprocess implements an in-process signaling backend using Go channels

Jump to

Keyboard shortcuts

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