Handeling websocket disconnect

This commit is contained in:
watsonb8 committed 2023-09-19 16:16:34 -05:00
1 parent 8f0db70487
commit 832e02f42f
6 files changed
+46 -14

No files matched your search

+9 -5
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
}