@xmpp/connection
Advanced tools
Comparing version 0.2.0 to 0.3.0
54
index.js
@@ -53,4 +53,13 @@ 'use strict' | ||
_reset() { | ||
this.domain = '' | ||
this.lang = '' | ||
this.jid = null | ||
this._detachSocket() | ||
this._detachParser() | ||
this.socket = null | ||
} | ||
_attachSocket(socket) { | ||
const sock = this.socket = socket | ||
const sock = (this.socket = socket) | ||
const listeners = this.socketListeners | ||
@@ -62,10 +71,5 @@ listeners.data = data => { | ||
} | ||
listeners.close = () => { | ||
this.domain = '' | ||
this.lang = '' | ||
this.jid = null | ||
this._detachSocket() | ||
this._detachParser() | ||
this.socket = null | ||
this._status('disconnect') | ||
listeners.close = (...args) => { | ||
this._reset() | ||
this._status('disconnect', ...args) | ||
} | ||
@@ -77,2 +81,6 @@ listeners.connect = () => { | ||
listeners.error = error => { | ||
this._reset() | ||
if (this.status === 'connecting') { | ||
this._status('offline') | ||
} | ||
this.emit('error', error) | ||
@@ -95,3 +103,3 @@ } | ||
_attachParser(p) { | ||
const parser = this.parser = p | ||
const parser = (this.parser = p) | ||
const listeners = this.parserListeners | ||
@@ -101,7 +109,13 @@ listeners.element = element => { | ||
this.close().then(() => this.disconnect()) | ||
this.emit('error', new StreamError( | ||
element.children[0].name, | ||
element.getChildText('text', 'urn:ietf:params:xml:ns:xmpp-streams') || '', | ||
element | ||
)) | ||
this.emit( | ||
'error', | ||
new StreamError( | ||
element.children[0].name, | ||
element.getChildText( | ||
'text', | ||
'urn:ietf:params:xml:ns:xmpp-streams' | ||
) || '', | ||
element | ||
) | ||
) | ||
} | ||
@@ -246,6 +260,8 @@ this.emit('element', element) | ||
} | ||
return this.close().then(el => this.disconnect().then(() => { | ||
this._status('offline') | ||
return el | ||
})) | ||
return this.close().then(el => | ||
this.disconnect().then(() => { | ||
this._status('offline') | ||
return el | ||
}) | ||
) | ||
} | ||
@@ -252,0 +268,0 @@ |
{ | ||
"name": "@xmpp/connection", | ||
"description": "XMPP connection for JavaScript", | ||
"repository": "github:node-xmpp/node-xmpp", | ||
"homepage": "https://github.com/node-xmpp/node-xmpp/tree/master/packages/connection", | ||
"bugs": "http://github.com/node-xmpp/node-xmpp/issues", | ||
"version": "0.2.0", | ||
"repository": "github:xmppjs/xmpp.js", | ||
"homepage": "https://github.com/xmppjs/xmpp.js/tree/master/packages/connection", | ||
"bugs": "http://github.com/xmppjs/xmpp.js/issues", | ||
"version": "0.3.0", | ||
"license": "ISC", | ||
@@ -14,10 +14,14 @@ "keywords": [ | ||
"dependencies": { | ||
"@xmpp/events": "^0.2.0", | ||
"@xmpp/jid": "^0.2.0", | ||
"@xmpp/events": "^0.3.0", | ||
"@xmpp/jid": "^0.3.0", | ||
"@xmpp/streamparser": "^0.0.6", | ||
"@xmpp/xml": "^0.2.0" | ||
"@xmpp/xml": "^0.3.0" | ||
}, | ||
"browser": { | ||
"url": false | ||
}, | ||
"engines": { | ||
"node": ">= 6", | ||
"npm": ">= 2" | ||
} | ||
} |
@@ -10,3 +10,3 @@ 'use strict' | ||
const conn = new Connection() | ||
const sock = conn.socket = new EventEmitter() | ||
const sock = (conn.socket = new EventEmitter()) | ||
sock.end = () => {} | ||
@@ -21,3 +21,3 @@ conn.disconnect().catch(err => { | ||
const conn = new Connection() | ||
const sock = conn.socket = new EventEmitter() | ||
const sock = (conn.socket = new EventEmitter()) | ||
sock.end = () => {} | ||
@@ -24,0 +24,0 @@ conn.disconnect().then(() => { |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
554
0
15992
+ Added@xmpp/events@0.3.0(transitive)
+ Added@xmpp/jid@0.3.0(transitive)
+ Added@xmpp/xml@0.3.0(transitive)
- Removed@xmpp/events@0.2.0(transitive)
- Removed@xmpp/jid@0.2.0(transitive)
- Removed@xmpp/xml@0.2.0(transitive)
Updated@xmpp/events@^0.3.0
Updated@xmpp/jid@^0.3.0
Updated@xmpp/xml@^0.3.0