diff --git a/handler.go b/handler.go index 597630f1bfccae2ed91c37ddafa8655a1af2cf30..cb41d69a40863c8ffe09f6dabd1a25e30c4f8031 100644 --- a/handler.go +++ b/handler.go @@ -227,20 +227,24 @@ func (h *handler) handleCall(cp *callProc, msg *jsonrpcMessage) *jsonrpcMessage req := &Request{ctx: cp.ctx, msg: *msg, peer: h.peer} mw := NewReaderResponseWriterMsg(req) h.reg.ServeRPC(mw, req) - if mw.notifications != nil { - for { - val, more := <-mw.notifications - if !more { - break - } - err := h.conn.writeJSON(cp.ctx, val) - if err != nil { - if mw.notifications != nil { - close(mw.notifications) - } - return msg.errorResponse(err) - } - } - } + + //TODO: notifications + //if mw.notifications != nil { + // go func() { + // for { + // val, more := <-mw.notifications + // if !more { + // break + // } + // err := h.conn.writeJSON(cp.ctx, val) + // if err != nil { + // if mw.notifications != nil { + // close(mw.notifications) + // } + // log.Println("error in notification", err) + // } + // } + // }() + //} return mw.msg } diff --git a/protocol.go b/protocol.go index bc98700a13a083aa216aef7399d5c58b0c1df181..808023610350fae550837694fb6991f61b01f195 100644 --- a/protocol.go +++ b/protocol.go @@ -138,7 +138,10 @@ func (w *ResponseWriterMsg) Notify(args any) (err error) { cm := w.r.Msg() nf := cm.response(args) nf.ID = nil - w.notifications <- nf + select { + case w.notifications <- nf: + default: + } return nil }