spacebro-client
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -19,3 +19,7 @@ 'use strict' | ||
] | ||
actionList.push({name: 'new-media'}) | ||
spacebroClient.registerToMaster(actionList, 'example-bro') | ||
spacebroClient.registerToMaster(actionList, 'example-bro') | ||
setInterval(function () { | ||
spacebroClient.emit('new-media', {data: 'foo'}) | ||
}, 2000) |
17
index.js
@@ -6,8 +6,8 @@ 'use strict' | ||
const _ = require('lodash') | ||
let socket | ||
function registerToMaster (actionList, clientName, zeroconfName) { | ||
mdns.connectToService(zeroconfName || 'spacebro', function socketioInit(err, address, port) { | ||
mdns.connectToService(zeroconfName || 'spacebro', function socketioInit (err, address, port) { | ||
console.log('service found: ', address) | ||
var socket = io('http://' + address + ':' + port) | ||
socket | ||
socket = io('http://' + address + ':' + port) | ||
.on('connect', function () { | ||
@@ -23,3 +23,5 @@ console.log('socketio connected to ' + 'http://' + address + ':' + port) | ||
socket.on(action.name, function (data) { | ||
action.trigger(data) | ||
if (action.trigger) { | ||
action.trigger(data) | ||
} | ||
}) | ||
@@ -31,3 +33,8 @@ } | ||
module.exports = { | ||
registerToMaster: registerToMaster | ||
registerToMaster: registerToMaster, | ||
emit: function (event, data) { | ||
if (socket) { | ||
socket.emit(event, data) | ||
} | ||
} | ||
} |
{ | ||
"name": "spacebro-client", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Allow to automagically 🌟 connect to a Spacebro server", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "echo \"Error: no test specified\" && exit 1", | ||
"example": "node ./example/index-example.js" | ||
}, | ||
@@ -9,0 +10,0 @@ "repository": { |
@@ -15,2 +15,3 @@ # Spacebro client | ||
spacebroClient.registerToMaster(actionList, clientName, zeroconfName) | ||
spacebroClient.emit('event', data) | ||
``` | ||
@@ -37,2 +38,4 @@ | ||
Do not forget to add the event you want to broadcast to the actionList. | ||
The clientName parameter is the name of you client. You will see it in the Spacebro log. | ||
@@ -39,0 +42,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
6884
98
44