fix process kill

fix unsubscribe error
This commit is contained in:
Marcelo Pires
2018-09-06 18:40:00 +02:00
parent db6b6c3848
commit e98ccfdec8
2 changed files with 26 additions and 24 deletions

View File

@ -89,8 +89,8 @@ func (w *Websocket) readWorker() error {
if !ok {
panic("BUG: subscription not registered `" + msg.Subscription + "`")
}
if msg.GetError() != nil {
//inject the error
if msg.GetError() == nil {
//inject the error if the server returns unsuccessful without error
msg.Error = fmt.Sprintf("susbscription `%s` failed", msg.Subscription)
}
subscription <- msg
@ -99,16 +99,7 @@ func (w *Websocket) readWorker() error {
delete(w.subs, msg.Channel)
w.subsMu.Unlock()
}
case transport.MetaUnsubscribe:
//handle MetaUnsubscribe resp
case transport.MetaConnect:
//handle MetaConnect resp
case transport.MetaDisconnect:
//handle MetaDisconnect resp
case transport.MetaHandshake:
//handle MetaHandshake resp
}
continue
@ -277,6 +268,10 @@ func (w *Websocket) Unsubscribe(subscription string) error {
delete(w.subs, subscription)
}
w.subsMu.Unlock()
//remove onPublishResponse handler
w.onPubResponseMu.Lock()
delete(w.onPublishResponse, subscription)
w.onPubResponseMu.Unlock()
return w.sendMessage(m)
}