mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-28 13:22:02 -08:00
Fix connect()
to work with external component
This commit is contained in:
parent
ac5b066815
commit
ddb8c5a1eb
@ -113,22 +113,27 @@ func (sm *StreamManager) Stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StreamManager) connect() error {
|
func (sm *StreamManager) connect() error {
|
||||||
if sm.client != nil {
|
if sm.client == nil {
|
||||||
if c, ok := sm.client.(*Client); ok {
|
return errors.New("client is not set")
|
||||||
if c.CurrentState.getState() == StateDisconnected {
|
}
|
||||||
sm.Metrics = initMetrics()
|
|
||||||
err := c.Connect()
|
if c, ok := sm.client.(*Client); ok {
|
||||||
if err != nil {
|
if c.CurrentState.getState() != StateDisconnected {
|
||||||
return err
|
return errors.New("client is not disconnected")
|
||||||
}
|
|
||||||
if sm.PostConnect != nil {
|
|
||||||
sm.PostConnect(sm.client)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errors.New("client is not disconnected")
|
|
||||||
|
sm.Metrics = initMetrics()
|
||||||
|
|
||||||
|
if err := sm.client.Connect(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if sm.PostConnect != nil {
|
||||||
|
sm.PostConnect(sm.client)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// resume manages the reconnection loop and apply the define backoff to avoid overloading the server.
|
// resume manages the reconnection loop and apply the define backoff to avoid overloading the server.
|
||||||
|
Loading…
Reference in New Issue
Block a user