Client app redis nodejs push message?

  node.js, question

At present, my needs are as follows:
The client app (currently only ios app) is ready to connect to the server through a long connection.
I have already looked up the relevant materials. swoole workerman in php feels that the two difficulties are a bit too big, and it feels that it is too difficult to be familiar with the socket bottom layer. After reading nodejs, I feel that this should be implemented. Today I read nodejs and want to use the form of his tcp protocol. For the time being, I will not consider the web browser side. The code is as follows:

var net = require('net');
 var server = net.createServer(function(connection) {
 console.log('client connected');
 connection.on('end', function() {
 Log ('client closes connection');
 });
 connection.on('data' , function(data){
 var strData = data.toString();
 var strSign = strData.substr(0, 32);
 var strJson = strData.substr(32);
 get_redis_data();
 Log (strugn plus "-"plus strJson);
 });
 
 connection.write('Hello World!  \r\n');
 connection.pipe(connection);
 });
 server.listen(8080, function() {
 console.log('server is listening');
 });

The above code only uses the net module of nodejs to realize that a client connects to the server. the client needs to trigger an action to send a message to the server before the server returns the message to the client. then the problem arises. .
1: What I want to realize now is that after the client user logs in, tcp connection will be made. After the client logs in, there will be an encrypted uid parameter, and I will push messages according to this encrypted uid (inquire whether the current user has any new messages)
2: At present, this message is ready to be implemented by redis. Then the problem arises. How does redis save this message? After looking at the queue redis can use, string, etc. However, the problem is, after sending the message to the user, what if the message has been read? ? ? How to choose a suitable format for storing messages? ?

Please, great gods, not stint. . .
Also note my server configuration:
*8 Central Processor, stone
Memory: 8G
Hard disk: solid state disk
Bandwidth: 4M of public network
The service currently installed inside is web service, and the database service is on another one.*
Under Remarks:
-Is there a ready-made open platform to realize what I said above? . . . . . (It doesn’t matter if you need to pay), it is actually a summary of one sentence. The client and the server maintain a long connection and need to push messages to the client.

Your question is how to save the message in Redis. According to your needs, you need to be able to push the list and save the unread status at the same time.
My plan is to separate the push message list from the message list, that is, each user saves a list of messages that need to be pushed and a list of historical messages for that user.
There is no need to save any state for the message push list, and it will be removed from the list after the push has passed. Regardless of whether the user reads it or not, the message will be added to the user’s historical message list at the same time of pushing and sending. Here, the read state of the message can be saved.
Queue is not recommended for historical message list. It is recommended to save it in two data structures. Since the message list is displayed according to the time sequence, the ordered list of redis can be used, with a score of time stamp. The ordered list is used to save the user’s message list (only ID is saved, which is convenient for query and paging). Then the specific information of the message, such as content, read status, time, sender, etc., is saved in a hash structure, and key is the message ID.


Please correct me.