mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2024-11-21 18:12:00 -08:00
Fix passing Component to StreamManager
0a4acd12c3
, which fixes #160, introduced
a regression as it assumed only Client may implement StreamClient, and
passing a component triggers an unconditional "client is not
disconnected" error.
This commit is contained in:
parent
5f99e1cd06
commit
e55463fc98
@ -114,18 +114,23 @@ 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 {
|
var scs *SyncConnState
|
||||||
if c.CurrentState.getState() == StateDisconnected {
|
if client, ok := sm.client.(*Client); ok {
|
||||||
sm.Metrics = initMetrics()
|
scs = &client.CurrentState
|
||||||
err := c.Connect()
|
}
|
||||||
if err != nil {
|
if component, ok := sm.client.(*Component); ok {
|
||||||
return err
|
scs = &component.CurrentState
|
||||||
}
|
}
|
||||||
if sm.PostConnect != nil {
|
if scs != nil && scs.getState() == StateDisconnected {
|
||||||
sm.PostConnect(sm.client)
|
sm.Metrics = initMetrics()
|
||||||
}
|
err := sm.client.Connect()
|
||||||
return nil
|
if err != nil {
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
if sm.PostConnect != nil {
|
||||||
|
sm.PostConnect(sm.client)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return errors.New("client is not disconnected")
|
return errors.New("client is not disconnected")
|
||||||
|
Loading…
Reference in New Issue
Block a user