Added stf namespace.

This commit is contained in:
Gunther Brunner
2014-02-18 20:32:45 +09:00
parent a1b0d136be
commit 347d9e9a55
10 changed files with 73 additions and 17 deletions

View File

@@ -0,0 +1,55 @@
module.exports = function ControlServiceFactory($rootScope, socket) {
var controlService = {
}
function ControlService(channel) {
function touchSender(type) {
return function (x, y) {
socket.emit(type, channel, {
x: x, y: y
})
}
}
function keySender(type) {
return function (key) {
socket.emit(type, channel, {
key: key
})
}
}
this.touchDown = touchSender('input.touchDown')
this.touchMove = touchSender('input.touchMove')
this.touchUp = touchSender('input.touchUp')
this.tap = touchSender('input.tap')
this.keyDown = keySender('input.keyDown')
this.keyUp = keySender('input.keyUp')
this.keyPress = keySender('input.keyPress')
this.home = function () {
socket.emit('input.home', channel)
}
this.menu = function () {
socket.emit('input.menu', channel)
}
this.back = function () {
socket.emit('input.back', channel)
}
this.type = function (text) {
socket.emit('input.type', channel, {
text: text
})
}
}
controlService.forChannel = function (channel) {
return new ControlService(channel)
}
return controlService
}