Streaming

Functions

Public API reference for the Streaming extension

Extension Entry Points

FunctionDescription
NewExtension(opts ...ConfigOption) forge.ExtensionCreate the streaming extension with functional options
NewExtensionWithConfig(config Config) forge.ExtensionCreate the streaming extension with a complete config
DefaultConfig() ConfigReturns the default configuration

DI Helpers

FunctionDescription
GetManager(c forge.Container) (Manager, error)Resolve the streaming Manager from the container
MustGetManager(c forge.Container) ManagerSame but panics on error
GetManagerFromApp(app forge.App) (Manager, error)Resolve from an app instance
MustGetManagerFromApp(app forge.App) ManagerSame but panics on error

Route Registration

MethodDescription
RegisterRoutes(router, wsPath, ssePath) errorMount WebSocket and SSE endpoints on the Forge router

Connection

FunctionDescription
NewConnection(conn forge.Connection) ConnectionWrap a Forge connection with enhanced tracking (rooms, channels, metadata)

Manager Interface (key methods)

Room Operations

MethodDescription
CreateRoom(ctx, options) (Room, error)Create a new room
GetRoom(ctx, roomID) (Room, error)Get a room by ID
DeleteRoom(ctx, roomID) errorDelete a room
JoinRoom(ctx, roomID, conn, opts) errorJoin a connection to a room
LeaveRoom(ctx, roomID, conn) errorRemove a connection from a room
BroadcastToRoom(ctx, roomID, message) errorSend a message to all room members

Channel Operations

MethodDescription
CreateChannel(ctx, channelID) errorCreate a named channel
DeleteChannel(ctx, channelID) errorDelete a channel
Subscribe(ctx, channelID, conn) errorSubscribe a connection to a channel
Unsubscribe(ctx, channelID, conn) errorRemove a subscription
BroadcastToChannel(ctx, channelID, message) errorPublish to all channel subscribers

Presence

MethodDescription
UpdatePresence(ctx, userID, presence) errorUpdate a user's presence status
GetPresence(ctx, userID) (*UserPresence, error)Get a user's current presence
GetOnlineUsers(ctx, filters) ([]UserPresence, error)Query online users

Typing

MethodDescription
SetTyping(ctx, roomID, userID, typing) errorSet typing status
GetTypingUsers(ctx, roomID) ([]string, error)Get users currently typing in a room

Stats

MethodDescription
GetStats() ManagerStatsGet overall manager statistics
GetRoomStats(roomID) (*RoomStats, error)Get stats for a specific room

How is this guide?

On this page