mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-12-27 01:48:21 +01:00
use web assembly and web worker for data decoder
This commit is contained in:
commit
ec0a87ef5a
@ -7,6 +7,12 @@ coffees = assets/coffee/bootstrap.coffee \
|
||||
assets/coffee/MarkOn.coffee \
|
||||
assets/coffee/WVNC.coffee
|
||||
|
||||
SED=sed
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
SED=gsed
|
||||
endif
|
||||
|
||||
main: js
|
||||
- mkdir -p $(BUILDDIR)/assets
|
||||
cp -rf $(copyfiles) $(BUILDDIR)
|
||||
@ -18,8 +24,8 @@ js:
|
||||
for f in $(coffees); do (cat "$${f}"; echo) >> assets/scripts/main.coffee; done
|
||||
coffee --compile assets/scripts/main.coffee
|
||||
coffee --compile assets/coffee/decoder.coffee
|
||||
sed '2d' assets/coffee/decoder.js > assets/scripts/tmp.js
|
||||
head -n -1 assets/scripts/tmp.js > assets/scripts/decoder.js
|
||||
$(SED) '2d' assets/coffee/decoder.js > assets/scripts/tmp.js
|
||||
$(SED) '$$ d' assets/scripts/tmp.js > assets/scripts/decoder.js
|
||||
-rm assets/coffee/decoder.js
|
||||
-rm assets/scripts/tmp.js
|
||||
-rm assets/scripts/main.coffee
|
||||
|
@ -60,16 +60,11 @@ class WVNC extends window.classes.BaseObject
|
||||
|
||||
me.canvas.onkeydown = me.canvas.onkeyup = me.canvas.onkeypress = (e) ->
|
||||
# get the key code
|
||||
if e.key is "Shift"
|
||||
code = 16
|
||||
else if e.ctrlKey
|
||||
code = 17
|
||||
else if e.altKey
|
||||
code = 18
|
||||
else if e.metaKey
|
||||
code = 91
|
||||
else
|
||||
code = String.charCodeAt(e.key)
|
||||
keycode = e.keyCode
|
||||
if ((keycode > 47 and keycode < 58) or (keycode > 64 and keycode < 91) or (keycode > 95 and keycode < 112) or (keycode > 185 and keycode < 193) or (keycode > 218 && keycode < 223))
|
||||
code = e.key.charCodeAt(0)
|
||||
else
|
||||
code = keycode
|
||||
if e.type is "keydown"
|
||||
me.sendKeyEvent code, 1
|
||||
else if e.type is "keyup"
|
||||
@ -132,7 +127,7 @@ class WVNC extends window.classes.BaseObject
|
||||
console.log "socket closed"
|
||||
|
||||
initConnection: () ->
|
||||
vncserver = "localhost:5901"
|
||||
vncserver = "192.168.1.20:5901"
|
||||
data = new Uint8Array vncserver.length + 5
|
||||
data[0] = 32 # bbp
|
||||
###
|
||||
@ -168,7 +163,7 @@ class WVNC extends window.classes.BaseObject
|
||||
data = new Uint8Array 2
|
||||
data[0] = code
|
||||
data[1] = v
|
||||
console.log String.fromCharCode(code), v
|
||||
console.log code, v
|
||||
@socket.send( @buildCommand 0x06, data )
|
||||
|
||||
buildCommand: (hex, o) ->
|
||||
@ -199,7 +194,7 @@ class WVNC extends window.classes.BaseObject
|
||||
console.log "Error", dec.decode(data)
|
||||
when 0x81
|
||||
console.log "Request for password"
|
||||
pass = "!x$@n9"
|
||||
pass = "lxsan9"#"!x$@n9"
|
||||
@socket.send (@buildCommand 0x02, pass)
|
||||
when 0x82
|
||||
console.log "Request for login"
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated by CoffeeScript 1.9.3
|
||||
// Generated by CoffeeScript 1.12.7
|
||||
(function() {
|
||||
var APIManager, BaseObject, MarkOn, WVNC, require,
|
||||
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
|
||||
@ -247,17 +247,12 @@
|
||||
return sendMouseLocation(e);
|
||||
});
|
||||
me.canvas.onkeydown = me.canvas.onkeyup = me.canvas.onkeypress = function(e) {
|
||||
var code;
|
||||
if (e.key === "Shift") {
|
||||
code = 16;
|
||||
} else if (e.ctrlKey) {
|
||||
code = 17;
|
||||
} else if (e.altKey) {
|
||||
code = 18;
|
||||
} else if (e.metaKey) {
|
||||
code = 91;
|
||||
var code, keycode;
|
||||
keycode = e.keyCode;
|
||||
if ((keycode > 47 && keycode < 58) || (keycode > 64 && keycode < 91) || (keycode > 95 && keycode < 112) || (keycode > 185 && keycode < 193) || (keycode > 218 && keycode < 223)) {
|
||||
code = e.key.charCodeAt(0);
|
||||
} else {
|
||||
code = String.charCodeAt(e.key);
|
||||
code = keycode;
|
||||
}
|
||||
if (e.type === "keydown") {
|
||||
me.sendKeyEvent(code, 1);
|
||||
@ -337,7 +332,7 @@
|
||||
|
||||
WVNC.prototype.initConnection = function() {
|
||||
var data, rate, vncserver;
|
||||
vncserver = "localhost:5901";
|
||||
vncserver = "192.168.1.20:5901";
|
||||
data = new Uint8Array(vncserver.length + 5);
|
||||
data[0] = 32;
|
||||
|
||||
@ -379,7 +374,7 @@
|
||||
data = new Uint8Array(2);
|
||||
data[0] = code;
|
||||
data[1] = v;
|
||||
console.log(String.fromCharCode(code), v);
|
||||
console.log(code, v);
|
||||
return this.socket.send(this.buildCommand(0x06, data));
|
||||
};
|
||||
|
||||
@ -415,7 +410,7 @@
|
||||
return console.log("Error", dec.decode(data));
|
||||
case 0x81:
|
||||
console.log("Request for password");
|
||||
pass = "!x$@n9";
|
||||
pass = "lxsan9";
|
||||
return this.socket.send(this.buildCommand(0x02, pass));
|
||||
case 0x82:
|
||||
console.log("Request for login");
|
||||
|
Loading…
Reference in New Issue
Block a user