Instant Messaging--Send Pictures

The above article finds out the process of video calling, and this record records the process of sending pictures.

The principle is much simpler than a video call.

  1. Sender A logs in and successfully establishes a socket connection with the server.
  2. Select the picture and click Finish, it will return to the chat interface, call the onActivityResult method, and then call the sendImage method. In this method, the sendImageMsg method is called first. In this method, the content to be sent is roughly encapsulated into an object, through socket.emit ("chat") event, which sends the content to the server and saves a copy locally for viewing the chat history.
  3. After the sending is complete, the local chat interface is updated.
  4. The server receives the image and processes it first, and saves a copy of the original image and the thumbnail image to the image folder of the server. Save the pictures using Imagemagic software. The Windows server used for testing needs to go to the official website to download the Windows version, download and install it. During the installation process, you need to tick the Install legacy utilities (eg convert) option, otherwise an error will be reported. After the installation is complete, you need to install images on the node terminal and run the command npm install images. After the installation is complete, it is ready to use.
  5. After the server processes the image, it starts to send a message to receiver B through the emit("chat") event.
  6. After receiver B receives the message, it saves the picture locally and updates the chat interface.
The picture process is basically relatively simple. This part is to pay attention to the installation and processing of the server software.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324746355&siteId=291194637