Skip to content

Commit 7850d07

Browse files
author
rcorniere
committed
Renamed Hooks
1 parent 477a2b1 commit 7850d07

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

client.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ type Client struct {
139139
ErrorHandler func(error)
140140

141141
// Post connection hook. This will be executed on first connection
142-
PostFirstConnHook func() error
142+
PostConnectHook func() error
143143

144144
// Post resume hook. This will be executed after the client resumes a lost connection using StreamManagement (XEP-0198)
145-
PostReconnectHook func() error
145+
PostResumeHook func() error
146146
}
147147

148148
/*
@@ -213,7 +213,7 @@ func NewClient(config *Config, r *Router, errorHandler func(error)) (c *Client,
213213
}
214214

215215
// Connect establishes a first time connection to a XMPP server.
216-
// It calls the PostFirstConnHook
216+
// It calls the PostConnectHook
217217
func (c *Client) Connect() error {
218218
err := c.connect()
219219
if err != nil {
@@ -223,8 +223,8 @@ func (c *Client) Connect() error {
223223
// Do we need an option to avoid that or do we rely on client to send the presence itself ?
224224
err = c.sendWithWriter(c.transport, []byte(InitialPresence))
225225
// Execute the post first connection hook. Typically this holds "ask for roster" and this type of actions.
226-
if c.PostFirstConnHook != nil {
227-
err = c.PostFirstConnHook()
226+
if c.PostConnectHook != nil {
227+
err = c.PostConnectHook()
228228
if err != nil {
229229
return err
230230
}
@@ -287,8 +287,8 @@ func (c *Client) Resume() error {
287287
}
288288
// Execute post reconnect hook. This can be different from the first connection hook, and not trigger roster retrival
289289
// for example.
290-
if c.PostReconnectHook != nil {
291-
err = c.PostReconnectHook()
290+
if c.PostResumeHook != nil {
291+
err = c.PostResumeHook()
292292
}
293293
return err
294294
}

client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func Test_ClientPostConnectHook(t *testing.T) {
417417
}
418418

419419
// The post connection client hook should just write to a channel that we will read later.
420-
client.PostFirstConnHook = func() error {
420+
client.PostConnectHook = func() error {
421421
go func() {
422422
hookChan <- struct{}{}
423423
}()
@@ -486,7 +486,7 @@ func Test_ClientPostReconnectHook(t *testing.T) {
486486
t.Errorf("connect create XMPP client: %s", err)
487487
}
488488

489-
client.PostReconnectHook = func() error {
489+
client.PostResumeHook = func() error {
490490
go func() {
491491
hookChan <- struct{}{}
492492
}()

0 commit comments

Comments
 (0)