{"modulePath":"github.com/GoCodeAlone/workflow-plugin-websocket","version":"v0.5.6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package workflowpluginwebsocket\n\nPackage workflowpluginwebsocket provides the WebSocket workflow plugin.\n\n## Functions\n\n```go\nfunc NewWSServerHTTPHandler(m WSServerModule) http.Handler\n```\nNewWSServerHTTPHandler wraps a WSServerModule as a standard http.Handler.\n\n```go\nfunc NewWebSocketPlugin() sdk.PluginProvider\n```\nNewWebSocketPlugin returns the WebSocket SDK plugin provider.\n\n```go\nfunc SetBroadcastHook(f func(room string, msg []byte) int)\n```\nSetBroadcastHook 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.\n\n```go\nfunc SetSendHook(f func(connID string, msg []byte) bool)\n```\nSetSendHook 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.\n\n```go\nfunc StartCtx(ctx context.Context, m WSServerModule) error\n```\nStartCtx satisfies context-aware start (no-op wrapper).\n\n## Types\n\n```go\ntype Hub interface {\n\tBroadcastToRoom(room string, msg []byte) int\n\t// SendTo delivers a text frame directly to a connection by its ID.\n\tSendTo(connID string, msg []byte) bool\n\t// SendBinary delivers a binary frame directly to a connection by its ID.\n\tSendBinary(connID string, msg []byte) bool\n\t// BroadcastBinaryToRoom sends a binary frame to all connections in room.\n\tBroadcastBinaryToRoom(room string, msg []byte) int\n}\n```\nHub is an exported interface for the WebSocket hub's broadcast capabilities. Satisfied by the internal hub after the ws.server module is initialized.\n\n```go\nfunc GetHub() Hub\n```\nGetHub returns the global WebSocket hub once the ws.server module has been initialized. Returns nil if the module has not started yet.\n\n```go\ntype WSServerHTTPHandler struct {\n\t// contains filtered or unexported fields\n}\n```\nWSServerHTTPHandler is an http.Handler adapter for WSServerModule. It satisfies the workflow engine's module.HTTPHandler interface via module.NewHTTPHandlerAdapter.\n\n```go\nfunc (h *WSServerHTTPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)\n```\nServeHTTP delegates to the underlying WSServerModule.\n\n```go\ntype WSServerModule interface {\n\tsdk.ModuleInstance\n\t// ServeHTTP handles WebSocket upgrade requests.\n\tServeHTTP(w http.ResponseWriter, r *http.Request)\n\t// HTTPPath returns the path this module listens on (e.g. \"/ws\").\n\tHTTPPath() string\n}\n```\nWSServerModule 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.\n\n```go\nfunc NewWSServerModule(name string, config map[string]any) (WSServerModule, error)\n```\nNewWSServerModule 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.\n\n","path":"github.com/GoCodeAlone/workflow-plugin-websocket","name":"workflowpluginwebsocket","synopsis":"Package workflowpluginwebsocket provides the WebSocket workflow plugin.","isRedistributable":true}
