forked from jshiffer/go-xmpp
Recv: Return error on stream error.
This commit is contained in:
parent
44095406a2
commit
da2377ecb0
8
xmpp.go
8
xmpp.go
@ -962,6 +962,14 @@ func (c *Client) Recv() (stanza interface{}, err error) {
|
|||||||
return Chat{}, err
|
return Chat{}, err
|
||||||
}
|
}
|
||||||
switch v := val.(type) {
|
switch v := val.(type) {
|
||||||
|
case *streamError:
|
||||||
|
errorMessage := v.Text.Text
|
||||||
|
if errorMessage == "" {
|
||||||
|
// v.Any is type of sub-element in failure,
|
||||||
|
// which gives a description of what failed if there was no text element
|
||||||
|
errorMessage = v.Any.Space
|
||||||
|
}
|
||||||
|
return Chat{}, errors.New("stream error: " + errorMessage)
|
||||||
case *clientMessage:
|
case *clientMessage:
|
||||||
if v.Event.XMLNS == XMPPNS_PUBSUB_EVENT {
|
if v.Event.XMLNS == XMPPNS_PUBSUB_EVENT {
|
||||||
// Handle Pubsub notifications
|
// Handle Pubsub notifications
|
||||||
|
Loading…
Reference in New Issue
Block a user