-
-
Save ramonsaraiva/6d0c98c48f9fe5d6d480208e21490332 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def market_parse_loop(sock): | |
while True: | |
data = receive_data(sock) | |
string_data = unpack_string(data['payload'])[0] | |
multiple_auctions_init = unpack_string(data['payload'][44:55])[0] | |
market_init = '\xf3\x03\x43\x00\x00\x2a\x00\x01\x00\x79\x00' | |
if market_init not in string_data: | |
continue | |
if multiple_auctions_init != market_init: | |
check_one_auction(string_data) | |
continue | |
nof_packets = struct.unpack('!I', data['payload'][28:32])[0] | |
more_packets = True | |
more_packets_id = '\xa4' # 19 | |
count = 1 | |
buff = unpack_string(data['payload'][59:])[0] | |
while more_packets and count < nof_packets: | |
data = receive_data(sock) | |
received_id = unpack_string(data['payload'][19])[0] | |
received_count = struct.unpack('!I', data['payload'][32:36])[0] | |
if more_packets_id != received_id and count != received_count: | |
continue | |
count = count + 1 | |
append = unpack_string(data['payload'][44:])[0] | |
buff = buff + append | |
if more_packets_id != received_id: | |
more_packets = False | |
auctions_serialized = re.findall('\{[^\{\}]*\}', buff) | |
resolve_auctions(auctions_serialized) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment