diff --git a/apps/assets/coffee/WVNC.coffee b/apps/assets/coffee/WVNC.coffee index b82ea89..f828f5b 100644 --- a/apps/assets/coffee/WVNC.coffee +++ b/apps/assets/coffee/WVNC.coffee @@ -16,6 +16,12 @@ class WVNC extends window.classes.BaseObject $("#connect").click (e) -> me.counter = 0 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) -> console.error(m, s) @@ -27,8 +33,8 @@ class WVNC extends window.classes.BaseObject ctx = @buffer.getContext('2d') data = ctx.createImageData w, h ctx.putImageData data, 0, 0 - @callback = () -> - me.draw() + #@callback = () -> + # me.draw() @draw() updateCanvas: (x, y, w, h, pixels) -> @@ -38,10 +44,10 @@ class WVNC extends window.classes.BaseObject imgData.data.set @getCanvasImageData(pixels, w, h) ctx.putImageData imgData, x, y @counter = @counter + 1 - #@draw() - if @counter > 50 - @draw() - @couter = 0 + @draw() + #if @counter > 50 + # @draw() + # @couter = 0 getCanvasImageData: (pixels, w, h) -> return pixels if @depth is 32 @@ -61,7 +67,7 @@ class WVNC extends window.classes.BaseObject draw: () -> if not @socket return - scale = 0.75 + scale = 1.0 w = @buffer.width * scale h = @buffer.height * scale @canvas.width = w @@ -108,9 +114,20 @@ class WVNC extends window.classes.BaseObject console.log "socket closed" initConnection: () -> - vncserver = "localhost:5901" + vncserver = "192.168.1.8:5900" @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) -> data = undefined switch typeof o @@ -139,7 +156,7 @@ class WVNC extends window.classes.BaseObject console.log "Error", dec.decode(data) when 0x81 console.log "Request for password" - pass = "!x$@n9" + pass = "sang" @socket.send (@buildCommand 0x02, pass) when 0x82 console.log "Request for login" diff --git a/apps/assets/scripts/main.js b/apps/assets/scripts/main.js index f864385..6caf93a 100644 --- a/apps/assets/scripts/main.js +++ b/apps/assets/scripts/main.js @@ -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; }, @@ -188,10 +188,18 @@ return me.socket.close(); } }); - return $("#connect").click(function(e) { + $("#connect").click(function(e) { me.counter = 0; 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) { return console.error(m, s); }); @@ -206,9 +214,6 @@ ctx = this.buffer.getContext('2d'); data = ctx.createImageData(w, h); ctx.putImageData(data, 0, 0); - this.callback = function() { - return me.draw(); - }; return this.draw(); }; @@ -253,7 +258,7 @@ if (!this.socket) { return; } - scale = 0.75; + scale = 1.0; w = this.buffer.width * scale; h = this.buffer.height * scale; this.canvas.width = w; @@ -312,10 +317,24 @@ WVNC.prototype.initConnection = function() { var vncserver; - vncserver = "localhost:5901"; + vncserver = "192.168.1.8:5900"; 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) { var cmd, data; data = void 0; @@ -348,7 +367,7 @@ return console.log("Error", dec.decode(data)); case 0x81: console.log("Request for password"); - pass = "!x$@n9"; + pass = "sang"; return this.socket.send(this.buildCommand(0x02, pass)); case 0x82: console.log("Request for login"); diff --git a/apps/controllers/WvncController.lua b/apps/controllers/WvncController.lua index ec38ddb..2e4dc91 100644 --- a/apps/controllers/WvncController.lua +++ b/apps/controllers/WvncController.lua @@ -3,7 +3,7 @@ BaseController:subclass("WvncController", { }) 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 end