For example, if the web side deletes the user who is logging in on the app side, how can the app side user be forced to log off? What method can be used on the web side to achieve this effect? javaweb
For example: The app needs a token to log in and push messages. After the app receives the push message, the code executes the behavior of clearing the token, causing the token to become invalid and forced to exit
This needs to be processed by the App and the background together. First, write the processing behavior of the token invalid App on the app side, whether to jump to the login interface, kill the app or delete some local files. Next is how to let the app obtain the token invalidation information. One is to push the message in the background as mentioned above, and the other is to change the token information in the background. The app accesses the background again and finds that the token is invalid. For the backend, the former is active and the latter is passive. If you require the App to be notified immediately, it is obviously the former. If the notification time is not sensitive, you can use the latter. Generally speaking, users' access to the network when operating apps is still very intensive. Using the latter is simple and convenient, and the time delay is not that big.
You can use socket.io to have a long connection and two-way communication. The server sends a message to the client. The client receives the message and exits to the login interface
First of all, you need to understand the meaning of your task’s app being offline. 1. It directly forces the app to return to the login interface. This time the login is invalid. 2. The app page is retained, but if any operations or network-related operations continue, it will be taken offline. The first situation is more complicated, because you execute it immediately, so the most appropriate thing is to use push. The web side pushes to specific users, and the app itself has already written the corresponding behavior for the specific push. In the second case, you only need to invalidate your token verification on the web side. Under normal circumstances, each user's token will retain an expiration time on the web side. You only need to invalidate this expiration time immediately. , then your app has corresponding request processing. When the token expires, it will be transferred to the login page to log in again
There is generally no need to log off in real time. When the user operates the app and the app sends a request to the server, the server returns the corresponding information, and then the app responds and exits.
For example: The app needs a token to log in and push messages. After the app receives the push message, the code executes the behavior of clearing the token, causing the token to become invalid and forced to exit
This needs to be processed by the App and the background together. First, write the processing behavior of the token invalid App on the app side, whether to jump to the login interface, kill the app or delete some local files. Next is how to let the app obtain the token invalidation information. One is to push the message in the background as mentioned above, and the other is to change the token information in the background. The app accesses the background again and finds that the token is invalid. For the backend, the former is active and the latter is passive. If you require the App to be notified immediately, it is obviously the former. If the notification time is not sensitive, you can use the latter. Generally speaking, users' access to the network when operating apps is still very intensive. Using the latter is simple and convenient, and the time delay is not that big.
For server-side control, when the app calls the interface, it clearly returns that the user is offline, and then the app exits to the login interface?
You can use socket.io to have a long connection and two-way communication. The server sends a message to the client. The client receives the message and exits to the login interface
First of all, you need to understand the meaning of your task’s app being offline.
1. It directly forces the app to return to the login interface. This time the login is invalid.
2. The app page is retained, but if any operations or network-related operations continue, it will be taken offline.
The first situation is more complicated, because you execute it immediately, so the most appropriate thing is to use push. The web side pushes to specific users, and the app itself has already written the corresponding behavior for the specific push.
In the second case, you only need to invalidate your token verification on the web side. Under normal circumstances, each user's token will retain an expiration time on the web side. You only need to invalidate this expiration time immediately. , then your app has corresponding request processing. When the token expires, it will be transferred to the login page to log in again
There is generally no need to log off in real time.
When the user operates the app and the app sends a request to the server, the server returns the corresponding information, and then the app responds and exits.