Tag Archives: Networking

RakNet Take Two

I made my first pass at integrating RakNet into my engine today. I ended up going with the following class inheritance structure for bringing it into the mix:

Red is RakNet and Purple are components of my own engine. So far the only class that actually makes use of the functionality in NetObject is my PhysicsCube that I’ve been using in the last few posts, but it’s very easy to extend any SceneObject derived class to be networkable.

To test out the integration I decided to try running my physics simulation entirely on the server. For ease of use I temporarily forked my codebase into two separate Xcode projects: one for the server and one for the client. All of the rendering code was stripped out of the server build, and physics disabled on the client build. The server handled all the physics simulation and would send updated positions/rotations to the client. In addition to testing RakNet’s basic networking features, the setup also allowed me to use RakNet::Replica’s syncing feature that keeps new clients up to date with the scene as they join. Here are a few shots of the system in action on the iPad simulator:

And one from my iPhone, just as new cubes were added to the scene on the server:

Overall I’m very happy with how RakNet is functioning. In the next few days I’m going to try to get some more interesting things in the scene, as I’m getting a bit tired of the cubes. 😛 I’m hoping to have some basic player-like functionality in place by the end of the week and hopefully a functional Mac and Windows client to go with the iPhone one.



Rak ’em Up…

I’m at the point in my engine development where I need to start integrating some net code before I go any further. Like the physics support, networkable objects and net code in general are components I’d like to have as part of the engine’s core functionality rather than tacked on later. I’ve worked with a few network solutions in the past (OpenTNL and RedDwarf), but I decided to use RakNet this time. It’s free to use up to a certain revenue cap, and it’s cross-platform. Perfect!

RakNet only comes with projects for Visual Studio, not Xcode, so I started by loading it onto my desktop machine first. Everything worked out of the box and I was able to run some of the sample use cases without any problems. Setting up Xcode projects for Mac and iPhone were equally straightforward, and I was able to run a chat server on the PC and have my Mac and iPhone connect to it:

I haven’t started to integrate anything into my engine code base yet, but I’m going to start work tomorrow. I did take a look at RakNet’s ReplicaManager though, which sounds extremely useful and will definitely be something I use. It’s essentially a set of classes that will handle replicating objects from the server to the client, or between peers. It’ll be a good foundation for the networked objects in my engine.

All in all, I’m very impressed with RakNet so far.


%d bloggers like this: