wrtcchat

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter provides a chat service

func NewAdapter

func NewAdapter(
	signaler string,
	key string,
	ice []string,
	config *AdapterConfig,
	ctx context.Context,
) *Adapter

NewAdapter creates the adapter

func (*Adapter) Close

func (a *Adapter) Close() error

Close disconnects the adapter from the signaler

func (*Adapter) Open

func (a *Adapter) Open() error

Open connects the adapter to the signaler

func (*Adapter) SendMessage

func (a *Adapter) SendMessage(body []byte)

SendMessage sends a message to all peers

func (*Adapter) Wait

func (a *Adapter) Wait() error

Wait starts the transmission loop

type AdapterConfig

type AdapterConfig struct {
	*wrtcconn.NamedAdapterConfig
	OnSignalerConnect  func(string)                          // Handler to be called when the adapter has connected to the signaler
	OnPeerConnect      func(peerID string, channelID string) // Handler to be called when the adapter has connected to a peer
	OnPeerDisconnected func(peerID string, channelID string) // Handler to be called when the adapter has disconnected from a peer
	OnMessage          func(Message)                         // Handler to be called when the adapter has received a message
	Channels           []string                              // Channels to join
}

AdapterConfig configures the adapter

type Message

type Message struct {
	PeerID    string // ID of the peer that sent the message
	ChannelID string // Channel to which the message has been sent
	Body      []byte // Content of the message
}

Message is a chat message

Jump to

Keyboard shortcuts

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