mirror of https://github.com/PiyushXCoder/lupt.git
fixes for kickout
This commit is contained in:
parent
59a9863838
commit
784b0f2017
|
|
@ -282,19 +282,19 @@ impl Handler<ms::pind::LeaveVayakti> for ChatPinnd {
|
||||||
fn handle(&mut self, msg: ms::pind::LeaveVayakti, _: &mut Self::Context) -> Self::Result {
|
fn handle(&mut self, msg: ms::pind::LeaveVayakti, _: &mut Self::Context) -> Self::Result {
|
||||||
if let Some(kaksh_kunjika) = &msg.kaksh_kunjika {
|
if let Some(kaksh_kunjika) = &msg.kaksh_kunjika {
|
||||||
if let Some(kaksh) = self.kaksh.get_mut(kaksh_kunjika) {
|
if let Some(kaksh) = self.kaksh.get_mut(kaksh_kunjika) {
|
||||||
|
if kaksh.loog.len() > 1 {
|
||||||
let name = if let Some(i) = kaksh.loog.iter().position(|x| x.addr == msg.addr) {
|
let name = if let Some(i) = kaksh.loog.iter().position(|x| x.addr == msg.addr) {
|
||||||
kaksh.loog.remove(i).name
|
kaksh.loog.remove(i).name
|
||||||
} else { "".to_owned() };
|
} else { "".to_owned() };
|
||||||
|
|
||||||
if kaksh.loog.len() == 0 {
|
|
||||||
self.kaksh.remove(kaksh_kunjika);
|
|
||||||
} else {
|
|
||||||
kaksh.loog.iter().for_each(|a| {
|
kaksh.loog.iter().for_each(|a| {
|
||||||
a.addr.do_send(ms::sansad::WsDisconnected {
|
a.addr.do_send(ms::sansad::WsDisconnected {
|
||||||
kunjika: msg.kunjika.to_owned(),
|
kunjika: msg.kunjika.to_owned(),
|
||||||
name: name.to_owned()
|
name: name.to_owned()
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
self.kaksh.remove(kaksh_kunjika);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);
|
||||||
const CLIENT_TIMEOUT: Duration = Duration::from_secs(15);
|
const CLIENT_TIMEOUT: Duration = Duration::from_secs(15);
|
||||||
|
|
||||||
/// How often heartbeat pings are sent
|
/// How often heartbeat pings are sent
|
||||||
const SPECIAL_HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5 * 60);
|
const SPECIAL_HEARTBEAT_INTERVAL: Duration = Duration::from_secs(3*60);
|
||||||
/// How long before lack of client response causes a timeout
|
/// How long before lack of client response causes a timeout
|
||||||
const SPECIAL_CLIENT_TIMEOUT: Duration = Duration::from_secs(15*60);
|
const SPECIAL_CLIENT_TIMEOUT: Duration = Duration::from_secs(15*60);
|
||||||
|
|
||||||
|
|
@ -143,6 +143,7 @@ impl WsSansad {
|
||||||
// don't try to send a ping
|
// don't try to send a ping
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
ctx.ping(b"");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,15 +42,13 @@ socket.onopen = function(event) {
|
||||||
socket.onerror = function(event) {
|
socket.onerror = function(event) {
|
||||||
$('#initerror').text('Warning: Failed to connect websocket! Refresh the '+
|
$('#initerror').text('Warning: Failed to connect websocket! Refresh the '+
|
||||||
'page and if still don\'t work upgrade Web Browser');
|
'page and if still don\'t work upgrade Web Browser');
|
||||||
|
socket.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
socket.onclose = function (e) {
|
socket.onclose = function (e) {
|
||||||
if(actions.has_key('leave')) return;
|
Messages.pushStatus('Connection failed!\nRefresh page');
|
||||||
actions.clear();
|
$('[name="error_msg"]').text('Connection failed! Refresh page');
|
||||||
myinfo.kunjika = '';
|
$('[name="error_msg"]').removeClass('is-hidden');
|
||||||
myinfo.name = '';
|
|
||||||
State.login();
|
|
||||||
State.hideProgress();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen for messages
|
// Listen for messages
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue