There are two types of solutions. The first type is proactive. When your second client logs in, the first client is notified to log out. This requires a long connection between the client and the server. The second type is passive. When the client logs in, it will obtain a token, and every subsequent operation will bring the token. The token will be updated each time it logs in. Therefore, when the second logs in, the token of the first login will be used. It will be invalid, log out at this time
You can integrate third parties such as Huanxin, which has a kick-out function for repeated logins. However, if it is just for this function, it is not necessary. It is better to design it through the interface.
If you are chatting, it is a long connection, and the server can actively disconnect the user. Like QQ If it is just for ordinary functions, tokens are used to squeeze out the other party's offline, but this must request the network interface to be effective. Generally, the interface design, each request head Zhongdu brings token information, but you can also send it directly to the client through push messages to prompt you to go offline.
If you do it yourself, use a custom message notification. When an account has been logged in and another device logs in to the account again, let the server send a notification to the first device. The device can log out after receiving the notification. If you are using third-party instant messaging, it is relatively simple. After the account is logged in, the instant messaging will have a monitoring method. Just perform operations in this method
Generally, one account is not allowed to be logged in on two mobile phones. Unless there are special needs, you can go to the mobile phone device parameters for unique verification as account parameters
There are two types of solutions. The first type is proactive. When your second client logs in, the first client is notified to log out. This requires a long connection between the client and the server.
The second type is passive. When the client logs in, it will obtain a token, and every subsequent operation will bring the token. The token will be updated each time it logs in. Therefore, when the second logs in, the token of the first login will be used. It will be invalid, log out at this time
You can integrate third parties such as Huanxin, which has a kick-out function for repeated logins. However, if it is just for this function, it is not necessary. It is better to design it through the interface.
If you are chatting, it is a long connection, and the server can actively disconnect the user. Like QQ
If it is just for ordinary functions, tokens are used to squeeze out the other party's offline, but this must request the network interface to be effective. Generally, the interface design, each request head Zhongdu brings token information, but you can also send it directly to the client through push messages to prompt you to go offline.
If you do it yourself, use a custom message notification. When an account has been logged in and another device logs in to the account again, let the server send a notification to the first device. The device can log out after receiving the notification.
If you are using third-party instant messaging, it is relatively simple. After the account is logged in, the instant messaging will have a monitoring method. Just perform operations in this method
Generally, one account is not allowed to be logged in on two mobile phones. Unless there are special needs, you can go to the mobile phone device parameters for unique verification as account parameters
Requires server-side classmates to make restrictions