Skip to content

Instantly share code, notes, and snippets.

@ramonsaraiva ramonsaraiva/market.py Secret
Created May 5, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.