Move IDHandler JS module to platform from Websock

This commit is contained in:
Fabio Alessandrelli
2018-08-09 02:58:39 +02:00
parent 6008745991
commit 6a1bf006a3
3 changed files with 69 additions and 19 deletions

View File

@ -60,25 +60,6 @@ void register_websocket_types() {
_SET_HINT(WSS_OUT_PKT, 1024, 16384);
#ifdef JAVASCRIPT_ENABLED
EM_ASM({
var IDHandler = {};
IDHandler["ids"] = {};
IDHandler["has"] = function(id) {
return IDHandler.ids.hasOwnProperty(id);
};
IDHandler["add"] = function(obj) {
var id = crypto.getRandomValues(new Int32Array(32))[0];
IDHandler.ids[id] = obj;
return id;
};
IDHandler["get"] = function(id) {
return IDHandler.ids[id];
};
IDHandler["remove"] = function(id) {
delete IDHandler.ids[id];
};
Module["IDHandler"] = IDHandler;
});
EMWSPeer::make_default();
EMWSClient::make_default();
EMWSServer::make_default();