IM one-to-one chat, based on NodeJS +socket. IO +vue.js

Warehouse address: gitee.com/aYuan-git/i…

Project analysis

WebSocket is a protocol for full duplex communication over a single TCP connection provided by HTML5. In the WebSocket API, the browser and server only need to complete a handshake to create a persistent connection and two-way data transfer. Here said data transmission, we simply understand is “broadcast”. Broadcasting can be divided into broadcasting to everyone and broadcasting to individuals, which is simply known as “group chat” and “private chat”. The project is one to one chat, that is, “private chat”, if the socket IO are interested, you can refer to the following document: www.w3cschool.cn/socket/sock…

One-on-one chat

Each user connected to a socket server is an object, and they are unique. Since they are unique, there must be a unique ID, which is called socket.id. We only need to maintain a global object mapping between socket.ID and user name. Var hashName = {}

Project running

The app. Js, views/scripts/login. Js, views/scripts/index. The IP address of the js into its own IP address, and then open the powershell, type the command node app. Js can experience.

Project screenshots. The project is developed for mobile terminal, and mobile terminal experience is preferred