implement client reconnect; remove some old code
This commit is contained in:
@ -52,6 +52,7 @@ var waterfall_setup_done=0;
|
||||
var waterfall_queue = [];
|
||||
var waterfall_timer;
|
||||
var secondary_fft_size;
|
||||
var audio_allowed;
|
||||
|
||||
/*function fade(something,from,to,time_ms,fps)
|
||||
{
|
||||
@ -1181,6 +1182,9 @@ function on_ws_recv(evt)
|
||||
max_clients_num = config.max_clients;
|
||||
waterfall_init();
|
||||
audio_preinit();
|
||||
|
||||
if (audio_allowed) audio_init();
|
||||
waterfall_clear();
|
||||
break;
|
||||
case "secondary_config":
|
||||
window.secondary_fft_size = json.value.secondary_fft_size;
|
||||
@ -1263,119 +1267,6 @@ function on_ws_recv(evt)
|
||||
console.warn('unknown type of binary message: ' + type)
|
||||
}
|
||||
}
|
||||
return
|
||||
if(!(evt.data instanceof ArrayBuffer)) { divlog("on_ws_recv(): Not ArrayBuffer received...",1); return; }
|
||||
//
|
||||
debug_ws_data_received+=evt.data.byteLength/1000;
|
||||
first4Chars=getFirstChars(evt.data,4);
|
||||
first3Chars=first4Chars.slice(0,3);
|
||||
if(first3Chars=="CLI")
|
||||
{
|
||||
|
||||
}
|
||||
if(first3Chars=="AUD")
|
||||
{
|
||||
var audio_data;
|
||||
if(audio_compression=="adpcm") audio_data=new Uint8Array(evt.data,4)
|
||||
else audio_data=new Int16Array(evt.data,4);
|
||||
audio_prepare(audio_data);
|
||||
audio_buffer_current_size_debug+=audio_data.length;
|
||||
audio_buffer_all_size_debug+=audio_data.length;
|
||||
if(!(ios||is_chrome) && (audio_initialized==0 && audio_prepared_buffers.length>audio_buffering_fill_to)) audio_init()
|
||||
}
|
||||
else if(first3Chars=="FFT")
|
||||
{
|
||||
//alert("Yupee! Doing FFT");
|
||||
//if(first4Chars=="FFTS") console.log("FFTS");
|
||||
if(fft_compression=="none") waterfall_add_queue(new Float32Array(evt.data,4));
|
||||
else if(fft_compression="adpcm")
|
||||
{
|
||||
fft_codec.reset();
|
||||
|
||||
var waterfall_i16=fft_codec.decode(new Uint8Array(evt.data,4));
|
||||
var waterfall_f32=new Float32Array(waterfall_i16.length-COMPRESS_FFT_PAD_N);
|
||||
for(var i=0;i<waterfall_i16.length;i++) waterfall_f32[i]=waterfall_i16[i+COMPRESS_FFT_PAD_N]/100;
|
||||
if(first4Chars=="FFTS") secondary_demod_waterfall_add_queue(waterfall_f32); //TODO digimodes
|
||||
else waterfall_add_queue(waterfall_f32);
|
||||
}
|
||||
}
|
||||
else if(first3Chars=="DAT")
|
||||
{
|
||||
//secondary_demod_push_binary_data(new Uint8Array(evt.data,4));
|
||||
secondary_demod_push_data(arrayBufferToString(evt.data).substring(4));
|
||||
//console.log("DAT");
|
||||
}
|
||||
else if(first3Chars=="MSG")
|
||||
{
|
||||
/*try
|
||||
{*/
|
||||
var stringData=arrayBufferToString(evt.data);
|
||||
params=stringData.substring(4).split(" ");
|
||||
for(i=0;i<params.length;i++)
|
||||
{
|
||||
param=params[i].split("=");
|
||||
switch(param[0])
|
||||
{
|
||||
case "setup":
|
||||
waterfall_init();
|
||||
audio_preinit();
|
||||
break;
|
||||
case "bandwidth":
|
||||
bandwidth=parseInt(param[1]);
|
||||
break;
|
||||
case "center_freq":
|
||||
center_freq=parseInt(param[1]); //there was no ; and it was no problem... why?
|
||||
break;
|
||||
case "fft_size":
|
||||
fft_size=parseInt(param[1]);
|
||||
break;
|
||||
case "secondary_fft_size":
|
||||
secondary_fft_size=parseInt(param[1]);
|
||||
break;
|
||||
case "secondary_setup":
|
||||
secondary_demod_init_canvases();
|
||||
break;
|
||||
case "if_samp_rate":
|
||||
if_samp_rate=parseInt(param[1]);
|
||||
break;
|
||||
case "secondary_bw":
|
||||
secondary_bw=parseFloat(param[1]);
|
||||
break;
|
||||
case "fft_fps":
|
||||
fft_fps=parseInt(param[1]);
|
||||
break;
|
||||
case "audio_compression":
|
||||
audio_compression=param[1];
|
||||
divlog( "Audio stream is "+ ((audio_compression=="adpcm")?"compressed":"uncompressed")+"." )
|
||||
break;
|
||||
case "fft_compression":
|
||||
fft_compression=param[1];
|
||||
divlog( "FFT stream is "+ ((fft_compression=="adpcm")?"compressed":"uncompressed")+"." )
|
||||
break;
|
||||
case "cpu_usage":
|
||||
var server_cpu_usage=parseInt(param[1]);
|
||||
progressbar_set(e("openwebrx-bar-server-cpu"),server_cpu_usage/100,"Server CPU ["+param[1]+"%]",server_cpu_usage>85);
|
||||
break;
|
||||
case "clients":
|
||||
var clients_num=parseInt(param[1]);
|
||||
progressbar_set(e("openwebrx-bar-clients"),clients_num/max_clients_num,"Clients ["+param[1]+"]",clients_num>max_clients_num*0.85);
|
||||
break;
|
||||
case "max_clients":
|
||||
max_clients_num=parseInt(param[1]);
|
||||
break;
|
||||
case "s":
|
||||
smeter_level=parseFloat(param[1]);
|
||||
setSmeterAbsoluteValue(smeter_level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*}
|
||||
catch(err)
|
||||
{
|
||||
divlog("Received invalid message over WebSocket.");
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function add_problem(what)
|
||||
@ -1799,7 +1690,9 @@ function on_ws_closed()
|
||||
audio_node.disconnect();
|
||||
}
|
||||
catch (dont_care) {}
|
||||
divlog("WebSocket has closed unexpectedly. Please reload the page.", 1);
|
||||
divlog("WebSocket has closed unexpectedly. Attempting to reconnect in 5 seconds...", 1);
|
||||
|
||||
setTimeout(open_websocket, 5000);
|
||||
}
|
||||
|
||||
function on_ws_error(event)
|
||||
@ -2316,6 +2209,7 @@ function iosPlayButtonClick()
|
||||
audio_init();
|
||||
e("openwebrx-big-grey").style.opacity=0;
|
||||
window.setTimeout(function(){ e("openwebrx-big-grey").style.display="none"; },1100);
|
||||
audio_allowed = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user