def read_notify_new_session(data): """Reads and parses a NNS ('Notify New Session') request.""" return { "user": read(data, "S", 0), "session_id": read(data, "S", 2), "clientContext": read_map(data, 4) }
def read_notify_user(data): """Reads and parses a NUS ('Notify User') request.""" return { "user": read(data, "S", 0), "password": read(data, "S", 2), "httpHeaders": read_map(data, 4) }
def read_notify_user_auth(data): """Reads and parses a NUA (extended version of 'Notify User', to carry identification data included in the client SSL certificate)) request. """ return {"user": read(data, "S", 0), "password": read(data, "S", 2), "clientPrincipal": read(data, "S", 4), "httpHeaders": read_map(data, 6)}
def _read_gcm_subscription_info(data, offset): num_of_data = int(read_token(data, offset)) map_start_idx = offset + 11 map_length = num_of_data * 4 return MpnGcmSubscriptionInfo( device=_read_mpn_device_info(data, offset + 1), trigger=read(data, "S", offset + 7), collapse_key=read(data, "S", offset + 9), data=read_map(data, map_start_idx, map_length), delay_while_idle=read(data, "S", map_start_idx + map_length), time_to_live=read(data, "S", map_start_idx + map_length + 2))
def _read_apn_subscription_info(data, offset): arg_length = int(read_token(data, offset)) arguments = read_seq(data, offset + 22, arg_length * 2) cust_data_size = int(read_token(data, offset + 1)) custom_data = read_map(data, offset + 22 + arg_length * 2, cust_data_size * 4) return MpnApnsSubscriptionInfo( device=_read_mpn_device_info(data, offset + 2), trigger=read(data, "S", offset + 8), sound=read(data, "S", offset + 10), badge=read(data, "S", offset + 12), localized_action_key=read(data, "S", offset + 14), launch_image=read(data, "S", offset + 16), txt_format=read(data, "S", offset + 18), localized_format_key=read(data, "S", offset + 20), arguments=arguments, custom_data=custom_data)
def read_init(data): """Reads and parses a MPI ('Metadata Init') request.""" return read_map(data, 0)