Browse Source

Renamed Hooks

160-regression
rcorniere 2 years ago
parent
commit
7850d07d37
2 changed files with 9 additions and 9 deletions
  1. +7
    -7
      client.go
  2. +2
    -2
      client_test.go

+ 7
- 7
client.go View File

@ -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
}


+ 2
- 2
client_test.go View File

@ -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{}{}
}()


Loading…
Cancel
Save