Overview of the samples and test code.
All the following samples are located under Samples\Code Samples
AutopatcherClient
AutopatcherServer
Intermediate
The autopatcher samples demonstrates the user of the autopatcher system. To run it, start one instance one of the AutoPatcherClient sample, and one of the AutoPatcherServer. The server uses the provided PostgreRepository class to store the application files in a a PostgreSQL database.
The client sample (AutopatcherClient) doesn't know anything about the mechanism used by the server to store the applications. It justs asks for patchs for applications.
BitPacketTest
Beginner
This sample tests the packet splitting capabilities of RakNet.
All it does is send a large block of data to the feedback loop.
BitStream
Beginner
The bitstream sample doesn't have much functionality but is instead intended to provide a clear sample of how to write and read bitstreams. It is all contained in one program and uses RPC to transmit the data. It writes a string and some numbers and shows how to read branching data.
Chat Example Client
Chat Example Server
Beginner
A simple chat server and a simple chat client. Unlike a real game, it encodes strings directly into the data stream and reads them out directly. Normally you would use a packet ID. It use static data to transmit the name and message of the day. To test, run an instance of the server and two or more instances of the client.
Client File Verification
Intermediate
This sample will read all the files in the Debug directory, generate a 20 byte SHA-1 code for them, and send that over the network. If the code generated by the client and server match then the files are good. This shows a simple way to test the integrity of files on the client - although you will have to take other steps to prevent them from being modified in memory or changed after this test.
CommandConsoleClient
CommandConsoleServer
Intermediate
CommandConsoleClient demonstrates connecting to the command console, using the RakNet transport protocol. It's the equivalent of a secure telnet client.
CommandConsoleServer demonstrates the command console server, which can be which can be a standalone application or part of your game server. It allows you to easily parse text strings sent from a client using either secure RakNet or Telnet.
Compression
Intermediate
This sample shows how to use the global compression scheme in RakNet. You have to start two or more instances of the program, passing nothing when queried for the frequency tables. Then chat for a while to 'train' the data. After quitting you will be prompted to save the frequency tables. The server should then send its frequency table to the clients, and one of the clients send its frequency table to the server. For better accuracy you can sum up the frequencies from all the clients and send that. Then start the program over again and enter the files you just generated when prompted. If everything works, you can chat again. When you quit you will be given statistics on how much bandwidth you saved by sending compressed data.
ConnectionGraph
Beginner
This sample demonstrates the connection graph plugin, which is used to maintain a list of all connections on the network.
DirectoryDeltaTransferTest
Intermediate
This sample demonstrates the plugin to incrementally transfer compressed deltas of directories. In essence, it's a simple autopatcher.
Unlike the full autopatcher, it has no dependencies. It is suitable for patching from non-dedicated servers at runtime.
Dropped Connection Test
Intermediate
This test randomly starts and stops connections for n clients, where n can be changed from a define at the top of the file. Since all clients are in the same exe on the same computer the n threads created may slow things down.
Encryption
Intermediate
This is a tutorial on how to load, save, and use RSA keys with secure connections. The process is difficult to explain in a manual but easy to follow in code. Helpful to have some familiarity with RSA encryption.
Flow Control Test
Beginner
RakNet automatically handles flow control, which is evident from this test. This test only really has meaning when run over the internet, where there is limited bandwidth. You can also try using RakPeer::ApplyNetworkSimulator to make things look more real.
FullyConnectedMesh
Beginner
This project tests and demonstrates the fully connected mesh plugin. No data is actually sent so it's mostly a sample of how to use a plugin.
LANServerDiscovery
Beginner
Sends an offline ping to everyone at IP "255.255.255.255". All active servers on a LAN should respond with a pong.
LoopbackPerformanceTest
Intermediate
The loopback performance test is good for discovering implementation flaws and measuring implementation efficiency. It is fairly complex with a large number of parameters but has defaults for everything - just hit enter. You will need to start 3 instances of the program and enter 1, then 2, then 3 when prompted. You can hit enter for all other parameters if you wish. Detailed statistics are shown during runtime and at the end of the test.
MessageFilter
Beginner
Demostrates the use of the MessageFilter plugin to filter all incoming messages, and only allow messages of a certain type.
NATPunchTrough
Intermediate
Shows how to use the NatPunchthrough plugin to connect two system that are both behind NATs.
ObjectMemberRPC
Advanced
Shows how to make RPC on object methods. You need to runs two instances, one as a server, and one as a client.
Also, you should understand the basics about NetworkIDObject .
OfflineMessagesTest
Beginner
This project tests the advertise system and offline ping messages.
PacketLoggerTest
Intermediate
Show how to use the PacketLogger class, to display all packets being sent or received.
You can derive PacketLogger, and overwrite PacketLogger::WriteLog to render output into your own program.
Ping
Beginner
Starts a server, then a client, then does an unconnected ping between the two.
RakVoice
RakVoiceFMOD
Intermediate
These two projects show how to integreate RakVoice with a sound engine. RakVoice sample show how to integrate with portaudio, and RakVoiceFMOD shows how to integrate wit FMOD sound engine.
This uses peer to peer connections between all chatting systems.
See rakvoice.html for more details.
Reliable ordered test
Beginner
Continually sends packets using reliable ordered from a sender to a receiver. The receiver checks the packet data to make sure the packets arrived in order.
Remote Procedure Calls
Intermediate
Shows how to send a message to the server using RPC, and then using RPC to send that message back to the client. Very simple - just look at the code.
ReplicaManagerCS
ReplicaManagerP2P
Advanced
Shows how to use the ReplicaManager class in a Client/Server environment or P2P. ReplicaManager is a very lightweight and efficient system that provides object creation, destruction, and serialization updates such that you have all copies of all desired objects on all desired systems semi-automatically.
See ReplicaManager for more details.
Router
Advanced
Demonstration of the Router plugin. The Router plugin exposes a Send function allowing you to send to systems you are not directly connected to.
ServerEnumeration and StaticClient Data
Intermediate
A client connects to a server and static data is shared between them. This sample covers all functionality associated with this and shows the more complex cases where you want to update data on the other system or only change data locally.
Timestamping
Beginner
In this sample, a sender writes the timestamp identifier and a timestamp into a byte stream and sends it to a recipient. It demonstrates how RakNet will automatically modify the timestamp so that it is system relative.
|