In the development of real-time communication system based on XMPP protocol, it is necessary to send the language, in general we have two kinds of solutions,
1. Use the HTTP transport, transfer the recorded language file to the server, then generate the file directory, obtain the directory when another client requests it, and then download the voice file.
2. Encode the recorded voice using BASE64 encoding, then transfer the encoded result string as a normal text message, and client B is then removed from the server to decode
Base64 is one of the most common encoding for transmitting 8bit bytes of data on the network, and it can transmit longer identity information in an HTTP environment. Use of the environment, in the language chat, the longest can only record 60 seconds of language (also so designed), its size is about 20K, cooked words to kill chicken with slaughter sledgehammer, the use of file mode transmission will appear clumsy, and we change a method, the use of character transmission, directly encoded string as the message content transmission, This eliminates the work of the service side and makes full use of the XMPP protocol.
Implementation of the sending language function of IM based on XMPP