rooms

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 2 Imported by: 0

README

workflow-plugin-rooms

Room management plugin for the workflow framework. Extracted from workflow-plugin-websocket to provide a standalone, thread-safe room hub for connection grouping, broadcast, and membership queries.

Features

  • Join/leave named rooms by connection ID
  • Broadcast messages to a room with optional sender exclusion
  • Query room membership
  • Register/unregister connections with automatic room cleanup
  • Empty rooms are garbage-collected on leave/unregister

RoomHub Interface

type RoomHub interface {
    JoinRoom(room, connID string) bool
    LeaveRoom(room, connID string)
    LeaveAllRooms(connID string)
    BroadcastToRoom(room string, msg []byte, excludeConnID string) int
    GetMembers(room string) []string
    RegisterConnection(connID string)
    UnregisterConnection(connID string)
}

Pipeline Steps

Step Type Description Config Params
step.room_join Add connection to a room room, conn_id
step.room_leave Remove connection from a room room, conn_id
step.room_broadcast Send message to all room members room, message, exclude_conn_id
step.room_members Query connections in a room room

Module type: rooms.manager

Usage

import rooms "github.com/GoCodeAlone/workflow-plugin-rooms"

provider := rooms.NewRoomsPlugin()
// register with workflow engine

hub := rooms.GetHub() // after module init
hub.JoinRoom("lobby", connID)

Build & Test

go build ./...
go test ./...

Requires Go 1.26+ and github.com/GoCodeAlone/workflow v0.3.52.

License

MIT

Documentation

Overview

Package rooms provides the workflow-plugin-rooms SDK plugin. It manages connection rooms: join, leave, broadcast, and member queries.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRoomsPlugin

func NewRoomsPlugin() sdk.PluginProvider

NewRoomsPlugin returns the rooms SDK plugin provider.

Types

type RoomHub

type RoomHub = internal.RoomHub

RoomHub is the public interface for room management.

func GetHub

func GetHub() RoomHub

GetHub returns the global room hub once the rooms.manager module has initialized. Returns nil if the module has not started yet.

func NewHub

func NewHub() RoomHub

NewHub creates a standalone room hub (useful for testing or custom wiring).

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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