1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 10:39:25 +02:00

APKs can now be drag & dropped to the device screen, which will install the application. Still lacking UI, and the app doesn't get launched.

This commit is contained in:
Simo Kinnunen 2014-03-20 22:00:01 +09:00
parent 5771507fc9
commit dfe3d97de3
12 changed files with 280 additions and 8 deletions

View file

@ -7,6 +7,7 @@ var validator = require('express-validator')
var socketio = require('socket.io')
var zmq = require('zmq')
var Promise = require('bluebird')
var httpProxy = require('http-proxy')
var _ = require('lodash')
var logger = require('../util/logger')
@ -20,14 +21,17 @@ var datautil = require('../util/datautil')
var auth = require('../middleware/auth')
var webpack = require('../middleware/webpack')
var cors = require('cors')
module.exports = function(options) {
var log = logger.createLogger('app')
, app = express()
, server = http.createServer(app)
, io = socketio.listen(server)
, channelRouter = new events.EventEmitter()
, proxy = httpProxy.createProxyServer()
proxy.on('error', function(err) {
log.error('Proxy had an error', err.stack)
})
app.set('view engine', 'jade')
app.set('views', pathutil.resource('app/views'))
@ -38,8 +42,6 @@ module.exports = function(options) {
io.set('log level', 1)
io.set('browser client', false)
app.use(cors())
app.use('/static/bower_components',
express.static(pathutil.resource('bower_components')))
app.use('/static/data', express.static(pathutil.resource('data')))
@ -181,6 +183,18 @@ module.exports = function(options) {
})
})
app.post('/api/v1/resources', function(req, res) {
proxy.web(req, res, {
target: options.storageUrl
})
})
app.get('/api/v1/resources/:id', function(req, res) {
proxy.web(req, res, {
target: options.storageUrl
})
})
io.set('authorization', (function() {
var parse = Promise.promisify(express.cookieParser(options.secret))
return function(handshake, accept) {
@ -387,6 +401,16 @@ module.exports = function(options) {
, wireutil.envelope(new wire.ShellKeepAliveMessage(data))
])
})
.on('device.install', function(channel, responseChannel, data) {
joinChannel(responseChannel)
push.send([
channel
, wireutil.transaction(
responseChannel
, new wire.InstallMessage(data)
)
])
})
})
.finally(function() {
// Clean up all listeners and subscriptions