MWSE/internal/services/bridge.go

22 lines
624 B
Go

package services
import (
"git.saqut.com/saqut/mwse/internal/bridge"
"git.saqut.com/saqut/mwse/internal/protocol"
"git.saqut.com/saqut/mwse/internal/ws"
)
// registerBridge wires the bridge/send handler that routes client messages into
// the application server's inbox (#46). The inbox is then drained by the
// application server via POST /api/bridge/inbox.
func registerBridge(hub *ws.Hub, inbox *bridge.Inbox) {
hub.Register("bridge/send", func(c *ws.Client, m protocol.Message) any {
pack := m.Get("pack")
if pack == nil {
return fail("PACK_REQUIRED")
}
inbox.Push(c.ID, pack)
return success()
})
}