Help us shape the future of Go! Take the 2026 Go Developer Survey

realtime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OpContinuation = 0x0
	OpText         = 0x1
	OpBinary       = 0x2
	OpClose        = 0x8
	OpPing         = 0x9
	OpPong         = 0xA
)

Variables

View Source
var ErrClosed = errors.New("websocket closed")

Functions

This section is empty.

Types

type Conn

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

Conn represents a websocket connection.

func Upgrade

func Upgrade(ctx *bebo.Context, options WebSocketOptions) (*Conn, error)

Upgrade upgrades the request to a WebSocket connection.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the websocket connection.

func (*Conn) ReadMessage

func (c *Conn) ReadMessage() (int, []byte, error)

ReadMessage reads the next non-control frame.

func (*Conn) ReadText

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

ReadText reads the next text frame as a string.

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(opcode int, payload []byte) error

WriteMessage writes a websocket frame.

func (*Conn) WriteText

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

WriteText writes a text frame.

type SSE

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

SSE represents an active SSE stream.

func StartSSE

func StartSSE(ctx *bebo.Context, options SSEOptions) (*SSE, error)

StartSSE configures response headers and returns an SSE stream.

func (*SSE) Close

func (s *SSE) Close()

Close marks the SSE stream as closed.

func (*SSE) Send

func (s *SSE) Send(msg SSEMessage) error

Send writes an SSE message and flushes the response.

type SSEMessage

type SSEMessage struct {
	Event string
	ID    string
	Data  string
	Retry time.Duration
}

SSEMessage is an SSE payload.

type SSEOptions

type SSEOptions struct {
	Headers map[string]string
}

SSEOptions configures server-sent events.

type WebSocketOptions

type WebSocketOptions struct {
	MaxMessageSize int64
	ReadTimeout    time.Duration
	WriteTimeout   time.Duration
}

WebSocketOptions configures websocket behavior.

Jump to

Keyboard shortcuts

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