Skip to content

Commit

Permalink
bug fixing on unexpected packet sends
Browse files Browse the repository at this point in the history
  • Loading branch information
citronneur committed Jun 29, 2015
1 parent b0eb9fd commit 0bbdb27
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/protocol/rdp.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function RdpClient(config) {
//bind all events
var self = this;
this.global.on('connect', function () {
self.connected = true;
self.emit('connect');
}).on('session', function () {
self.emit('session');
Expand Down Expand Up @@ -116,7 +117,6 @@ RdpClient.prototype.connect = function (host, port) {
log.info('connect to ' + host + ':' + port);
var self = this;
this.bufferLayer.socket.connect(port, host, function () {
self.connected = true;
// in client mode connection start from x224 layer
self.x224.connect();
});
Expand All @@ -142,6 +142,8 @@ RdpClient.prototype.close = function () {
* @param isPressed {boolean} state of button
*/
RdpClient.prototype.sendPointerEvent = function (x, y, button, isPressed) {
if (!this.connected)
return;
var event = pdu.data.pointerEvent();
if (isPressed) {
event.obj.pointerFlags.value |= pdu.data.PointerFlag.PTRFLAGS_DOWN;
Expand Down Expand Up @@ -174,6 +176,8 @@ RdpClient.prototype.sendPointerEvent = function (x, y, button, isPressed) {
* @param extended {boolenan} extended keys
*/
RdpClient.prototype.sendKeyEventScancode = function (code, isPressed, extended) {
if (!this.connected)
return;
extended = extended || false;
var event = pdu.data.scancodeKeyEvent();
event.obj.keyCode.value = code;
Expand All @@ -182,7 +186,7 @@ RdpClient.prototype.sendKeyEventScancode = function (code, isPressed, extended)
event.obj.keyboardFlags.value |= pdu.data.KeyboardFlag.KBDFLAGS_RELEASE;
}

if (!extended) {
if (extended) {
event.obj.keyboardFlags.value |= pdu.data.KeyboardFlag.KBDFLAGS_EXTENDED;
}

Expand Down

0 comments on commit 0bbdb27

Please sign in to comment.