Fix repeat connection issue.
This commit is contained in:
parent
365f80444d
commit
71879a9efc
@ -32,6 +32,24 @@ impl Session {
|
||||
].concat()
|
||||
}
|
||||
|
||||
pub fn add_connection(&mut self, source:u8, id:u32)
|
||||
{
|
||||
let connections = match source {
|
||||
0 => &mut self.p_dawn.connections,
|
||||
1 => &mut self.p_dusk.connections,
|
||||
_ => &mut self.connections,
|
||||
};
|
||||
|
||||
for i in 0..connections.len() {
|
||||
if connections[i] == id {
|
||||
connections.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
connections.push(id);
|
||||
}
|
||||
|
||||
pub fn remove_connection(&mut self, source:u8, id:u32)
|
||||
{
|
||||
let connections = match source {
|
||||
|
@ -448,12 +448,7 @@ pub async fn thread_system(mut app:App, bus:Bus<protocol::QRPacket>)
|
||||
if let Some(conn) = app.connections.get_mut(qr.id as usize) {
|
||||
conn.session = Some(session.token);
|
||||
}
|
||||
match response.mode {
|
||||
0 => session.p_dawn.connections.push(qr.id),
|
||||
1 => session.p_dusk.connections.push(qr.id),
|
||||
2 => session.connections.push(qr.id),
|
||||
_ => { }
|
||||
}
|
||||
session.add_connection(response.mode, qr.id);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -493,10 +493,10 @@ const SCENES = {
|
||||
return true;
|
||||
},
|
||||
unload() {
|
||||
INTERFACE.uninit();
|
||||
MESSAGE_COMPOSE([
|
||||
PACK.u16(OpCode.SessionLeave),
|
||||
]);
|
||||
INTERFACE.uninit();
|
||||
},
|
||||
message(code, data) {
|
||||
switch(code) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user