如果消息发送成功,我想验证PDU,然后获取pdu.message_id
并将其存储在数据库中。
client.set_message_sent_handler(
lambda pdu: sys.stdout.write('sent {} {}\n'.format(pdu.sequence, pdu.message_id))
)
client.set_message_received_handler(
lambda pdu: sys.stdout.write('delivered {}\n'.format(pdu.receipted_message_id))
)
client.connect()
client.bind_transceiver(system_id='', password='')
parts, encoding_flag, msg_type_flag = smpplib.gsm.make_parts('Test message ID \n'+ msg_uuid.replace('-', '') +'\nTimestamp ' + str(datetime.now()) + '\n')
for part in parts:
pdu = client.send_message(
receipted_message_id=msg_uuid,
source_addr_ton=smpplib.consts.SMPP_TON_INTL,
source_addr_npi=smpplib.consts.SMPP_NPI_ISDN,
source_addr='PyTestSMPP',
dest_addr_ton=smpplib.consts.SMPP_TON_INTL,
dest_addr_npi=smpplib.consts.SMPP_NPI_ISDN,
destination_addr='0030...',
short_message=part,
data_coding=encoding_flag,
esm_class=msg_type_flag,
registered_delivery=True,
)
我是Python的新手,不确定如何验证消息是否已发送。
以及如何使pdu.message_id
超出此范围:
client.set_message_sent_handler(
lambda pdu: sys.stdout.write('sent {} {}\n'.format(pdu.sequence, pdu.message_id))
)