This commit is contained in:
unkelpehr 2014-09-27 14:56:57 +02:00
parent cb37d41502
commit e221e9b662
3 changed files with 53 additions and 43 deletions

View File

@ -210,7 +210,7 @@ define({
// Connect events // Connect events
for (var commandName in commands) { for (var commandName in commands) {
if (commandName === '_require' && commandName !== 'post') { if (commandName !== '_require' && commandName !== 'post') {
mediator.on('console:' + commandName, commands[commandName]); mediator.on('console:' + commandName, commands[commandName]);
} }
} }

View File

@ -8,48 +8,60 @@ define({
var mediator = requires.castrato; var mediator = requires.castrato;
// Route mediator messages // Route mediator messages
mediator.on('window:focused',function() { mediator
mediator.emit('audio:off'); .on('window:focused', function() {
mediator.emit('notification:off'); mediator.emit('audio:off');
}); mediator.emit('notification:off');
})
.on('window:blurred',function() {
mediator.emit('audio:on');
mediator.emit('notification:on');
})
.on('command:mute', function () {
mediator.emit('audio:mute');
})
.on('command:unmute', function () {
mediator.emit('audio:unmute');
})
mediator.on('window:blurred',function() { // Help console and host keep track of current states
mediator.emit('audio:on'); .on('room:changed', function(room) {
mediator.emit('notification:on'); mediator
}); .emit('console:param', {
room: room
})
.emit('host:param', {
room: room
});
})
.on('nick:changed', function(nick) {
mediator.emit('console:param', {
nick: nick
});
})
.on('key:changed', function(key) {
mediator
.emit('console:param', {
key: key
})
.emit('host:param', {
key: key
});
})
mediator.on('command:mute', function () { mediator.emit('audio:mute'); } ); // Connect to the default host
mediator.on('command:unmute', function () { mediator.emit('audio:unmute'); } ); .emit('command:connect', undefined, function() {
// Join room and set key if a hash in the format #Room:Key has been provided
if ((hash = window.location.hash)) {
parts = hash.slice(1).split(':');
// Help console and host keep track of current states if (parts[0]) {
mediator.on('room:changed', function(room) { mediator.emit('command:join', parts[0]);
mediator.emit('console:param',{ room: room}); }
mediator.emit('host:param',{ room: room});
});
mediator.on('nick:changed', function(nick) { if (parts[1]) {
mediator.emit('console:param',{ nick: nick}); mediator.emit('command:key', parts[1]);
}); }
mediator.on('key:changed', function(key) {
mediator.emit('console:param',{ key: key});
mediator.emit('host:param',{ key: key});
});
// Connect to the default host
mediator.emit('command:connect', undefined, function() {
// Join room and set key if a hash in the format #Room:Key has been provided
if ((hash = window.location.hash)) {
parts = hash.slice(1).split(':');
if (parts[0]) {
mediator.emit('command:join', parts[0]);
} }
});
if (parts[1]) {
mediator.emit('command:key', parts[1]);
}
}
});
}); });

View File

@ -252,7 +252,7 @@ define(
param = function (p) { param = function (p) {
parameters = fandango.merge({}, parameters, p ); parameters = fandango.merge({}, parameters, p );
}; };
mediator.on('command:host', host); mediator.on('command:host', host);
mediator.on('command:hosts', hosts); mediator.on('command:hosts', hosts);
mediator.on('command:connect', connect); mediator.on('command:connect', connect);
@ -261,6 +261,4 @@ define(
mediator.on('socket:emit', emit); mediator.on('socket:emit', emit);
mediator.on('host:param', param); mediator.on('host:param', param);
}); });