From 5ff9ad77abb1c29b2e69ed7366b1b61c41f3f86d Mon Sep 17 00:00:00 2001 From: goxiaoy Date: Sun, 15 Sep 2024 20:43:56 +0800 Subject: [PATCH] Return channel in generate key (#34) As `keygen` can return a private channel next to its key, this channel should be returned by the API. --- v2/emitter.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/v2/emitter.go b/v2/emitter.go index 1e7f9c2..2d98cc0 100644 --- a/v2/emitter.go +++ b/v2/emitter.go @@ -359,7 +359,7 @@ 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, @@ -367,14 +367,14 @@ func (c *Client) GenerateKey(key, channel, permissions string, ttl int) (string, 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.