sse

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: MIT Imports: 5 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func (*Client) Chan

func (c *Client) Chan() chan Envelope

func (*Client) ID

func (c *Client) ID() string

type Envelope

type Envelope interface {
	String() string // Represent the envelope contents as a string for transmission.
}

Envelope defines the interface for content that can be broadcast to clients.

type History

type History interface {
	Add(message Envelope) // Add adds a message to the history.
	Send(c Listener)      // Send sends the history to a client.
}

type Listener

type Listener interface {
	ID() string
	Chan() chan Envelope
}

Listener defines the interface for the receiving end.

func NewClient

func NewClient(id string) Listener

type Manager

type Manager interface {
	Send(message Envelope)
	Handle(w http.ResponseWriter, r *http.Request, cl Listener)
	Clients() []string
}

Manager defines the interface for managing clients and broadcasting messages.

func NewManager

func NewManager(workerPoolSize int) Manager

NewManager initializes and returns a new Manager instance.

type Message

type Message struct {
	Event string
	Time  time.Time
	Data  string
}

Message represents a simple message implementation.

func NewMessage

func NewMessage(data string) *Message

NewMessage returns a new message instance.

func (*Message) String

func (m *Message) String() string

String returns the message as a string.

func (*Message) WithEvent

func (m *Message) WithEvent(event string) Envelope

WithEvent sets the event name for the message.

Jump to

Keyboard shortcuts

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