Documentation
¶
Overview ¶
Package workflowpluginwebsocket provides the WebSocket workflow plugin.
Index ¶
- func NewWSServerHTTPHandler(m WSServerModule) http.Handler
- func NewWebSocketPlugin() sdk.PluginProvider
- func SetBroadcastHook(f func(room string, msg []byte) int)
- func SetSendHook(f func(connID string, msg []byte) bool)
- func StartCtx(ctx context.Context, m WSServerModule) error
- type Hub
- type WSServerHTTPHandler
- type WSServerModule
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewWSServerHTTPHandler ¶ added in v0.3.3
func NewWSServerHTTPHandler(m WSServerModule) http.Handler
NewWSServerHTTPHandler wraps a WSServerModule as a standard http.Handler.
func NewWebSocketPlugin ¶
func NewWebSocketPlugin() sdk.PluginProvider
NewWebSocketPlugin returns the WebSocket SDK plugin provider.
func SetBroadcastHook ¶ added in v0.5.0
SetBroadcastHook installs a hook that overrides the room-broadcast in step.ws_broadcast. The hook receives the room name and message bytes and returns the number of recipients. Pass nil to remove the hook.
func SetSendHook ¶ added in v0.5.0
SetSendHook installs a hook that overrides the text-frame direct send in step.ws_send. The hook receives the connection ID and message bytes and returns whether the send succeeded. Pass nil to remove the hook and restore default behaviour.
Types ¶
type Hub ¶
type Hub interface {
BroadcastToRoom(room string, msg []byte) int
// SendTo delivers a text frame directly to a connection by its ID.
SendTo(connID string, msg []byte) bool
// SendBinary delivers a binary frame directly to a connection by its ID.
SendBinary(connID string, msg []byte) bool
// BroadcastBinaryToRoom sends a binary frame to all connections in room.
BroadcastBinaryToRoom(room string, msg []byte) int
}
Hub is an exported interface for the WebSocket hub's broadcast capabilities. Satisfied by the internal hub after the ws.server module is initialized.
type WSServerHTTPHandler ¶ added in v0.3.3
type WSServerHTTPHandler struct {
// contains filtered or unexported fields
}
WSServerHTTPHandler is an http.Handler adapter for WSServerModule. It satisfies the workflow engine's module.HTTPHandler interface via module.NewHTTPHandlerAdapter.
func (*WSServerHTTPHandler) ServeHTTP ¶ added in v0.3.3
func (h *WSServerHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP delegates to the underlying WSServerModule.
type WSServerModule ¶ added in v0.3.3
type WSServerModule interface {
sdk.ModuleInstance
// ServeHTTP handles WebSocket upgrade requests.
ServeHTTP(w http.ResponseWriter, r *http.Request)
// HTTPPath returns the path this module listens on (e.g. "/ws").
HTTPPath() string
}
WSServerModule is the public interface for the ws.server module instance. It exposes the HTTP handler methods needed to register the WebSocket upgrade endpoint directly on the host engine's HTTP router.
func NewWSServerModule ¶ added in v0.3.3
func NewWSServerModule(name string, config map[string]any) (WSServerModule, error)
NewWSServerModule creates a ws.server module instance that can be registered directly on the host engine's HTTP router. This is the correct way to embed the WebSocket plugin in-process: HTTP upgrade requests cannot cross the gRPC boundary used by external plugins.