able to detect disconnected subscribers

This commit is contained in:
Chris Lu
2020-05-16 08:57:29 -07:00
parent 7aafb9e3f8
commit b0de01ff3b
3 changed files with 40 additions and 25 deletions

View File

@@ -27,7 +27,7 @@ func (mc *MessagingClient) NewSubChannel(subscriberId, chanName string) (*SubCha
if err != nil {
return nil, err
}
sc, err := setupSubscriberClient(grpcConnection, subscriberId, "chan", chanName, 0, time.Unix(0, 0))
sc, err := setupSubscriberClient(grpcConnection, tp, subscriberId, time.Unix(0, 0))
if err != nil {
return nil, err
}
@@ -48,6 +48,10 @@ func (mc *MessagingClient) NewSubChannel(subscriberId, chanName string) (*SubCha
log.Printf("fail to receive from netchan %s: %v", chanName, subErr)
return
}
if resp.Data == nil {
// this could be heartbeat from broker
continue
}
if resp.Data.IsClose {
t.stream.Send(&messaging_pb.SubscriberMessage{
IsClose: true,