mirror of
https://github.com/lxsang/antd-web-apps
synced 2024-11-20 02:18:20 +01:00
fix
This commit is contained in:
parent
c9ea224f22
commit
f1bd204aff
@ -16,6 +16,12 @@ class WVNC extends window.classes.BaseObject
|
|||||||
$("#connect").click (e) ->
|
$("#connect").click (e) ->
|
||||||
me.counter = 0
|
me.counter = 0
|
||||||
me.openSession()
|
me.openSession()
|
||||||
|
($ me.canvas).css "cursor","none"
|
||||||
|
($ me.canvas).mousemove (e) ->
|
||||||
|
rect = me.canvas.getBoundingClientRect()
|
||||||
|
x = Math.floor(e.clientX - rect.left)
|
||||||
|
y = Math.floor(e.clientY - rect.top)
|
||||||
|
me.sendPointEvent x, y, 0
|
||||||
.catch (m, s) ->
|
.catch (m, s) ->
|
||||||
console.error(m, s)
|
console.error(m, s)
|
||||||
|
|
||||||
@ -27,8 +33,8 @@ class WVNC extends window.classes.BaseObject
|
|||||||
ctx = @buffer.getContext('2d')
|
ctx = @buffer.getContext('2d')
|
||||||
data = ctx.createImageData w, h
|
data = ctx.createImageData w, h
|
||||||
ctx.putImageData data, 0, 0
|
ctx.putImageData data, 0, 0
|
||||||
@callback = () ->
|
#@callback = () ->
|
||||||
me.draw()
|
# me.draw()
|
||||||
@draw()
|
@draw()
|
||||||
|
|
||||||
updateCanvas: (x, y, w, h, pixels) ->
|
updateCanvas: (x, y, w, h, pixels) ->
|
||||||
@ -38,10 +44,10 @@ class WVNC extends window.classes.BaseObject
|
|||||||
imgData.data.set @getCanvasImageData(pixels, w, h)
|
imgData.data.set @getCanvasImageData(pixels, w, h)
|
||||||
ctx.putImageData imgData, x, y
|
ctx.putImageData imgData, x, y
|
||||||
@counter = @counter + 1
|
@counter = @counter + 1
|
||||||
#@draw()
|
|
||||||
if @counter > 50
|
|
||||||
@draw()
|
@draw()
|
||||||
@couter = 0
|
#if @counter > 50
|
||||||
|
# @draw()
|
||||||
|
# @couter = 0
|
||||||
|
|
||||||
getCanvasImageData: (pixels, w, h) ->
|
getCanvasImageData: (pixels, w, h) ->
|
||||||
return pixels if @depth is 32
|
return pixels if @depth is 32
|
||||||
@ -61,7 +67,7 @@ class WVNC extends window.classes.BaseObject
|
|||||||
draw: () ->
|
draw: () ->
|
||||||
if not @socket
|
if not @socket
|
||||||
return
|
return
|
||||||
scale = 0.75
|
scale = 1.0
|
||||||
w = @buffer.width * scale
|
w = @buffer.width * scale
|
||||||
h = @buffer.height * scale
|
h = @buffer.height * scale
|
||||||
@canvas.width = w
|
@canvas.width = w
|
||||||
@ -108,9 +114,20 @@ class WVNC extends window.classes.BaseObject
|
|||||||
console.log "socket closed"
|
console.log "socket closed"
|
||||||
|
|
||||||
initConnection: () ->
|
initConnection: () ->
|
||||||
vncserver = "localhost:5901"
|
vncserver = "192.168.1.8:5900"
|
||||||
@socket.send(@buildCommand 0x01, vncserver)
|
@socket.send(@buildCommand 0x01, vncserver)
|
||||||
|
|
||||||
|
sendPointEvent: (x,y,mask) ->
|
||||||
|
return unless @socket
|
||||||
|
data = new Uint8Array 5
|
||||||
|
data[0] = x & 0xFF
|
||||||
|
data[1] = x >> 8
|
||||||
|
data[2] = y & 0xFF
|
||||||
|
data[3] = y >> 8
|
||||||
|
data[4] = 0
|
||||||
|
#console.log x,y
|
||||||
|
@socket.send( @buildCommand 0x05, data )
|
||||||
|
|
||||||
buildCommand: (hex, o) ->
|
buildCommand: (hex, o) ->
|
||||||
data = undefined
|
data = undefined
|
||||||
switch typeof o
|
switch typeof o
|
||||||
@ -139,7 +156,7 @@ class WVNC extends window.classes.BaseObject
|
|||||||
console.log "Error", dec.decode(data)
|
console.log "Error", dec.decode(data)
|
||||||
when 0x81
|
when 0x81
|
||||||
console.log "Request for password"
|
console.log "Request for password"
|
||||||
pass = "!x$@n9"
|
pass = "sang"
|
||||||
@socket.send (@buildCommand 0x02, pass)
|
@socket.send (@buildCommand 0x02, pass)
|
||||||
when 0x82
|
when 0x82
|
||||||
console.log "Request for login"
|
console.log "Request for login"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Generated by CoffeeScript 1.9.3
|
// Generated by CoffeeScript 1.12.7
|
||||||
(function() {
|
(function() {
|
||||||
var APIManager, BaseObject, MarkOn, WVNC, require,
|
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; },
|
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; },
|
||||||
@ -188,10 +188,18 @@
|
|||||||
return me.socket.close();
|
return me.socket.close();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return $("#connect").click(function(e) {
|
$("#connect").click(function(e) {
|
||||||
me.counter = 0;
|
me.counter = 0;
|
||||||
return me.openSession();
|
return me.openSession();
|
||||||
});
|
});
|
||||||
|
($(me.canvas)).css("cursor", "none");
|
||||||
|
return ($(me.canvas)).mousemove(function(e) {
|
||||||
|
var rect, x, y;
|
||||||
|
rect = me.canvas.getBoundingClientRect();
|
||||||
|
x = Math.floor(e.clientX - rect.left);
|
||||||
|
y = Math.floor(e.clientY - rect.top);
|
||||||
|
return me.sendPointEvent(x, y, 0);
|
||||||
|
});
|
||||||
})["catch"](function(m, s) {
|
})["catch"](function(m, s) {
|
||||||
return console.error(m, s);
|
return console.error(m, s);
|
||||||
});
|
});
|
||||||
@ -206,9 +214,6 @@
|
|||||||
ctx = this.buffer.getContext('2d');
|
ctx = this.buffer.getContext('2d');
|
||||||
data = ctx.createImageData(w, h);
|
data = ctx.createImageData(w, h);
|
||||||
ctx.putImageData(data, 0, 0);
|
ctx.putImageData(data, 0, 0);
|
||||||
this.callback = function() {
|
|
||||||
return me.draw();
|
|
||||||
};
|
|
||||||
return this.draw();
|
return this.draw();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -253,7 +258,7 @@
|
|||||||
if (!this.socket) {
|
if (!this.socket) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
scale = 0.75;
|
scale = 1.0;
|
||||||
w = this.buffer.width * scale;
|
w = this.buffer.width * scale;
|
||||||
h = this.buffer.height * scale;
|
h = this.buffer.height * scale;
|
||||||
this.canvas.width = w;
|
this.canvas.width = w;
|
||||||
@ -312,10 +317,24 @@
|
|||||||
|
|
||||||
WVNC.prototype.initConnection = function() {
|
WVNC.prototype.initConnection = function() {
|
||||||
var vncserver;
|
var vncserver;
|
||||||
vncserver = "localhost:5901";
|
vncserver = "192.168.1.8:5900";
|
||||||
return this.socket.send(this.buildCommand(0x01, vncserver));
|
return this.socket.send(this.buildCommand(0x01, vncserver));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WVNC.prototype.sendPointEvent = function(x, y, mask) {
|
||||||
|
var data;
|
||||||
|
if (!this.socket) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data = new Uint8Array(5);
|
||||||
|
data[0] = x & 0xFF;
|
||||||
|
data[1] = x >> 8;
|
||||||
|
data[2] = y & 0xFF;
|
||||||
|
data[3] = y >> 8;
|
||||||
|
data[4] = 0;
|
||||||
|
return this.socket.send(this.buildCommand(0x05, data));
|
||||||
|
};
|
||||||
|
|
||||||
WVNC.prototype.buildCommand = function(hex, o) {
|
WVNC.prototype.buildCommand = function(hex, o) {
|
||||||
var cmd, data;
|
var cmd, data;
|
||||||
data = void 0;
|
data = void 0;
|
||||||
@ -348,7 +367,7 @@
|
|||||||
return console.log("Error", dec.decode(data));
|
return console.log("Error", dec.decode(data));
|
||||||
case 0x81:
|
case 0x81:
|
||||||
console.log("Request for password");
|
console.log("Request for password");
|
||||||
pass = "!x$@n9";
|
pass = "sang";
|
||||||
return this.socket.send(this.buildCommand(0x02, pass));
|
return this.socket.send(this.buildCommand(0x02, pass));
|
||||||
case 0x82:
|
case 0x82:
|
||||||
console.log("Request for login");
|
console.log("Request for login");
|
||||||
|
@ -3,7 +3,7 @@ BaseController:subclass("WvncController", {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function WvncController:index( ... )
|
function WvncController:index( ... )
|
||||||
self.template:set("args", "['WVNC', 'wss://localhost:9195/wvnc', '#canvas']")
|
self.template:set("args", "['WVNC', 'wss://localhost:9192/wvnc', '#canvas']")
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user