sse

package
v0.0.0-...-f70499c Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PublishUsingBrokerInContext

func PublishUsingBrokerInContext(ctx context.Context, event Event) error

Types

type Broker

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

func NewBroker

func NewBroker(logger zerolog.Logger, chatService ChatService) *Broker

func (*Broker) Close

func (b *Broker) Close()

func (*Broker) Middleware

func (b *Broker) Middleware(next http.Handler) http.Handler

func (*Broker) Publish

func (b *Broker) Publish(e Event)

func (*Broker) ServeHTTPForChannel

func (b *Broker) ServeHTTPForChannel(w http.ResponseWriter, r *http.Request)

func (*Broker) ServeHTTPForChannelList

func (b *Broker) ServeHTTPForChannelList(w http.ResponseWriter, r *http.Request)

func (*Broker) SubscribeToChannel

func (b *Broker) SubscribeToChannel(channelUUID string) chan Event

func (*Broker) SubscribeToChannelListUpdates

func (b *Broker) SubscribeToChannelListUpdates(userUUID string) chan Event

func (*Broker) Unsubscribe

func (b *Broker) Unsubscribe(c chan Event)

type ChatService

type ChatService interface {
	IsMemberOfChannel(channelUUID, userUUID string) (bool, error)
	GetChannelList(user model.User) ([]model.Channel, error)
}

type Event

type Event struct {
	ID              string
	Type            string
	Message         model.Message
	Channel         model.Channel
	CurrentUserUUID string
}

func NewEvent

func NewEvent(t string, channel model.Channel, message model.Message, currentUserUUID string) Event

Jump to

Keyboard shortcuts

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