Files
stf-DeviceFarmer-1/lib/units/device/plugins/vnc/util/server.js
Simo Kinnunen 792713d415 VNC screen is visible (w/ RAW encoding). Size of VNC screen is still
hardcoded, preventing real use.
2015-09-14 18:00:17 +09:00

51 lines
1.3 KiB
JavaScript

var util = require('util')
var EventEmitter = require('eventemitter3').EventEmitter
var debug = require('debug')('vnc:server')
var VncConnection = require('./connection')
function VncServer(server) {
this._bound = {
_listeningListener: this._listeningListener.bind(this)
, _connectionListener: this._connectionListener.bind(this)
, _closeListener: this._closeListener.bind(this)
, _errorListener: this._errorListener.bind(this)
}
this.server = server
.on('listening', this._bound._listeningListener)
.on('connection', this._bound._connectionListener)
.on('close', this._bound._closeListener)
.on('error', this._bound._errorListener)
}
util.inherits(VncServer, EventEmitter)
VncServer.prototype.close = function() {
this.server.close()
}
VncServer.prototype.listen = function() {
this.server.listen.apply(this.server, arguments)
}
VncServer.prototype._listeningListener = function() {
this.emit('listening')
}
VncServer.prototype._connectionListener = function(conn) {
debug('connection', conn.remoteAddress, conn.remotePort)
this.emit('connection', new VncConnection(conn))
}
VncServer.prototype._closeListener = function() {
this.emit('close')
}
VncServer.prototype._errorListener = function(err) {
this.emit('error', err)
}
module.exports = VncServer