Skip to content

Commit

Permalink
Extract explanatory functions from mover.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Feline committed Aug 23, 2017
1 parent df10104 commit f541733
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions TelepresenceBot/server-unit/core/mover.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
module.exports = function Mover(clientsAndRooms, emitter) {

var emitToRoom = function (direction) {
return function (room) {
emitter.to(room).emit('direction', direction);
}
}

return {
moveIn: function (clientId, direction) {
var rooms = clientsAndRooms[clientId];

Object.keys(rooms || {})
.map(function (room) {
emitter.to(room).emit('direction', direction);
});
.every(emitToRoom(direction));
}
};
}

0 comments on commit f541733

Please sign in to comment.