Comparing version 4.0.1 to 4.0.2
@@ -12,3 +12,2 @@ | ||
websocket._antena_push = push; | ||
websocket._antena_terminate = terminate; | ||
websocket._antena_session = session; | ||
@@ -35,7 +34,2 @@ websocket._antena_receptor = this; | ||
function terminate () { | ||
this.close(1000); | ||
this._antena_receptor._disconnect(this._antena_session, this); | ||
} | ||
function onclose (code, reason) { | ||
@@ -42,0 +36,0 @@ this._antena_receptor._disconnect(this._antena_session, this); |
@@ -1,2 +0,3 @@ | ||
if (typeof window === "undefined") { | ||
// https://github.com/iliakan/detect-node | ||
if (Object.prototype.toString.call(typeof process !== "undefined" ? process : 0) === "[object process]") { | ||
const browserify_do_no_require1 = "./mock/emitter.js"; | ||
@@ -9,2 +10,2 @@ const browserify_do_no_require2 = "./node/emitter.js"; | ||
module.exports = require("./browser/emitter.js"); | ||
} | ||
} |
@@ -9,4 +9,3 @@ | ||
emitter._terminated = false; | ||
emitter._antena_push = _push; | ||
emitter._antena_terminate = _terminate; | ||
emitter._antena_push = push; | ||
emitter.session = session; | ||
@@ -61,3 +60,3 @@ emitter.pull = pull; | ||
function _push (message) { | ||
function push (message) { | ||
if (this._token === null) { | ||
@@ -70,7 +69,2 @@ this._token = message; | ||
function _terminate () { | ||
this._receptor._disconnect(this.session, this); | ||
setTimeout(success, 0, this); | ||
} | ||
///////////// | ||
@@ -77,0 +71,0 @@ // Emitter // |
@@ -13,3 +13,2 @@ | ||
socket._antena_push = null; | ||
socket._antena_terminate = null; | ||
socket.on("close", onclose0); | ||
@@ -38,7 +37,2 @@ socket.on("end", onend); | ||
function terminate () { | ||
this.end(); | ||
this._antena_receptor._disconnect(this._antena_session, this); | ||
} | ||
function receive0 (message) { | ||
@@ -50,3 +44,2 @@ this.removeListener("close", onclose0); | ||
this._antena_push = this._antena_send; | ||
this._antena_terminate = terminate; | ||
if (this._antena_receptor._connect(session, this)) { | ||
@@ -53,0 +46,0 @@ this.on("end", onend1); |
@@ -20,3 +20,2 @@ | ||
_messagess: {__proto__:null}, | ||
_callbacks: {__proto__:null}, | ||
_connect: connect, | ||
@@ -26,3 +25,2 @@ _disconnect: disconnect, | ||
_revoke: revoke, | ||
terminate, | ||
push, | ||
@@ -42,21 +40,7 @@ onpost, | ||
const session = this._sessions[token]; | ||
if (session) { | ||
if (session) | ||
this._sessions[token] = undefined; | ||
if (session in this._callbacks) { | ||
process.nextTick(this._callbacks[session]); | ||
delete this._callbacks[session]; | ||
} | ||
} | ||
return Boolean(session); | ||
} | ||
function terminate (session, callback) { | ||
if (session in this._callbacks) | ||
return callback(new Error("Terminate already pending")); | ||
if (!this._connections[session]) | ||
return callback(new Error("Connection not found")); | ||
this._callbacks[session] = callback; | ||
this._connections[session]._antena_terminate(); | ||
} | ||
function connect (session, connection) { | ||
@@ -68,6 +52,2 @@ if (session in this._connections) | ||
this._sessions[token] = undefined; | ||
if (session in this._callbacks) { | ||
process.nextTick(this._callbacks[session], new Error("Token revoked by another connection")); | ||
delete this._callbacks[session]; | ||
} | ||
} | ||
@@ -74,0 +54,0 @@ } |
{ | ||
"name": "antena", | ||
"description": "Isomorphic communication library for node and browsers", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Laurent Christophe", |
@@ -91,9 +91,2 @@ # Antena | ||
### `receptor.terminate(session, (error) => { ... })` | ||
Attempt to gracefully close a connection. | ||
* `session :: string` | ||
* `error :: Error` | ||
### `receptor.onpost = (session, message) => { ... }` | ||
@@ -100,0 +93,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31948
2
783
205