search

Home  >  Q&A  >  body text

java - How to force the app to go offline?

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

大家讲道理大家讲道理2738 days ago1410

reply all(6)I'll reply

  • 黄舟

    黄舟2017-06-28 09:25:31

    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

    reply
    0
  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-28 09:25:31

    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.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-28 09:25:31

    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?

    reply
    0
  • phpcn_u1582

    phpcn_u15822017-06-28 09:25:31

    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

    reply
    0
  • 阿神

    阿神2017-06-28 09:25:31

    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

    reply
    0
  • 迷茫

    迷茫2017-06-28 09:25:31

    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.

    reply
    0
  • Cancelreply