Compare commits
3 commits
160-regres
...
disco_info
Author | SHA1 | Date | |
---|---|---|---|
Bohdan Horbeshko | 69619ebc6d | ||
Bohdan Horbeshko | f8c4ecb59d | ||
9abd5be0aa |
|
@ -21,6 +21,7 @@ type DiscoInfo struct {
|
||||||
Identity []Identity `xml:"identity"`
|
Identity []Identity `xml:"identity"`
|
||||||
Features []Feature `xml:"feature"`
|
Features []Feature `xml:"feature"`
|
||||||
ResultSet *ResultSet `xml:"set,omitempty"`
|
ResultSet *ResultSet `xml:"set,omitempty"`
|
||||||
|
Form *Form `xml:"x,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Namespace lets DiscoInfo implement the IQPayload interface
|
// Namespace lets DiscoInfo implement the IQPayload interface
|
||||||
|
|
|
@ -16,6 +16,7 @@ func TestDiscoInfo_Builder(t *testing.T) {
|
||||||
disco := iq.DiscoInfo()
|
disco := iq.DiscoInfo()
|
||||||
disco.AddIdentity("Test Component", "gateway", "service")
|
disco.AddIdentity("Test Component", "gateway", "service")
|
||||||
disco.AddFeatures(stanza.NSDiscoInfo, stanza.NSDiscoItems, "jabber:iq:version", "urn:xmpp:delegation:1")
|
disco.AddFeatures(stanza.NSDiscoInfo, stanza.NSDiscoItems, "jabber:iq:version", "urn:xmpp:delegation:1")
|
||||||
|
disco.Form = stanza.NewForm([]*stanza.Field{}, "result")
|
||||||
|
|
||||||
parsedIQ, err := checkMarshalling(t, iq)
|
parsedIQ, err := checkMarshalling(t, iq)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -48,6 +49,15 @@ func TestDiscoInfo_Builder(t *testing.T) {
|
||||||
t.Errorf("Incorrect identity name: %#v", pp.Identity[0].Name)
|
t.Errorf("Incorrect identity name: %#v", pp.Identity[0].Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check form
|
||||||
|
if pp.Form == nil {
|
||||||
|
t.Errorf("Form is nil")
|
||||||
|
} else {
|
||||||
|
if len(pp.Form.Fields) != 0 {
|
||||||
|
t.Errorf("Form fields length mismatch: %#v", pp.Form.Fields)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements XEP-0030 example 17
|
// Implements XEP-0030 example 17
|
||||||
|
|
|
@ -114,23 +114,18 @@ func (sm *StreamManager) Stop() {
|
||||||
|
|
||||||
func (sm *StreamManager) connect() error {
|
func (sm *StreamManager) connect() error {
|
||||||
if sm.client != nil {
|
if sm.client != nil {
|
||||||
var scs *SyncConnState
|
if c, ok := sm.client.(*Client); ok {
|
||||||
if client, ok := sm.client.(*Client); ok {
|
if c.CurrentState.getState() == StateDisconnected {
|
||||||
scs = &client.CurrentState
|
sm.Metrics = initMetrics()
|
||||||
}
|
err := c.Connect()
|
||||||
if component, ok := sm.client.(*Component); ok {
|
if err != nil {
|
||||||
scs = &component.CurrentState
|
return err
|
||||||
}
|
}
|
||||||
if scs != nil && scs.getState() == StateDisconnected {
|
if sm.PostConnect != nil {
|
||||||
sm.Metrics = initMetrics()
|
sm.PostConnect(sm.client)
|
||||||
err := sm.client.Connect()
|
}
|
||||||
if err != nil {
|
return 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 a new issue