Read address from beacon message. If no address is specified then "nullable" WIPV4SocketInfo returns

		:param message: message to parse
		:param invert_hello: defines whether message header is the original one or reversed.
		:return: WIPV4SocketInfo
337954
def _message_address_parse(self, message, invert_hello=False):
		
		message_header = self.hello_message(invert_hello=invert_hello)

		if message[:len(message_header)] != message_header:
			raise ValueError('Invalid message header')

		message = message[len(message_header):]
		message_parts = message.split(WBeaconGouverneurMessenger.__message_splitter__)

		address = None
		port = None

		if len(message_parts) > 3:
			raise ValueError('Invalid message. Too many separators')
		elif len(message_parts) == 3:
			address = WIPV4SocketInfo.parse_address(message_parts[1].decode('ascii'))
			port = WIPPort(int(message_parts[2]))
		elif len(message_parts) == 2 and len(message_parts[1]) > 0:
			address = WIPV4SocketInfo.parse_address(message_parts[1].decode('ascii'))

		return WIPV4SocketInfo(address, port)
1066617
function readNotifyMpnDeviceTokenChange(message, tokens) {
	message.userName = protocol.decodeString(tokens[1]);
	message.sessionId = protocol.decodeString(tokens[3]);
	message.device = {};
	message.device.mpnPlatformType = protocol.decodeString(tokens[5]);
	message.device.applicationId = protocol.decodeString(tokens[7]);
	message.device.deviceToken = protocol.decodeString(tokens[9]);
	message.newDeviceToken = protocol.decodeString(tokens[11]);
}
733893
def parse_address(address: str) -> str:
    
    display_name, parsed_address = email.utils.parseaddr(address)

    return parsed_address or address
1088896
def targetHi(self):
        
        hi_byte = None
        if self.target.addr is not None and self._messageFlags.isBroadcast:
            hi_byte = self.target.bytes[2]
        return hi_byte
326200
public SIBusMessage peek() throws SISessionUnavailableException, SIIncorrectCallException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "peek", this);

    checkValidState("peek");

    localConsumerPoint.checkNotClosed();

    JsMessage jsMsg = null;

    synchronized(this)
    {
      if(!endReached)
      {
        // If currentMsg is null it means we start from the begining
        if(currentMsg == null)
        {
          if(firstMsg != null)
          {
            jsMsg = setPropertiesInMessage(firstMsg);
          }
        }
        else
        {
          if(currentMsg.next != null)
          {
            jsMsg = setPropertiesInMessage(currentMsg.next);
          }
        }
      }
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "peek", jsMsg);
    return jsMsg;
  }
571431
def get_mail_addresses(message, header_name):
    
    headers = [h for h in message.get_all(header_name, [])]
    addresses = email.utils.getaddresses(headers)

    for index, (address_name, address_email) in enumerate(addresses):
        addresses[index] = {'name': decode_mail_header(address_name),
                            'email': address_email}
        logger.debug("{} Mail address in message: <{}> {}".format(
            header_name.upper(), address_name, address_email))
    return addresses
319369
def parse_address(self, address, line_number=-1):
        
        return Address(address, self, line_number, self.logger)
734436
def hex(self):
        """"""
        props = self._message_properties()
        msg = bytearray([MESSAGE_START_CODE_0X02, self._code])

        for prop in props:
            # pylint: disable=unused-variable
            for key, val in prop.items():
                if val is None:
                    pass
                elif isinstance(val, int):
                    msg.append(val)
                elif isinstance(val, Address):
                    if val.addr is None:
                        pass
                    else:
                        msg.extend(val.bytes)
                elif isinstance(val, MessageFlags):
                    msg.extend(val.bytes)
                elif isinstance(val, bytearray):
                    msg.extend(val)
                elif isinstance(val, bytes):
                    msg.extend(val)
                elif isinstance(val, Userdata):
                    msg.extend(val.bytes)

        return binascii.hexlify(msg).decode()
836424
def hello_message(self, invert_hello=False):
		
		if invert_hello is False:
			return self.__gouverneur_message

		hello_message = []
		for i in range(len(self.__gouverneur_message) - 1, -1, -1):
			hello_message.append(self.__gouverneur_message[i])
		return bytes(hello_message)
1334742
def recv_message(self, debug=False):
        
        if debug:
            packet = self.sock.recv(1024)  # reads how many bytes to read
            hexdump(packet)

        packet_length_data = self.sock.recv(4)  # reads how many bytes to read

        if len(packet_length_data) < 4:
            raise Exception("Nothing in the socket!")
        packet_length = struct.unpack("<I", packet_length_data)[0]
        packet = self.sock.recv(packet_length - 4)  # read the rest of bytes from socket

        # check the CRC32
        if not crc32(packet_length_data + packet[0:-4]) == struct.unpack('<I', packet[-4:])[0]:
            raise Exception("CRC32 was not correct!")
        x = struct.unpack("<I", packet[:4])
        auth_key_id = packet[4:12]
        if auth_key_id == b'\x00\x00\x00\x00\x00\x00\x00\x00':
            # No encryption - Plain text
            (message_id, message_length) = struct.unpack("<QI", packet[12:24])
            data = packet[24:24+message_length]
        elif auth_key_id == self.auth_key_id:
            pass
            message_key = packet[12:28]
            encrypted_data = packet[28:-4]
            aes_key, aes_iv = self.aes_calculate(message_key, direction="from server")
            decrypted_data = crypt.ige_decrypt(encrypted_data, aes_key, aes_iv)
            assert decrypted_data[0:8] == self.server_salt
            assert decrypted_data[8:16] == self.session_id
            message_id = decrypted_data[16:24]
            seq_no = struct.unpack("<I", decrypted_data[24:28])[0]
            message_data_length = struct.unpack("<I", decrypted_data[28:32])[0]
            data = decrypted_data[32:32+message_data_length]
        else:
            raise Exception("Got unknown auth_key id")
        return data
922075
def parse_socket_info(cls, info):
		
		info = info.split(':')
		if len(info) > 2:
			raise ValueError('Incorrect socket info specified')
		address = info[0].strip()
		port = int(info[1].strip()) if len(info) == 2 else None
		return WIPV4SocketInfo(address=address, port=port)
1292729
def recv_msg(self, connection):
        
        # Read message length and unpack it into an integer
        raw_msglen = self.__recvall(connection, 4, decode_json=False)
        if not raw_msglen:
            return None
        msglen = struct.unpack('>I', raw_msglen)[0]
        # Read the message data
        return self.__recvall(connection, msglen)
667353
def on_hello(self, message):
        

        logger.info("Got a hello")
        self.identify(self.token)
        self.heartbeat_thread = Heartbeat(self.ws,
                                          message['d']['heartbeat_interval'])
        self.heartbeat_thread.start()
        return
978169
def parse_hash(address):
    '''
    
    '''

    raw = parse(address)

    # Cash addresses
    try:
        if address.find(riemann.network.CASHADDR_PREFIX) == 0:
            if raw.find(riemann.network.CASHADDR_P2SH) == 0:
                return raw[len(riemann.network.CASHADDR_P2SH):]
            if raw.find(riemann.network.CASHADDR_P2PKH) == 0:
                return raw[len(riemann.network.CASHADDR_P2PKH):]
    except TypeError:
        pass

    # Segwit addresses
    try:
        if address.find(riemann.network.BECH32_HRP) == 0:
            if raw.find(riemann.network.P2WSH_PREFIX) == 0:
                return raw[len(riemann.network.P2WSH_PREFIX):]
            if raw.find(riemann.network.P2WPKH_PREFIX) == 0:
                return raw[len(riemann.network.P2WPKH_PREFIX):]
    except TypeError:
        pass

    # Legacy Addresses
    if raw.find(riemann.network.P2SH_PREFIX) == 0:
        return raw[len(riemann.network.P2SH_PREFIX):]
    if raw.find(riemann.network.P2PKH_PREFIX) == 0:
        return raw[len(riemann.network.P2PKH_PREFIX):]
357776
def messageReceived(self, value, sender, target):
        
        if value.type != AMP_MESSAGE_TYPE:
            raise UnknownMessageType()
        inputBox = self._boxFromData(value.data)
        thunk = commandMethod.responderForName(self, inputBox[COMMAND])
        placeholder = _ProtocolPlaceholder(sender, target)
        arguments = thunk.command.parseArguments(inputBox, placeholder)
        try:
            result = thunk(**arguments)
        except tuple(thunk.command.errors.keys()), knownError:
            errorCode = thunk.command.errors[knownError.__class__]
            raise RevertAndRespond(
                Value(AMP_ANSWER_TYPE,
                         Box(_error_code=errorCode,
                             _error_description=str(knownError)).serialize()))
        else:
            response = thunk.command.makeResponse(result, None)
            return Value(AMP_ANSWER_TYPE, response.serialize())
852013
def _read_message(self):
        
        # first 4 bytes is Big-Endian payload length
        payload_info = self._read_bytes_from_socket(4)
        read_len = unpack(">I", payload_info)[0]

        # now read the payload
        payload = self._read_bytes_from_socket(read_len)

        # pylint: disable=no-member
        message = cast_channel_pb2.CastMessage()
        message.ParseFromString(payload)

        return message
372204
def valid_response(self, beacon_config, response, server_address):
		
		try:
			self._message_address_parse(response, invert_hello=self.__invert_hello)
			return True
		except ValueError:
			pass
		return False