Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
eighteyes committed Feb 2, 2018
1 parent 6374731 commit f885dcf
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 102 deletions.
1 change: 0 additions & 1 deletion lib/service/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ f.init = function () {
}
}
}
}

module.exports = f;
56 changes: 31 additions & 25 deletions lib/service/stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,30 +453,36 @@ function registerDevice(opts) {
applicationConfigs: true
});

if (channel === 'app-emit') {
if (_.isArray(payload)) {
Matrix.dailyDPCount[new Date().getHours()] += payload.length;
})
}

// in case an ID slipped through
_.each(payload, (p) => {
delete p._id;
});
/**
* pretty damn important for being at the end of the file
* writes to the socket using a standardized format
* @example { channel: 'app-emit', payload: {foo: 'bar'}}
*/
function socketEmit(channel, payload) {

/**
* pretty damn important for being at the end of the file
* writes to the socket using a standardized format
* @example { channel: 'app-emit', payload: {foo: 'bar'}}
*/
function socketEmit(channel, payload) {

if (socket && socket.connected && (socket.registered || channel === 'device-register')) {
debug('[M]->SS', channel.yellow, (_.isArray(payload)) ? '#' + payload.length : payload);
socket.send(JSON.stringify({
channel: channel,
payload: payload
}));
} else if (channel === 'app-emit') {
debug('[M]->SS WARN: emit while socket is unwell');
Matrix.sendCache.push(payload);
}
}

if (channel === 'app-emit') {
if (_.isArray(payload)) {
Matrix.dailyDPCount[new Date().getHours()] += payload.length;

// in case an ID slipped through
_.each(payload, (p) => {
delete p._id;
});
}
}

if (socket && socket.connected && (socket.registered || channel === 'device-register')) {
debug('[M]->SS', channel.yellow, (_.isArray(payload)) ? '#' + payload.length : payload);
socket.send(JSON.stringify({
channel: channel,
payload: payload
}));
} else if (channel === 'app-emit') {
debug('[M]->SS WARN: emit while socket is unwell');
Matrix.sendCache.push(payload);
}
}
77 changes: 1 addition & 76 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,78 +1,4 @@
{
<<<<<<< HEAD
"name": "matrix-os",
"version": "0.16.0",
"description": "Portal to device layer for AdMobilize Matrix devices. Includes global component, npm install -g matrix-cli",
"main": "app.js",
"repository": "http://github.com/matrix-io/matrix-os",
"keywords": "matrix,creator,iot,zmq,protobuf,zigbee,zwave,nfc,gyroscope,accellerometer,thread,bluetooth,ir,microphone,robots,smart homes,smart business,security,sensors,maker,firebase",
"homepage": "http://creator.matrix.one",
"bugs": "https://github.com/matrix-io/matrix-os/issues/new",
"scripts": {
"debug": "DEBUG=*,-engine*,-needle,-*led,-gatt,-bleno,-Component,-bt-characteristic,-hci NODE_ENV=dev node index.js",
"debugger": "DEBUG=*,-engine*,-needle,-*led,-gatt,-bleno,-Component,-bt-characteristic,-hci NODE_ENV=dev node --debug index.js",
"debug-test": "DEBUG=*,-engine*,-Component*,-gatt,-bleno,-bt-characteristic,-hci node test/_runner.js",
"local-debug": "DEBUG=*,-engine*,-Component* NODE_ENV=local node index.js",
"local": "NODE_ENV=local node index.js",
"start": "nodemon --watch lib --watch config",
"test": "node test/_runner.js",
"pr": "open https://bitbucket.org/admobilize/admatrix/pull-request/new",
"deploy-clear": "sudo rm -r db node_modules/matrix-firebase node_modules/matrix-app-config-helper node_modules/matrix-node-sdk node_modules/matrix-eventfilter",
"deploy-copy": "cd node_modules; cp -r ../../matrix-firebase ./matrix-firebase; cp -r ../../matrix-app-config-helper ./matrix-app-config-helper; cp -r ../../matrix-node-sdk ./matrix-node-sdk; cp -r ../../matrix-eventfilter ./matrix-eventfilter; cd ..;",
"deploy-image": "find apps -name '*.matrix' ! -name 'monitor.matrix' -type d -exec rm -r {} +; docker build --no-cache -t matrix/matrix-os .;docker push admobilize/matrix-os",
"local-setup": "cd node_modules; ln -s ../../pi-wifi ./pi-wifi; ln -s ../../matrix-firebase ./matrix-firebase; ln -s ../../matrix-app-config-helper ./matrix-app-config-helper; ln -s ../../matrix-node-sdk ./matrix-node-sdk; ln -s ../../matrix-eventfilter ./matrix-eventfilter; cd ..",
"sync": "rsync -e ssh --progress -u package.json index.js pi@m:mos/;rsync -ru -e ssh --progress lib proto config apps test pi@m:mos",
"sync-local": "rsync -e ssh --progress -u package.json index.js pi@l:matrix-os/;rsync -ru -e ssh --progress lib proto config apps test pi@l:matrix-os",
"sync-m1": "rsync -e ssh --progress -u package.json index.js pi@m1:matrix-os/;rsync -ru -e ssh --progress lib proto config apps test pi@m1:matrix-os",
"device-diagnostics": "DEBUG=*,-engine*,-gatt,-bleno,-bt-characteristic,-hci START_APP=monitor NODE_ENV=dev node index.js",
"screensaver": "START_APP=life NODE_ENV=dev node index.js",
"clock": "START_APP=clock NODE_ENV=dev node index.js",
"apphost-debug": "docker run -v `pwd`/apps:/apps -it matrix-apphost bash",
"apphost-build": "docker build -t matrix-apphost -f Dockerfile-apphost-arm .",
"upgrade": "npm update matrix-node-sdk matrix-app-config-helper matrix-firebase matrix-eventfilter pi-wifi",
"watch": "nodemon --exec npm run sync"
},
"author": "Sean Canton <[email protected]>",
"contributors": [
"Sean Canton <[email protected]>"
],
"license": "ISC",
"dependencies": {
"async": "^1.5.2",
"chai": "^3.5.0",
"colors": "^1.1.2",
"debug": "^2.2.0",
"engine.io-client": "^3.1.4",
"fs-extra": "^0.30.0",
"grpc": "^1.0.0",
"js-yaml": "^3.6.1",
"jsonwebtoken": "^5.7.0",
"lodash": "^4.13.1",
"matrix-app-config-helper": "https://github.com/matrix-io/matrix-app-config-helper/tarball/master",
"matrix-eventfilter": "https://github.com/matrix-io/matrix-eventfilter/tarball/master",
"matrix-firebase": "https://github.com/matrix-io/matrix-firebase/tarball/master",
"matrix-node-sdk": "https://github.com/matrix-io/matrix-node-sdk/tarball/master",
"matrix-protos": "0.0.11",
"mic": "^2.1.1",
"mocha": "^2.4.5",
"nedb": "^1.8.0",
"network": "^0.3.2",
"optional": "^0.1.4",
"pi-wifi": "^1.1.2",
"protobufjs": "^5.0.1",
"request": "^2.72.0",
"rimraf": "^2.5.2",
"should": "^7.0.2",
"tinycolor2": "^1.3.0",
"tree-kill": "^1.1.0",
"unzip2": "^0.2.5",
"zeromq": "^4.6.0"
},
"engines": {
"node": ">=0.12.7 <=6.5"
}
}
=======
"name": "matrix-os",
"version": "0.16.0",
"description": "Portal to device layer for AdMobilize Matrix devices. Includes global component, npm install -g matrix-cli",
Expand Down Expand Up @@ -148,5 +74,4 @@
"engines": {
"node": ">=0.12.7 <=6.5"
}
}
>>>>>>> sc/matrix-protos
}

0 comments on commit f885dcf

Please sign in to comment.