mirror of
https://github.com/Oibaf66/frodo-wii.git
synced 2024-11-14 07:35:12 +01:00
Handle disconnects at the broker side as well
This commit is contained in:
parent
8af1a6c773
commit
2a492b70b6
@ -158,9 +158,8 @@ void C64::network_vblank()
|
||||
|
||||
if (this->quit_thyself)
|
||||
{
|
||||
if (this->network_connection_type != CONNECT)
|
||||
remote->Disconnect();
|
||||
delete remote;
|
||||
remote->Disconnect();
|
||||
delete remote;
|
||||
this->network = NULL;
|
||||
TheC64->network_connection_type = NONE;
|
||||
|
||||
|
@ -195,6 +195,11 @@ class PingAckPacket(Packet):
|
||||
"""Create data representation of a packet"""
|
||||
return Packet.marshal(self) + struct.pack(">L", self.seq)
|
||||
|
||||
class DisconnectPacket(Packet):
|
||||
def __init__(self):
|
||||
Packet.__init__(self)
|
||||
self.type = DISCONNECT
|
||||
|
||||
|
||||
class SelectPeerPacket(Packet):
|
||||
def __init__(self):
|
||||
@ -507,6 +512,12 @@ class BrokerPacketHandler(SocketServer.DatagramRequestHandler):
|
||||
|
||||
peer = srv.get_peer(self.client_address)
|
||||
|
||||
# Handle disconnects by removing the peer and ignoring the rest
|
||||
if pkt.get_type() == DISCONNECT:
|
||||
log_info("Peer disconnected, removing")
|
||||
self.server.remove_peer(peer)
|
||||
return
|
||||
|
||||
try:
|
||||
peer.handle_packet(pkt)
|
||||
except Exception, e:
|
||||
@ -630,6 +641,7 @@ packet_class_by_type = {
|
||||
CONNECT_TO_BROKER : ConnectToBrokerPacket,
|
||||
SELECT_PEER : SelectPeerPacket,
|
||||
REGISTER_DATA : RegisterDataPacket,
|
||||
DISCONNECT : DisconnectPacket,
|
||||
ACK : PingAckPacket,
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user