<s> from hazelcast . serialization . bits import * <EOL> from hazelcast . protocol . client_message import ClientMessage <EOL> from hazelcast . protocol . custom_codec import * <EOL> from hazelcast . util import ImmutableLazyDataList <EOL> from hazelcast . protocol . codec . map_message_type import * <EOL> from hazelcast . protocol . event_response_const import * <EOL> REQUEST_TYPE = MAP_ADDENTRYLISTENER <EOL> RESPONSE_TYPE = <NUM_LIT> <EOL> RETRYABLE = False <EOL> def calculate_size ( name , include_value , listener_flags , local_only ) : <EOL> """<STR_LIT>""" <EOL> data_size = <NUM_LIT:0> <EOL> data_size += calculate_size_str ( name ) <EOL> data_size += BOOLEAN_SIZE_IN_BYTES <EOL> data_size += INT_SIZE_IN_BYTES <EOL> data_size += BOOLEAN_SIZE_IN_BYTES <EOL> return data_size <EOL> def encode_request ( name , include_value , listener_flags , local_only ) : <EOL> """<STR_LIT>""" <EOL> client_message = ClientMessage ( payload_size = calculate_size ( name , include_value , listener_flags , local_only ) ) <EOL> client_message . set_message_type ( REQUEST_TYPE ) <EOL> client_message . set_retryable ( RETRYABLE ) <EOL> client_message . append_str ( name ) <EOL> client_message . append_bool ( include_value ) <EOL> client_message . append_int ( listener_flags ) <EOL> client_message . append_bool ( local_only ) <EOL> client_message . update_frame_length ( ) <EOL> return client_message <EOL> def decode_response ( client_message , to_object = None ) : <EOL> """<STR_LIT>""" <EOL> parameters = dict ( response = None ) <EOL> parameters [ '<STR_LIT>' ] = client_message . read_str ( ) <EOL> return parameters <EOL> def handle ( client_message , handle_event_entry = None , to_object = None ) : <EOL> """<STR_LIT>""" <EOL> message_type = client_message . get_message_type ( ) <EOL> if message_type == EVENT_ENTRY and handle_event_entry is not None : <EOL> key = None <EOL> if not client_message . read_bool ( ) : <EOL> key = client_message . read_data ( ) <EOL> value = None <EOL> if not client_message . read_bool ( ) : <EOL> value = client_message . read_data ( ) <EOL> old_value = None <EOL> if not client_message . read_bool ( ) : <EOL> old_value = client_message . read_data ( ) <EOL> merging_value = None <EOL> if not client_message . read_bool ( ) : <EOL> merging_value = client_message . read_data ( ) <EOL> event_type = client_message . read_int ( ) <EOL> uuid = client_message . read_str ( ) <EOL> number_of_affected_entries = client_message . read_int ( ) <EOL> handle_event_entry ( key = key , value = value , old_value = old_value , merging_value = merging_value , event_type = event_type , uuid = uuid , number_of_affected_entries = number_of_affected_entries ) </s>
