Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
N
noVNC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
noVNC
Commits
a4370793
Commit
a4370793
authored
Feb 04, 2015
by
Solly
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #427 from jswanner/register-listeners
Unregister event listeners from websock.
parents
e9f55ea0
155d78b3
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
+34
-0
rfb.js
include/rfb.js
+4
-0
websock.js
include/websock.js
+4
-0
test.rfb.js
tests/test.rfb.js
+26
-0
No files found.
include/rfb.js
View file @
a4370793
...
@@ -197,6 +197,7 @@ var RFB;
...
@@ -197,6 +197,7 @@ var RFB;
}
else
{
}
else
{
this
.
_fail
(
"Server disconnected"
+
msg
);
this
.
_fail
(
"Server disconnected"
+
msg
);
}
}
this
.
_sock
.
off
(
'close'
);
}.
bind
(
this
));
}.
bind
(
this
));
this
.
_sock
.
on
(
'error'
,
function
(
e
)
{
this
.
_sock
.
on
(
'error'
,
function
(
e
)
{
Util
.
Warn
(
"WebSocket on-error event"
);
Util
.
Warn
(
"WebSocket on-error event"
);
...
@@ -239,6 +240,9 @@ var RFB;
...
@@ -239,6 +240,9 @@ var RFB;
disconnect
:
function
()
{
disconnect
:
function
()
{
this
.
_updateState
(
'disconnect'
,
'Disconnecting'
);
this
.
_updateState
(
'disconnect'
,
'Disconnecting'
);
this
.
_sock
.
off
(
'error'
);
this
.
_sock
.
off
(
'message'
);
this
.
_sock
.
off
(
'open'
);
},
},
sendPassword
:
function
(
passwd
)
{
sendPassword
:
function
(
passwd
)
{
...
...
include/websock.js
View file @
a4370793
...
@@ -200,6 +200,10 @@ function Websock() {
...
@@ -200,6 +200,10 @@ function Websock() {
},
},
// Event Handlers
// Event Handlers
off
:
function
(
evt
)
{
this
.
_eventHandlers
[
evt
]
=
function
()
{};
},
on
:
function
(
evt
,
handler
)
{
on
:
function
(
evt
,
handler
)
{
this
.
_eventHandlers
[
evt
]
=
handler
;
this
.
_eventHandlers
[
evt
]
=
handler
;
},
},
...
...
tests/test.rfb.js
View file @
a4370793
...
@@ -62,6 +62,24 @@ describe('Remote Frame Buffer Protocol Client', function() {
...
@@ -62,6 +62,24 @@ describe('Remote Frame Buffer Protocol Client', function() {
expect
(
client
.
_updateState
).
to
.
have
.
been
.
calledOnce
;
expect
(
client
.
_updateState
).
to
.
have
.
been
.
calledOnce
;
expect
(
client
.
_updateState
).
to
.
have
.
been
.
calledWith
(
'disconnect'
);
expect
(
client
.
_updateState
).
to
.
have
.
been
.
calledWith
(
'disconnect'
);
});
});
it
(
'should unregister error event handler'
,
function
()
{
sinon
.
spy
(
client
.
_sock
,
'off'
);
client
.
disconnect
();
expect
(
client
.
_sock
.
off
).
to
.
have
.
been
.
calledWith
(
'error'
);
});
it
(
'should unregister message event handler'
,
function
()
{
sinon
.
spy
(
client
.
_sock
,
'off'
);
client
.
disconnect
();
expect
(
client
.
_sock
.
off
).
to
.
have
.
been
.
calledWith
(
'message'
);
});
it
(
'should unregister open event handler'
,
function
()
{
sinon
.
spy
(
client
.
_sock
,
'off'
);
client
.
disconnect
();
expect
(
client
.
_sock
.
off
).
to
.
have
.
been
.
calledWith
(
'open'
);
});
});
});
describe
(
'#sendPassword'
,
function
()
{
describe
(
'#sendPassword'
,
function
()
{
...
@@ -1710,6 +1728,14 @@ describe('Remote Frame Buffer Protocol Client', function() {
...
@@ -1710,6 +1728,14 @@ describe('Remote Frame Buffer Protocol Client', function() {
expect
(
client
.
_rfb_state
).
to
.
equal
(
'failed'
);
expect
(
client
.
_rfb_state
).
to
.
equal
(
'failed'
);
});
});
it
(
'should unregister close event handler'
,
function
()
{
sinon
.
spy
(
client
.
_sock
,
'off'
);
client
.
connect
(
'host'
,
8675
);
client
.
_rfb_state
=
'disconnect'
;
client
.
_sock
.
_websocket
.
close
();
expect
(
client
.
_sock
.
off
).
to
.
have
.
been
.
calledWith
(
'close'
);
});
// error events do nothing
// error events do nothing
});
});
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment