How to implement direct submission of data to the server when sending messages, instead of submitting data after the entire process is completed?