Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function deletePhoto(imgPath) {
fs.unlink(imgPath, (err) => {
if (err) {
return console.error(err);
}
console.log(imgPath + ' is deleted.');
});
}
// PubNub to publish the data
// to make a separated web/mobile interface can subscribe the data to stream the photos in realtime.
const channel = 'kittyCam';
const pubnub = require('pubnub').init({
subscribe_key: config.pubnub.subscribe_key,
publish_key: config.pubnub.publish_key
});
function publish(url, timestamp) {
pubnub.publish({
channel: channel,
message: {image: url, timestamp: timestamp},
callback: (m) => {console.log(m);},
error: (err) => {console.log(err);}
});
}
// Nexmo to send SMS
const Nexmo = require('nexmo');
var raspi = require('raspi-io');
var five = require('johnny-five');
var board = new five.Board({io: new raspi()});
var PUBNUB = require('pubnub');
var pubnub = PUBNUB.init({
publish_key: 'demo',
subscribe_key: 'demo'
});
board.on('ready', function() {
console.log('board is ready');
// Create a new `motion` hardware instance.
var pin = new five.Pin({
pin: 'P1-7'
}); //pin 7 (GPIO 4)
setInterval(function(){
pin.query(function(state) {
(function(){
// -------------------------------------
// INIT PUBNUB
// -------------------------------------
var pubnub = require('pubnub').init({
publish_key : 'demo',
subscribe_key : 'demo',
ssl : false,
origin : 'pubsub.pubnub.com'
});
// -------------------------------------
// LISTEN FOR MESSAGES
// -------------------------------------
pubnub.subscribe({
channel : 'test',
connect : function() {
// You can Receive Messages!
send_a_message("Hello World! #1");
send_a_message("Hello World! #2");
send_a_message("Hello World! #3");
function Connector_PubNub(config_init, config_mess, max_connections)
{
HandshakeConnector.call(this, max_connections);
var self = this;
var channel = config_mess.channel;
// Connect a handshake connector to the PubNub server
var pubnub = PUBNUB.init(config_init);
// Configure handshake connector
pubnub.subscribe(
{
channel: channel,
restore: false,
backfill: false,
connect: self._open,
message: self._message,
disconnect: self._close,
error: function(response)
{
self._error(new Error(response ? response.error : 'Undefined error'))
}
var pubnub = require('pubnub').init({
publish_key : 'pub-c-156a6d5f-22bd-4a13-848d-b5b4d4b36695',
subscribe_key : 'sub-c-f762fb78-2724-11e4-a4df-02ee2ddab7fe'
});
var channel = 'hello-pi';
var username = 'Your name';
var message = 'Hello World from Pi!';
data = {
'username': username,
'message': message
}
pubnub.publish({
channel : channel,
interaction.header("PubNubDriver: This store is not set up yet");
interaction.log("Please set up your PubNub account and then enter the following command");
interaction.log();
interaction.code("iotdb --global set stores/pubnub/publish_key 'pub-c-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'");
interaction.code("iotdb --global set stores/pubnub/subscribe_key 'pub-c-XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX'");
interaction.end();
logger.error({
method: "pubnub",
cause: "publish_key not in keystore",
}, "no PubNub publish key");
return null;
}
__pubnub = node_pubnub.init({
publish_key: publish_key,
subscribe_key: subscribe_key,
});
}
return __pubnub;
};
export default (publish_key, subscribe_key, userType) => {
let uuid = new Date().getTime();
const pubnub = PUBNUB.init({publish_key, subscribe_key, uuid});
if (isSender(userType)) {
return sendActionMiddleware(pubnub);
}
if (isReceiver(userType)) {
return receiveActionMiddleware(pubnub);
}
return farwardNextAction();
}
var Ma=PUBNUB.ws=function(a,c){if(!(this instanceof Ma))return new Ma(a,c);var b=this,a=b.url=a||"";b.protocol=c||"Sec-WebSocket-Protocol";var d=a.split("/"),d={ssl:"wss:"===d[0],origin:d[2],publish_key:d[3],subscribe_key:d[4],channel:d[5]};b.CONNECTING=0;b.OPEN=1;b.CLOSING=2;b.CLOSED=3;b.CLOSE_NORMAL=1E3;b.CLOSE_GOING_AWAY=1001;b.CLOSE_PROTOCOL_ERROR=1002;b.CLOSE_UNSUPPORTED=1003;b.CLOSE_TOO_LARGE=1004;b.CLOSE_NO_STATUS=1005;b.CLOSE_ABNORMAL=1006;b.onclose=b.onerror=b.onmessage=b.onopen=b.onsend=
x();b.binaryType="";b.extensions="";b.bufferedAmount=0;b.trasnmitting=u;b.buffer=[];b.readyState=b.CONNECTING;if(!a)return b.readyState=b.CLOSED,b.onclose({code:b.CLOSE_ABNORMAL,reason:"Missing URL",wasClean:j}),b;b.e=PUBNUB.init(d);b.e.i=d;b.i=d;b.e.subscribe({restore:u,channel:d.channel,disconnect:b.onerror,reconnect:b.onopen,error:function(){b.onclose({code:b.CLOSE_ABNORMAL,reason:"Missing URL",wasClean:u})},callback:function(a){b.onmessage({data:a})},connect:function(){b.readyState=b.OPEN;b.onopen()}})};
Ma.prototype.send=function(a){var c=this;c.e.publish({channel:c.e.i.channel,message:a,callback:function(a){c.onsend({data:a})}})};
function init() {
pubnub = require("pubnub").init({
publish_key : "demo",
subscribe_key : "demo"
});
}
var PUBNUB = require('pubnub');
var pubnub = PUBNUB.init({
publish_key: 'demo',
subscribe_key: 'demo'
});
setInterval(function(){
pubnub.publish({
channel: "c3-gauge-rasp-demo",
message: {
columns: [['data', Math.random() * 99]]
}
});
}, 1000);