About the process and consumption of the server using GatewayWorker to push messages to C-sharp clients?

has not been actually developed yet, is the process like this

  1. the server socket, connected to the PC through Ip and port will get a client_id
  2. the PC side takes the client_id to request the server, and the server binds the obtained client_id with the user"s uid to generate channel, which is recorded in the database and returned to the PC side. The PC side has been listening to the channel. when the user is online
  3. .
  4. when the server wants to send an active push message, it finds out that the channel, of the user uses the GatewayClient call API to push the message from the database. When the user exits, it clears the channel from the database
  5. .

if the process is right,

  1. if there are a large number of users when connecting and exiting, frequent reading and writing to the database will certainly cause a burden on the database.
  2. when many users are online, they are listening to whether the socket, server can"t afford it

if the process is wrong, please give me some advice. Thank you so much!

Jun.30,2021

you can add a layer of redis between the server and the database to cache part of the traffic.
Visual observation that the PC side of an application like yours may connect, port and reconnect frequently. It is recommended to use redis to cache data such as client_id and channel.


1. PC side connects GatewayWorker (GatewayWorker through ip port without sending client_id to PC side.
2. PC side sends its unique identity to GatewayWorker
3. GatewayWorker uses Gateway::bindUid ($client_id, $uid) to bind $client_id corresponding socket to uid
4. After binding, set a $_ SESSION ['uid'] = $uid to record $client_id corresponding to uid
5. From this GatewayWorker directly uses Gateway::sendToUid ($uid,) to send messages to some PC side. The content of the message can be sent. No longer pay attention to client_id
6. After receiving the message from the PC side, GatewayWorker can use $_ SESSION ['uid'] to determine which PC side sent the message
7, and the rest is its own business logic

.

the above $uid is the unique identity of the client and is used to distinguish between different PC ends.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b317cb-2bd91.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b317cb-2bd91.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?