Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Commit

Permalink
refactored changeGroup + made function signatures more telling
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaus Großmann committed Jul 17, 2015
1 parent 7dcc319 commit 4928594
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions master/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ module.exports = {
},
/**
* @param {String} url
* @param {String} which
* @param {String} clientId
* @param {Function} cb
*/
changeUrl: function (url, which, cb) {
changeUrl: function (url, clientId, cb) {
try {
var client = this.getClient(which, true);
var client = this.getClient(clientId, true);
client.url = url;

if (client.up) {
Expand All @@ -124,12 +124,12 @@ module.exports = {
},
/**
* @param {String} url
* @param {String} which
* @param {String} clientId
* @param {Function} cb
*/
changePanicUrl: function (url, which, cb) {
changePanicUrl: function (url, clientId, cb) {
try {
var client = this.getClient(which, true);
var client = this.getClient(clientId, true);
client.panicUrl = url;
cb(null, client);

Expand All @@ -139,12 +139,12 @@ module.exports = {
},
/**
* @param {String} state
* @param {String} which
* @param {String} clientId
* @param {Function} cb
*/
setPanicState: function (state, which, cb) {
setPanicState: function (state, clientId, cb) {
try {
var client = this.getClient(which, true);
var client = this.getClient(clientId, true);
client.panicState = state;

if (client.up) {
Expand All @@ -159,12 +159,12 @@ module.exports = {
},
/**
* @param {String} title
* @param {String} which
* @param {String} clientId
* @param {Function} cb
*/
changeTitle: function (title, which, cb) {
changeTitle: function (title, clientId, cb) {
try {
var client = this.getClient(which, true);
var client = this.getClient(clientId, true);
client.title = title;

cb(null, client);
Expand All @@ -174,14 +174,18 @@ module.exports = {
}
},
/**
* @param {String} group
* @param {String} which
* @param {String} groupId
* @param {String} clientId
* @param {Function} cb
*/
changeGroup: function (group, which, cb) {
changeGroup: function (groupId, clientId, cb) {
try {
var client = this.getClient(which, true);
client.group = group;
var client = this.getClient(clientId, true);
var group = this.getGroup(groupId);

client.group = groupId;
client.panicUrl = group.panicUrl;
client.panicState = group.panicState;

cb(null, client);
}
Expand All @@ -191,12 +195,12 @@ module.exports = {
},
/**
* @param {String} title
* @param {String} which
* @param {String} groupId
* @param {Function} cb
*/
changeGroupTitle: function (title, which, cb) {
changeGroupTitle: function (title, groupId, cb) {
try {
var group = this.getGroup(which);
var group = this.getGroup(groupId);
group.title = title;

cb(null, group);
Expand All @@ -207,12 +211,12 @@ module.exports = {
},
/**
* @param {Boolean|Number} state
* @param {String} which
* @param {String} clientId
* @param {Function} cb
*/
switchTV: function (state, which, cb) {
switchTV: function (state, clientId, cb) {
try {
var client = this.getClient(which);
var client = this.getClient(clientId);
protocol.requestSwitchTV(state, client.socket, cb);
}
catch (e) {
Expand Down

0 comments on commit 4928594

Please sign in to comment.