Commit 24a619ae by Sheng

Check wssh is connected before connecting

parent a5d3cbfe
__version_info__ = (0, 3, 4) __version_info__ = (0, 3, 5)
__version__ = '.'.join(map(str, __version_info__)) __version__ = '.'.join(map(str, __version_info__))
...@@ -8,6 +8,7 @@ jQuery(function($){ ...@@ -8,6 +8,7 @@ jQuery(function($){
var status = $('#status'), var status = $('#status'),
btn = $('.btn-primary'), btn = $('.btn-primary'),
style = {}, style = {},
connected = false,
key_max_size = 16384, key_max_size = 16384,
form_id = '#connect', form_id = '#connect',
names = ['hostname', 'port', 'username', 'password'], names = ['hostname', 'port', 'username', 'password'],
...@@ -208,6 +209,7 @@ jQuery(function($){ ...@@ -208,6 +209,7 @@ jQuery(function($){
$('.container').hide(); $('.container').hide();
term.open(terminal, true); term.open(terminal, true);
term.toggleFullscreen(true); term.toggleFullscreen(true);
connected = true;
}; };
sock.onmessage = function(msg) { sock.onmessage = function(msg) {
...@@ -241,6 +243,7 @@ jQuery(function($){ ...@@ -241,6 +243,7 @@ jQuery(function($){
reset_wssh(); reset_wssh();
$('.container').show(); $('.container').show();
status.text(e.reason); status.text(e.reason);
connected = false;
}; };
$(window).resize(function(){ $(window).resize(function(){
...@@ -252,6 +255,11 @@ jQuery(function($){ ...@@ -252,6 +255,11 @@ jQuery(function($){
function connect() { function connect() {
if (connected) {
console.log('This client was already connected.');
return;
}
var form = document.querySelector(form_id), var form = document.querySelector(form_id),
url = form.action, url = form.action,
data = new FormData(form), data = new FormData(form),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment