1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-12-29 02:38:22 +01:00
antd-web-apps/apps/assets/coffee/WebVNC.coffee
2018-10-09 12:14:33 +02:00

55 lines
1.7 KiB
CoffeeScript

class WebVNC extends window.classes.BaseObject
constructor: () ->
super "WebVNC"
init: () ->
me = @
@ready()
.then () ->
me.initVNCClient()
.catch (m, s) ->
console.error(m, s)
initVNCClient: () ->
args =
{
element: 'canvas',
#ws: 'wss://localhost:9192/wvnc',
ws: 'wss://lxsang.me/wvnc',
worker: '/assets/scripts/decoder.js'
}
@client = new WVNC args
me = @
@client.onpassword = () ->
return new Promise (r,e) ->
r('demopass')
@client.oncredential = () ->
return new Promise (r,e) ->
r('demo', 'demo')
@client.oncopy = (text) ->
cosole.log text
@client.onerror = (m) ->
alert(m)
@client.init()
.then () ->
$("#connect").click (e) ->
me.client.connect "/opt/www/vnc.conf", {
bbp: 32,
flag: 3,
quality: 30
}
$("#tbstatus").html "32bbp, compression JPEG & ZLib, JPEG quality 30%"
$("#stop").click (e) ->
me.client.disconnect()
$("#selscale").on 'change', (e) ->
value = Number(@value)/100
me.client.setScale value
#$("#btclipboard").click (e) ->
# me.client.sendTextAsClipboard ($ "#clipboard")[0].value
.catch (m,s) ->
console.error m, s
WebVNC.dependencies = [
"/assets/scripts/wvnc.js"
]
makeclass "WebVNC", WebVNC