events

package
v0.0.0-...-5156b21 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSubscription

func NewSubscription() (Publisher, Subscriber)

NewSubscription creates a new event subscription.

Types

type Event

type Event interface {
	// MarshalToProtobuf maps events into API protobuf events.
	MarshalToProtobuf() *apigen.Event
}

Event represents a node event.

type NewMessage

type NewMessage struct {
	Message  entities.Message
	RoomName string
}

NewMessage occurs when a new message is received from a subscribed room (pubsub topic).

func (*NewMessage) MarshalToProtobuf

func (e *NewMessage) MarshalToProtobuf() *apigen.Event

type PeerJoined

type PeerJoined struct {
	PeerID   peer.ID
	RoomName string
}

PeerJoined occurs when a peer joins a room that we are subscribed to.

func (*PeerJoined) MarshalToProtobuf

func (e *PeerJoined) MarshalToProtobuf() *apigen.Event

type PeerLeft

type PeerLeft struct {
	PeerID   peer.ID
	RoomName string
}

PeerLeft occurs when a peer lefts a room that we are subscribed to.

func (*PeerLeft) MarshalToProtobuf

func (e *PeerLeft) MarshalToProtobuf() *apigen.Event

type Publisher

type Publisher interface {
	// Publish blocks until it is able to send the event through.
	Publish(Event) error

	// Closed checks whether the publisher is closed.
	Closed() bool
}

Publisher defines the event subscription sender interface.

type Subscriber

type Subscriber interface {
	// Next blocks until an event is received through the subscriber.
	Next() (Event, error)

	// Close closes the subscriber so it stops receiving new events.
	Close()
}

Subscriber defines the event subscription receiver interface.

Jump to

Keyboard shortcuts

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