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