forked from facebookarchive/RakNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatacompression.html
96 lines (86 loc) · 5.11 KB
/
datacompression.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<HTML>
<HEAD>
<TITLE>Data Compression</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</HEAD>
<link href="RaknetManual.css" rel="stylesheet" type="text/css">
<meta name="title" content="RakNet - Advanced multiplayer game networking API">
</HEAD><BODY BGCOLOR="#ffffff" LINK="#003399" vlink="#003399" alink="#003399" LEFTMARGIN="0" TOPMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0"">
<span style="background-color: rgb(255, 255, 255);"><img src="RakNet_Icon_Final-copy.jpg" alt="Oculus VR, Inc." width="150" height="150"></span><BR>
<BR>
<table width="100%" border="0">
<tr>
<td bgcolor="#2c5d92" class="RakNetWhiteHeader"><img src="spacer.gif" width="8" height="1">Data Compression Overview</td>
</tr>
</table>
<TABLE BORDER="0" CELLPADDING="10" CELLSPACING="0" WIDTH="100%">
<TR>
<TD><span class="RakNetBlueHeader">Description </span><BR>
<BR>
RakNet can automatically compress all your outgoing data and decompress your incoming data. To do this, it needs a 'sample' frequency table for your average game so it can pre-compute how to encode the data to get maximum savings. Here is the general process of how to go about this:
<OL>
<LI>Run a sample 'average' game. Get the frequency table for the server and for one of the clients (or average all the clients if you want).
<LI>Generate the decompression layer for the server from the client's frequency table
<LI>Generate the compression layer for the server from the server's frequency table
<LI>Generate the decompression layer for the client from the server's frequency table
<LI>Generate the compression layer for the client from the client's frequency table.
</OL>
After that everything is handled automatically.<BR>
<BR>
The functions are described below. See Samples\Compression for a full example. </TD>
</TR>
</TABLE>
<table width="100%" border="0">
<tr>
<td bgcolor="#2c5d92" class="RakNetWhiteHeader"><img src="spacer.gif" width="8" height="1">Data Compression Functions</td>
</tr>
</table>
<TABLE BORDER="0" CELLPADDING="10" CELLSPACING="0" WIDTH="100%">
<TR>
<TD><span class="RakNetCode">SetCompileFrequencyTable( bool doCompile )</span><BR>
<BR>
Enables or disables frequency table tracking. This is required to get a frequency table, which is used in GenerateCompressionLayer()
This value persists between connect calls and defaults to false (no frequency tracking)
You can call this at any time - however you SHOULD only call it when disconnected. Otherwise you will only trackpart of the values sent over the network.
<BR><BR>
<span class="RakNetCode">GenerateCompressionLayer(unsigned long inputFrequencyTable[256], bool inputLayer)</span><BR>
<BR>
This is an optional function to generate the compression layer based on the input frequency table, which you get with GetOutgoingFrequencyTable.You should call this twice - once with inputLayer as true and once as false.
The frequency table passed here with inputLayer=true should match the frequency table on the recipient with inputLayer=false.
Likewise, the frequency table passed here with inputLayer=false should match the frequency table on the recipient with inputLayer=true.
Calling this function when there is an existing layer will overwrite the old layer.
<BR>
<BR>
<span class="RakNetCode">DeleteCompressionLayer(bool inputLayer) <BR>
</span><BR>
Delete the output or input layer as specified. This is not necessary to call and is only valuable for freeing memory.
You should only call this when disconnected<BR>
<BR>
<span class="RakNetCode">GetOutgoingFrequencyTable(unsigned long outputFrequencyTable[256]) </span><BR>
<BR>
Returns the frequency of outgoing bytes into output frequency table
The purpose is to save to file as either a master frequency table from a sample game session for passing to GenerateCompressionLayer() .
You should only call this when disconnected. Requires that you first enable data frequency tracking by calling SetCompileFrequencyTable(true)
<BR>
<BR>
<span class="RakNetCode">float GetCompressionRatio </span><BR>
<BR>
This returns a number n > 0.0f where lower numbers are better. n == 1.0f means your data is no smaller or greater than the original. This shows how effective your compression rates are.<BR>
<BR>
<span class="RakNetCode">float GetDecompressionRatio </span><BR>
<BR>
This returns a number n > 0.0f where higher numbers are better. n == 1.0f means the incoming data was decompressed to be just as large as it was when it came in. This shows how effective your compression rates are.<BR>
<BR>
<table width="100%" border="0">
<tr>
<td bgcolor="#2c5d92" class="RakNetWhiteHeader"><img src="spacer.gif" width="8" height="1">See Also</td>
</tr>
</table>
<TABLE BORDER="0" CELLPADDING="10" CELLSPACING="0" WIDTH="100%">
<TR>
<TD> <A HREF="index.html">Index</A><BR> </TD>
</TR>
</TABLE></TD>
</TR></TABLE>
</BODY>
</HTML>