diff --git a/pkg/blas/core/core.go b/pkg/blas/core/core.go index 5784368..d5ef63c 100644 --- a/pkg/blas/core/core.go +++ b/pkg/blas/core/core.go @@ -30,7 +30,7 @@ type WebSocketManager interface { // cmd is the first part, before first slash // dataNew is a function to create a new message datatype RegisterWSCommand(cmd string, hnd Handler, dataNew NewData) - WSCommandHandler(cmd string) (NewData, Handler, error) + WSCommandHandler(cmd string, splitCmd []string) (NewData, Handler, error) } type WebSocketSession interface { diff --git a/pkg/wsapi/api.go b/pkg/wsapi/api.go index 454f807..b4f0d8e 100644 --- a/pkg/wsapi/api.go +++ b/pkg/wsapi/api.go @@ -62,13 +62,16 @@ func (wsm *wsManager) RegisterWSCommand(cmd string, hnd core.Handler, dataNew co } } -func (wsm *wsManager) WSCommandHandler(cmd string) (core.NewData, core.Handler, error) { - wse, ok := wsm.r[cmd] - if !ok { - return nil, nil, NoSuchHandlerErr +func (wsm *wsManager) WSCommandHandler(cmd string, cmdSplit []string) (core.NewData, core.Handler, error) { + if wse, ok := wsm.r[cmd]; ok { + return wse.dataNew, wse.hnd, nil } - return wse.dataNew, wse.hnd, nil + if wse, ok := wsm.r[cmdSplit[0]]; ok { + return wse.dataNew, wse.hnd, nil + } + + return nil, nil, NoSuchHandlerErr } func NewManager() core.WebSocketManager { @@ -173,7 +176,7 @@ func (ws *cmdHandler) handleMsg(r io.Reader) error { cmd := strings.Split(msgType, "/") - newData, hand, err := ws.b.WSCommandHandler(cmd[0]) + newData, hand, err := ws.b.WSCommandHandler(cmd[0], cmd) switch err { case nil: case NoSuchHandlerErr: