Skip to content

Commit

Permalink
Return channel in generate key (#34)
Browse files Browse the repository at this point in the history
As `keygen` can return a private channel next to its key, this channel should be returned by the API.
  • Loading branch information
goxiaoy authored Sep 15, 2024
1 parent 12ee0e0 commit 5ff9ad7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions v2/emitter.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,22 +359,22 @@ func (c *Client) Presence(key, channel string, status, changes bool) error {
}

// GenerateKey sends a key generation request to the broker
func (c *Client) GenerateKey(key, channel, permissions string, ttl int) (string, error) {
func (c *Client) GenerateKey(key, channel, permissions string, ttl int) (string, string, error) {
resp, err := c.request("keygen", &keygenRequest{
Key: key,
Channel: channel,
Type: permissions,
TTL: ttl,
})
if err != nil {
return "", err
return "", "", err
}

// Cast the response and return it
if result, ok := resp.(*keyGenResponse); ok {
return result.Key, nil
return result.Key, result.Channel, nil
}
return "", ErrUnmarshal
return "", "", ErrUnmarshal
}

// BlockKey sends a request to block a key.
Expand Down

0 comments on commit 5ff9ad7

Please sign in to comment.