Skip to content

Commit

Permalink
change pubnub library to handle secret key
Browse files Browse the repository at this point in the history
  • Loading branch information
ajithnn committed Jan 21, 2020
1 parent 74ed8b8 commit ea88afa
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions protocols/sub/pubnub.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var pubnubmap = map[string]string{
"topic": "Topic",
"subscribe_key": "SubscribeKey",
"publish_key": "PublishKey",
"secret_key": "SecretKey",
"persistence": "Persistence",
}

Expand All @@ -35,6 +36,7 @@ type pubnubConfig struct {
Topic string
SubscribeKey string
PublishKey string
SecretKey string
Persistence bool
FileName string
}
Expand All @@ -43,6 +45,7 @@ func (c pubnubConfig) GetKeys() []string {
return []string{
"name",
"topic",
"secret_key",
"subscribe_key",
"publish_key",
"persistence",
Expand Down Expand Up @@ -205,6 +208,9 @@ func pubnubConnect(cfg pubnubConfig) (jmsg.RawPubnubClient, error) {
config := pubnub.NewConfig()
config.SubscribeKey = cfg.SubscribeKey
config.PublishKey = cfg.PublishKey
if cfg.SecretKey != "" {
config.SecretKey = cfg.SecretKey
}

return jmsg.PubnubRawClient{Client: pubnub.NewPubNub(config), Listener: pubnub.NewListener()}, nil
}

0 comments on commit ea88afa

Please sign in to comment.