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 {
|
||||
if let Some(kaksh_kunjika) = &msg.kaksh_kunjika {
|
||||
if let Some(kaksh) = self.kaksh.get_mut(kaksh_kunjika) {
|
||||
let name = if let Some(i) = kaksh.loog.iter().position(|x| x.addr == msg.addr) {
|
||||
kaksh.loog.remove(i).name
|
||||
} else { "".to_owned() };
|
||||
|
||||
if kaksh.loog.len() == 0 {
|
||||
self.kaksh.remove(kaksh_kunjika);
|
||||
} else {
|
||||
if kaksh.loog.len() > 1 {
|
||||
let name = if let Some(i) = kaksh.loog.iter().position(|x| x.addr == msg.addr) {
|
||||
kaksh.loog.remove(i).name
|
||||
} else { "".to_owned() };
|
||||
|
||||
kaksh.loog.iter().for_each(|a| {
|
||||
a.addr.do_send(ms::sansad::WsDisconnected {
|
||||
kunjika: msg.kunjika.to_owned(),
|
||||
name: name.to_owned()
|
||||
})
|
||||
});
|
||||
} else {
|
||||
self.kaksh.remove(kaksh_kunjika);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,9 +35,9 @@ const HEARTBEAT_INTERVAL: Duration = Duration::from_secs(5);
|
|||
const CLIENT_TIMEOUT: Duration = Duration::from_secs(15);
|
||||
|
||||
/// 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
|
||||
const SPECIAL_CLIENT_TIMEOUT: Duration = Duration::from_secs(15 * 60);
|
||||
const SPECIAL_CLIENT_TIMEOUT: Duration = Duration::from_secs(15*60);
|
||||
|
||||
pub struct WsSansad {
|
||||
kunjika: String,
|
||||
|
|
@ -66,7 +66,7 @@ impl Actor for WsSansad {
|
|||
|
||||
fn stopping(&mut self, _: &mut Self::Context) -> Running {
|
||||
tokio::runtime::Runtime::new().unwrap()
|
||||
.block_on(self.leave_kaksh());// notify leaving
|
||||
.block_on(self.leave_kaksh());// notify leaving
|
||||
Running::Stop
|
||||
}
|
||||
}
|
||||
|
|
@ -143,6 +143,7 @@ impl WsSansad {
|
|||
// don't try to send a ping
|
||||
return;
|
||||
}
|
||||
ctx.ping(b"");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,15 +42,13 @@ socket.onopen = function(event) {
|
|||
socket.onerror = function(event) {
|
||||
$('#initerror').text('Warning: Failed to connect websocket! Refresh the '+
|
||||
'page and if still don\'t work upgrade Web Browser');
|
||||
socket.close()
|
||||
}
|
||||
|
||||
socket.onclose = function (e) {
|
||||
if(actions.has_key('leave')) return;
|
||||
actions.clear();
|
||||
myinfo.kunjika = '';
|
||||
myinfo.name = '';
|
||||
State.login();
|
||||
State.hideProgress();
|
||||
Messages.pushStatus('Connection failed!\nRefresh page');
|
||||
$('[name="error_msg"]').text('Connection failed! Refresh page');
|
||||
$('[name="error_msg"]').removeClass('is-hidden');
|
||||
}
|
||||
|
||||
// Listen for messages
|
||||
|
|
|
|||
Loading…
Reference in New Issue