Skip to content

Commit

Permalink
fix: 处理 redis sub 返回多个消息的情况
Browse files Browse the repository at this point in the history
  • Loading branch information
Mmx233 committed Sep 26, 2023
1 parent 057e149 commit da8aab5
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions internal/pkg/sshDev/server/rpc/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ func (a *SshAccounts) Watch(_ *emptypb.Empty, server proto.SshAccounts_WatchServ
return
}

var msgDecoded []SshAccountMsg
msgBytes := unsafe.Slice(unsafe.StringData(msg.Payload), len(msg.Payload))
err = json.Unmarshal(msgBytes, &msgDecoded)
msgChannel <- msgDecoded
if msg.PayloadSlice == nil && msg.Payload != "" {
msg.PayloadSlice = []string{msg.Payload}
} else {
continue
}

for _, payload := range msg.PayloadSlice {
var msgDecoded []SshAccountMsg
msgBytes := unsafe.Slice(unsafe.StringData(payload), len(payload))
err = json.Unmarshal(msgBytes, &msgDecoded)
msgChannel <- msgDecoded
}
}
}()

Expand Down

0 comments on commit da8aab5

Please sign in to comment.