realtime

package
v1.11.8 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package realtime provides Server-Sent Events and WebSocket handlers with bounded connection and message behavior. Applications own authorization, fan-out infrastructure, presence, replay, and connection accounting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamSSE

func StreamSSE(c *gpp.Context, eventChan <-chan any) error

StreamSSE streams events from a channel continuously using HTTP text/event-stream headers.

Types

type Conn

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

Conn wraps a WebSocket connection over a raw net.Conn socket.

func Upgrade

func Upgrade(c *gpp.Context) (*Conn, error)

Upgrade performs a WebSocket handshake (101 Switching Protocols) and returns a WebSocket Conn.

func (*Conn) Close

func (c *Conn) Close() error

Close terminates the WebSocket connection socket.

func (*Conn) ReadMessage

func (c *Conn) ReadMessage() (string, error)

ReadMessage reads a WebSocket text message frame.

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(message string) error

WriteMessage sends a WebSocket text message frame.

type SSEEvent

type SSEEvent struct {
	Event string `json:"event,omitempty"`
	Data  any    `json:"data"`
	ID    string `json:"id,omitempty"`
}

SSEEvent represents a single Server-Sent Event frame.

Jump to

Keyboard shortcuts

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