1
0
mirror of https://github.com/lxsang/antd-web-apps synced 2024-12-31 19:38:21 +01:00
antd-web-apps/apps/assets/coffee/WebVNC.coffee

55 lines
1.7 KiB
CoffeeScript
Raw Normal View History

2018-09-22 19:11:40 +02:00
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',
2018-10-03 11:28:39 +02:00
#ws: 'wss://localhost:9192/wvnc',
2018-09-23 14:20:28 +02:00
ws: 'wss://lxsang.me/wvnc',
2018-09-22 19:11:40 +02:00
worker: '/assets/scripts/decoder.js'
}
@client = new WVNC args
me = @
@client.onpassword = () ->
return new Promise (r,e) ->
2018-09-23 14:08:19 +02:00
r('demopass')
2018-09-22 19:11:40 +02:00
@client.oncredential = () ->
return new Promise (r,e) ->
2018-09-23 14:08:19 +02:00
r('demo', 'demo')
2018-09-22 19:11:40 +02:00
@client.oncopy = (text) ->
2018-09-23 18:26:20 +02:00
cosole.log text
2018-10-09 12:14:33 +02:00
@client.onerror = (m) ->
alert(m)
2018-09-22 19:11:40 +02:00
@client.init()
.then () ->
$("#connect").click (e) ->
2018-09-23 14:08:19 +02:00
me.client.connect "/opt/www/vnc.conf", {
2018-09-22 19:11:40 +02:00
bbp: 32,
flag: 3,
2018-10-03 11:28:39 +02:00
quality: 30
2018-09-22 19:11:40 +02:00
}
2018-10-03 11:28:39 +02:00
$("#tbstatus").html "32bbp, compression JPEG & ZLib, JPEG quality 30%"
2018-09-22 19:11:40 +02:00
$("#stop").click (e) ->
me.client.disconnect()
2018-09-23 14:08:19 +02:00
$("#selscale").on 'change', (e) ->
value = Number(@value)/100
me.client.setScale value
#$("#btclipboard").click (e) ->
# me.client.sendTextAsClipboard ($ "#clipboard")[0].value
2018-09-22 19:11:40 +02:00
.catch (m,s) ->
console.error m, s
WebVNC.dependencies = [
"/assets/scripts/wvnc.js"
]
makeclass "WebVNC", WebVNC