sse

package
v1.2.26 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSSEHandler

func NewSSEHandler(clientManager *ClientManager) http.HandlerFunc

NewSSEHandler handles the SSE connection

Types

type Client

type Client struct {
	ID   uint32
	Send chan []byte
}

Client is a client of the SSE server

func NewClient

func NewClient(id uint32) *Client

NewClient creates a new client

func (*Client) Close added in v1.2.15

func (c *Client) Close()

Close closes the client

func (*Client) SendMessage

func (c *Client) SendMessage(message string) (err error)

SendMessage sends a message to the client

func (*Client) WriteSSE

func (c *Client) WriteSSE(w http.ResponseWriter)

WriteSSE writes data to the client

type ClientManager

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

ClientManager is a manager of the S

func NewClientManager

func NewClientManager() *ClientManager

NewClientManager creates a new client manager

func (*ClientManager) AddClient

func (cm *ClientManager) AddClient(client *Client)

AddClient adds a client to the manager

func (*ClientManager) Close

func (cm *ClientManager) Close()

Close closes the client

func (*ClientManager) GetClient

func (cm *ClientManager) GetClient(id uint32) (*Client, bool)

GetClient returns a client by id

func (*ClientManager) RemoveClient

func (cm *ClientManager) RemoveClient(id uint32)

RemoveClient removes a client from the manager

Jump to

Keyboard shortcuts

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