Structure Introduction:
When the client goes offline, the client sends a message to the server, tells the server that I want to go offline, and then the client executes the offline function.
The Downline function executes a function that allows the server to write the client's data to the database and delete the client from the session list.
The Downline function is also executed when the server accepts the intention of the client to go offline.
This is done to prevent the client from accidentally offline, causing the client to fail to execute the Downline function, the server to write data to the database itself.
Live Diary:
When writing test cases, when the client executes the Downline function, the database is immediately clear. This will cause the server to still write data to the database, but the database
has been emptied, so this will be an error.
Analysis Process:
From the site diary can be very simple analysis of the cause of the error, it is natural to think of the flag that this client has been executed the downline function.
After doing this, the problem really solved. A second problem was found shortly thereafter. Because the program is multithreaded, it happens to write data to the database.
The operation to clear the database will be performed before execution, so the error will still occur. Then think of writing another downline service, let the data go to the database first to write, and then
Perform a downline operation. and then block the service off. This service is executed to perform other services.
Final Solution:
After the analysis of the solution is very simple, first mark the client has successfully executed the Downline function.
Then write a downline service that blocks the service.
Bug Fix journal---------player information is repeatedly written to the database