Handeling websocket disconnect

This commit is contained in:
2023-09-19 10:19:04 -05:00
parent 8f0db70487
commit 832e02f42f
6 changed files with 46 additions and 14 deletions

View File

@ -30,12 +30,16 @@ func NewSubscription(chanel string, unsub Unsubscriber, msgCh chan *message.Mess
func (s *Subscription) OnMessage(onMessage func(channel string, msg message.Data)) error {
var inMsg *message.Message
for inMsg = range s.msgCh {
if inMsg.GetError() != nil {
return inMsg.GetError()
go func() error {
for inMsg = range s.msgCh {
if inMsg.GetError() != nil {
return inMsg.GetError()
}
onMessage(inMsg.Channel, inMsg.Data)
}
onMessage(inMsg.Channel, inMsg.Data)
}
return nil
}()
return nil
}