Skip to content

PhpManager

Sasso edited this page Jan 30, 2021 · 1 revision

This class provides methods to dialog with php files. To implement the methods of this class you need a server to host php files and a database. Php files and MySQL query to create the appropriate table are provided in the GitHub repository.


FirstContact

Try to contact server and, if the connection is successful, set url to mega archive in megaurl and the tag of the last version available in lastVer. This method should not be used if the game is stored in a GitLab repository, in that case version tag can be retrieved with XVLauncher.UpdateHandler.GetLatestRelease, while megaurl is no more useful.

Returns

true if the conncection is successful, false otherwise.


GetID(version)

Assign to user a new auto-increment ID.

Name Description
version System.String
current game version tag.

Returns

ID.


GetLastVer

Getter method for lastVer.

Returns

Last version available.


GetMegaUrl

Getter method for PhpManager.megaUrl.


ReportError(error)

Store error message in last_error column. Also update error_date column with current timestamp.

Name Description
error System.String
Error message.

SendPost(url, postData, report)

Helper method provided by makim on this Stack Overflow thread: https://stackoverflow.com/questions/6960426/c-sharp-xml-documentation-website-link.

Name Description
url System.String
postData System.String
report System.Boolean
In case of Exception, don't call ReportError if it is false. Default is true, but in some cases it can be useful to set it to false to avoid loops.

Returns

webpage content.


UpdateVersion(newVer)

Update user current version in the database. Since in the database the column last_date is setted as ON UPDATE CURRENT_TIMESTAMP, this method can also be used to update that column. For example, it can be called whenever the game is launched, so the database will register the last time each id has launched the game. It can be useful to know if someone is still playing the game (using the application/using whatever this launcher is used to) after months or years.

Name Description
newVer System.String
User current version.

USE_PHP

Set it to true if you want to use php files to communicate with your server. Check the documentation for more details.