live

package
v0.44.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package to provide a server-side instance for SSE.

Index

Constants

This section is empty.

Variables

View Source
var Streamer = &sse.Server{

	Provider: &sse.Joe{

		ReplayProvider: &sse.ValidReplayProvider{
			TTL:        time.Minute * 5,
			GCInterval: time.Minute,
			AutoIDs:    true,
		},
	},

	OnSession: func(s *sse.Session) (sse.Subscription, bool) {

		topics := s.Req.URL.Query()["topic"]

		for _, topic := range topics {

			if topic != topicRandomNumbers && topic != topicMetrics {

			}
		}

		if len(topics) == 0 {

			topics = []string{topicRandomNumbers, topicMetrics}
		}

		return sse.Subscription{
			Client:      s,
			LastEventID: s.LastEventID,
			Topics:      append(topics, sse.DefaultTopic),
		}, true
	},
}

Core SSE server struct initialization, the server implements http.Handler interface.

Functions

func BroadcastMessage

func BroadcastMessage(data, eventName string)

BroadcastMessage is a wrapper function for a SSE message sending.

func Router

func Router() chi.Router

Types

This section is empty.

Jump to

Keyboard shortcuts

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