diff --git a/client.go b/client.go index 1be1f4d..446dcbe 100644 --- a/client.go +++ b/client.go @@ -139,10 +139,10 @@ type Client struct { ErrorHandler func(error) // Post connection hook. This will be executed on first connection - PostFirstConnHook func() error + PostConnectHook func() error // Post resume hook. This will be executed after the client resumes a lost connection using StreamManagement (XEP-0198) - PostReconnectHook func() error + PostResumeHook func() error } /* @@ -213,7 +213,7 @@ func NewClient(config *Config, r *Router, errorHandler func(error)) (c *Client, } // Connect establishes a first time connection to a XMPP server. -// It calls the PostFirstConnHook +// It calls the PostConnectHook func (c *Client) Connect() error { err := c.connect() if err != nil { @@ -223,8 +223,8 @@ func (c *Client) Connect() error { // Do we need an option to avoid that or do we rely on client to send the presence itself ? err = c.sendWithWriter(c.transport, []byte(InitialPresence)) // Execute the post first connection hook. Typically this holds "ask for roster" and this type of actions. - if c.PostFirstConnHook != nil { - err = c.PostFirstConnHook() + if c.PostConnectHook != nil { + err = c.PostConnectHook() if err != nil { return err } @@ -287,8 +287,8 @@ func (c *Client) Resume() error { } // Execute post reconnect hook. This can be different from the first connection hook, and not trigger roster retrival // for example. - if c.PostReconnectHook != nil { - err = c.PostReconnectHook() + if c.PostResumeHook != nil { + err = c.PostResumeHook() } return err } diff --git a/client_test.go b/client_test.go index 3cdd77a..4f30c0e 100644 --- a/client_test.go +++ b/client_test.go @@ -417,7 +417,7 @@ func Test_ClientPostConnectHook(t *testing.T) { } // The post connection client hook should just write to a channel that we will read later. - client.PostFirstConnHook = func() error { + client.PostConnectHook = func() error { go func() { hookChan <- struct{}{} }() @@ -486,7 +486,7 @@ func Test_ClientPostReconnectHook(t *testing.T) { t.Errorf("connect create XMPP client: %s", err) } - client.PostReconnectHook = func() error { + client.PostResumeHook = func() error { go func() { hookChan <- struct{}{} }()