Handeling websocket disconnect
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user