Skip to content

Commit

Permalink
proxy data in subscribe result
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia committed Oct 8, 2021
1 parent 9d473ec commit fc07520
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions internal/proxy/subscribe_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func (h *SubscribeHandler) Handle(node *centrifuge.Node) SubscribeHandlerFunc {
position := chOpts.Position

var info []byte
var data []byte
if subscribeRep.Result != nil {
if subscribeRep.Result.B64Info != "" {
decodedInfo, err := base64.StdEncoding.DecodeString(subscribeRep.Result.B64Info)
Expand All @@ -100,6 +101,16 @@ func (h *SubscribeHandler) Handle(node *centrifuge.Node) SubscribeHandlerFunc {
} else {
info = subscribeRep.Result.Info
}
if subscribeRep.Result.B64Data != "" {
decodedData, err := base64.StdEncoding.DecodeString(subscribeRep.Result.B64Data)
if err != nil {
node.Log(centrifuge.NewLogEntry(centrifuge.LogLevelError, "error decoding base64 data", map[string]interface{}{"client": client.ID(), "error": err.Error()}))
return centrifuge.SubscribeReply{}, centrifuge.ErrorInternal
}
data = decodedData
} else {
data = subscribeRep.Result.Data
}

result := subscribeRep.Result

Expand All @@ -124,6 +135,7 @@ func (h *SubscribeHandler) Handle(node *centrifuge.Node) SubscribeHandlerFunc {
JoinLeave: joinLeave,
Recover: useRecover,
Position: position,
Data: data,
},
ClientSideRefresh: true,
}, nil
Expand Down

0 comments on commit fc07520

Please sign in to comment.