good morning!!!!

Skip to content
Snippets Groups Projects
Verified Commit a57df833 authored by a's avatar a
Browse files

better

parent ba87d417
Branches
Tags
No related merge requests found
Pipeline #31380 passed
...@@ -2,6 +2,7 @@ package subscription ...@@ -2,6 +2,7 @@ package subscription
import ( import (
"context" "context"
"encoding/json"
"strings" "strings"
"sync" "sync"
...@@ -61,14 +62,16 @@ func (e *Engine) Middleware() func(jsonrpc.Handler) jsonrpc.Handler { ...@@ -61,14 +62,16 @@ func (e *Engine) Middleware() func(jsonrpc.Handler) jsonrpc.Handler {
h.ServeRPC(w, r) h.ServeRPC(w, r)
case strings.HasSuffix(r.Method, serviceMethodSeparator+unsubscribeMethodSuffix): case strings.HasSuffix(r.Method, serviceMethodSeparator+unsubscribeMethodSuffix):
// read the subscription id to close // read the subscription id to close
var subid SubID resp := []SubID{}
err := r.ParamArray(subid) err := json.Unmarshal(r.Params, &resp)
if err != nil { if err != nil {
w.Send(false, err) w.Send(false, err)
return return
} }
// close that sub // close subs
w.Send(e.closeSub(subid)) if len(resp) > 0 {
w.Send(e.closeSub(resp[0]))
}
default: default:
h.ServeRPC(w, r) h.ServeRPC(w, r)
} }
......
...@@ -71,25 +71,6 @@ func NewRequest(ctx context.Context, id *ID, method string, params any) (r *Requ ...@@ -71,25 +71,6 @@ func NewRequest(ctx context.Context, id *ID, method string, params any) (r *Requ
return NewRawRequest(ctx, id, method, raw), nil return NewRawRequest(ctx, id, method, raw), nil
} }
func (r *Request) ParamArray(a ...any) error {
var params []json.RawMessage
err := json.Unmarshal(r.Params, &params)
if err != nil {
return err
}
for idx, v := range params {
if len(v) > idx {
err := json.Unmarshal(v, &a[idx])
if err != nil {
return err
}
} else {
break
}
}
return nil
}
func (r *Request) Context() context.Context { func (r *Request) Context() context.Context {
return r.ctx return r.ctx
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment