How to use swoole + js + redis to realize simple chat room
This article mainly introduces "how to use swoole + js + redis to achieve a simple chat room". In daily operation, I believe many people have doubts about how to use swoole + js + redis to achieve a simple chat room. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to use swoole + js + redis to achieve a simple chat room". Next, please follow the editor to study!
The company needs to use the online chat function, so first write a demo to show the effect.
The websocket,task of swoole and the string,hash,set,zet of redis are mainly used.
Chat room is divided into 10 channels, you can switch channels, channel counting and so on.
At present, the chat content has not been encrypted.
According to the demand, the chat content may retain the last 100 per channel, aes may be considered if the chat is encrypted, or it may not be added. It depends on the situation.
No exception handling has been done yet. It may be updated later after further improvement.
First put on the code, if you have any questions, you can leave a message to communicate. Here is the html code that can introduce its own jq address.
WebSocketTestPage