2D online game development (network) (7) 2

xiaoxiao2021-04-05  271

Autopatcher.setNetworkingsystem (rakpeer);

The prototype of the setNetworkingsystem function is as follows:

Void setNetworkingsystem (RakpeerInterface * localsystem)

Void setNetworkingsystem (RakClientInterface * localsystem)

Void setNetworkingsystem (RakserverInterface * localsystem)

The role of this function is to set the instance of which system to transfer files.

After these settings, the next step will set the load file on the server side, set the download file on the client, set the following:

Service-Terminal:

IF (autopatcher :: CreateFilesignature (Input) == false)

Printf ("Unable to create file signature% s.shan", input);

IF (autopatcher.setfiledownloadable (Input, true)! = set_file_downloadable_success)

Printf ("Unable to make% s downloadablen", input);

}

Printf ("Enter Name of Second File To Make Downloadable or Hit Enter For Nonen");

Gets (Input);

IF (Input [0] && autopatcher.setfiledownloadable! = set_file_downloadable_success

Printf ("Unable to make% s downloadablen", input);

The front two IF statements are used to set up the signature file, and the last IF is used to set without signature downloads. The three function prototypes are as follows:

Bool autopatcher :: CreateFilesignature (Char * filename) [static]

Establish a signature file with. SHA as an extension for FileName.

SetFileDownloadableResult AutoPatcher :: setFileDownloadable (Char * FileName,

Bool Checkfilesignature

)

This function is already explained earlier.

Then you need to download the download directory for the client settings:

Autopatcher.SetDownloadedfileDirectoryPrefix (Input);

The function prototype is as follows:

Void AutoPatcher :: setdownloadededFileDirectoryPrefix (Char * prefix)

Is the setting file download to where, set with prefix, such as C:.

Now enter the cycle, in the message detection, add the following code:

Case ID_AUTOPATCHER_REQUEST_FILE_LIST:

Printf ("Got A Request for the File Listn);

Autopatcher.senddownloadableFileList (Packet-> Playerid);

Break;

Case ID_AUTOPATCHER_FILE_LIST:

Printf ("N ------- ngot the list of available server files.nrequesting downloads.n ------ n"); autopatcher.onautopatcherfilelist (packet, true);

SHOWDOWNLOADSTATUS (& AutoPatcher) == 0)

{

Rakpeer-> DeallocatePacket;

Goto quit;

}

Break;

Case ID_AUTOPATCHER_REQUEST_FILES:

Printf ("Got A Request for Filesn);

Autopatcher.onautopatcherRequestFiles (Packet);

Break;

Case ID_AUTOPATCHER_SET_DOWNLOAD_LIST:

Printf ("* confirmed download listn);

AutoPATCHER.ONAUTOPATCHERSETDOWNLOADLIST (Packet);

Break;

Case ID_AUTOPATCHER_WRITE_FILE:

Printf ("------ ngot a filen ------- n");

Autopatcher.onautopatcherWritefile (Packet);

SHOWDOWNLOADSTATUS (& AutoPatcher) == 0)

{

Rakpeer-> DeallocatePacket;

Goto quit;

}

Break;

}

The prototype of the AutoPatcher.sendDownloadableFileList function is as follows:

Void AutoPatcher :: SenddownloadableFileList (Const Playerid RemoteSystem)

The function of this function is to send all the files in the download list to the client that is scheduled by PlayerID.

The function of .onautopatcherfilelist is as follows:

Void AutoPatcher :: onautopatcherfilelist (packet * packet,

Bool OnlyAcceptFileSifrequested

)

The role of this function is to analyze the list of download files in the server, see if we have no files, or the files that do not match. The analysis results are then passed to the server in the form of a package.

The second parameter, if set to truth, then use the GETDOWNLOADSTATUS function after calling this function. If you set a holiday, you will download the file immediately.

Autopatcher.onautopatcherRequestFiles (Packet);

This function prototype is as follows:

Void AutoPatcher :: onautopatcherRequestFiles (Packet * Packet)

The role of this function is to read the file from the memory and then send them to the client.

AutoPATCHER.ONAUTOPATCHERSETDOWNLOADLIST (Packet);

This function prototype is as follows:

Void AutoPatcher :: onautopatchersetdownloadList (Packet * Packet)

The role of this function is that the server is agreed to download the files on the download list.

Autopatcher.onautopatcherWritefile (Packet);

The function prototype is as follows:

Bool autopatcher :: onautopatcherwritefile (packet * packet)

The function of this function is to write all the files all written to the hard drive we set. Others are nothing, you can refer to its source code in the Raknet routine. For the effect of the program, please go to compile yourself.

OVER!

For more information, please visit the Jinqiao Science website (

http://popul.jqcq.com

The game development section, if you need a book development, please refer to Jinqiao Book City Game Channel (

http://book.jqcq.com/category/1_70_740.html

).

If you have any good suggestions when you read this article, please let me, mine.

E_mail: akinggw@126.com.

If you are using

SDL

What is wrong with it, please go to Jinqiao Scot,

http://popul.jqcq.com

) The game development section, I will answer your questions in detail.

转载请注明原文地址:https://www.9cbs.com/read-132141.html

New Post(0)