+ if proto_of_message(packet) == LOGIN.PROTO:
+ msg = parse_message(packet)
+ if isinstance(msg, LOGIN): # Can be unparseable
+ if clnt.imei is None:
+ clnt.imei = msg.imei
+ log.info(
+ "LOGIN from fd %d (IMEI %s)",
+ clnt.sock.fileno(),
+ clnt.imei,
+ )
+ oldclnt = self.by_imei.get(clnt.imei)
+ if oldclnt is not None:
+ log.info(
+ "Orphaning fd %d with the same IMEI",
+ oldclnt.sock.fileno(),
+ )
+ oldclnt.imei = None