forked from genofire/unified-push-xmpp
be sure TokenReadClosed always closed
also if decode of response does not work
This commit is contained in:
parent
7647fc1631
commit
748e4ca5d7
|
@ -122,16 +122,17 @@ func (s *XMPPService) Register(appName, token string) (string, string, error) {
|
||||||
logger.Errorf("xmpp send IQ for register: %v", err)
|
logger.Errorf("xmpp send IQ for register: %v", err)
|
||||||
return "", "xmpp unable send iq to gateway", err
|
return "", "xmpp unable send iq to gateway", err
|
||||||
}
|
}
|
||||||
|
defer func() {
|
||||||
|
if err := t.Close(); err != nil {
|
||||||
|
logger.Errorf("unable to close registration response %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
d := xml.NewTokenDecoder(t)
|
d := xml.NewTokenDecoder(t)
|
||||||
iqRegister := messages.RegisterIQ{}
|
iqRegister := messages.RegisterIQ{}
|
||||||
if err := d.Decode(&iqRegister); err != nil {
|
if err := d.Decode(&iqRegister); err != nil {
|
||||||
logger.Errorf("xmpp recv IQ for register: %v", err)
|
logger.Errorf("xmpp recv IQ for register: %v", err)
|
||||||
return "", "xmpp unable recv iq to gateway", err
|
return "", "xmpp unable recv iq to gateway", err
|
||||||
}
|
}
|
||||||
if err := t.Close(); err != nil {
|
|
||||||
logger.Errorf("unable to close registration response %v", err)
|
|
||||||
return "", "xmpp unable recv iq to gateway", err
|
|
||||||
}
|
|
||||||
if endpoint := iqRegister.Register.Endpoint; endpoint != nil {
|
if endpoint := iqRegister.Register.Endpoint; endpoint != nil {
|
||||||
logger.WithField("endpoint", endpoint.Body).Info("success")
|
logger.WithField("endpoint", endpoint.Body).Info("success")
|
||||||
return endpoint.Body, "", nil
|
return endpoint.Body, "", nil
|
||||||
|
|
Loading…
Reference in New Issue