Comparing version 0.1.3 to 0.1.4
{ | ||
"name": "antena", | ||
"description": "API to uniformely perform (a)synchronous http requests and websocket connections", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Laurent Christophe", |
@@ -7,3 +7,3 @@ # antena | ||
While emitters should receive information to connect to a receptor at their creation. | ||
Usage [here](/demo), live demo [here](https://cdn.rawgit.com/lachrist/antena/8e7431d1/demo/index.html). | ||
Usage [here](/demo), live demo [here](https://cdn.rawgit.com/lachrist/antena/8964c4d2/demo/index.html). | ||
@@ -62,7 +62,13 @@ ## `Handlers` | ||
### `terminate = receptor.spawn(url)` | ||
### `worker = receptor.spawn(url)` | ||
* `receptor :: antena.ReceptorWorker` | ||
* `url :: string | object-url` | ||
* `terminate()` | ||
* `worker :: EventTarget` | ||
* `terminate()` | ||
* BrowserEvent `error :: ErrorEvent` | ||
* `message :: string` | ||
* `filename :: string` | ||
* `lineno :: number` | ||
* `colno :: number` | ||
@@ -69,0 +75,0 @@ ### `onrequest = receptor.handler("request")` |
@@ -6,5 +6,15 @@ | ||
module.exports = function (url) { | ||
function terminate () { | ||
this.terminate(); | ||
for (var i=0; this._pool.get[i] !== void 0; i++) { | ||
if (pool.get[i] !== null) { | ||
this._pool.get[i].readyState = 3; | ||
this._pool.get[i].emit("close", 1001, "CLOSE_GOING_AWAY") | ||
} | ||
}; | ||
} | ||
module.exports = function (url, options) { | ||
var self = this; | ||
var worker = new Worker(url); | ||
var worker = new Worker(url, options); | ||
var pool = WebworkerSocketPool(worker); | ||
@@ -59,23 +69,13 @@ var views = null; | ||
}; | ||
worker.onmessage = function (message) { | ||
worker.addEventListener("message", function (event) { | ||
if (views) | ||
return handlers[message.data.name](message.data); | ||
return handlers[event.data.name](event.data); | ||
views = {}; | ||
views.lock = new Uint8Array(message.data, 0, 1); | ||
views.length = new Uint32Array(message.data, 4, 1); | ||
views.data = new Uint16Array(message.data, 8); | ||
}; | ||
return function () { | ||
worker.terminate(); | ||
worker.onmessage = null; | ||
for (var i=0; pool.get[i] !== void 0; i++) { | ||
if (pool.get[i] !== null) { | ||
pool.get[i].readyState = 3; | ||
pool.get[i].emit("close", 1001, "CLOSE_GOING_AWAY") | ||
} | ||
}; | ||
pool = null; | ||
views = null; | ||
handlers = null; | ||
}; | ||
views.lock = new Uint8Array(event.data, 0, 1); | ||
views.length = new Uint32Array(event.data, 4, 1); | ||
views.data = new Uint16Array(event.data, 8); | ||
}); | ||
worker._pool = pool; | ||
worker.terminate = terminate; | ||
return worker; | ||
}; |
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
28803
195
675