Currently I’m trying to implement this library in the Urho3D engine to completely replace kNet and allow all the nice features that are available in RakNet but not in kNet library (NAT Punchtrough, LAN discovery and other nice things).
I need advice on how to proceed further. As I understood RakNet doesn’t have distinction between client and server connections but in engine there are Network and Connection classes which leads to duplicate code in both classes if I keep the existing structure. Changes are inevitable if I want to proceed I just want to understand the best approach to this problem before I move further with the development.
There wasn’t really any duplication involved in switching to RakNet. It was basically a by-the-numbers piece-wise replacement.
Connection was and remained a helper with state-data for an end-point. In RakNet instead of the kNet::MessageConnection the RakNet::AddressOrGUID and the already initialized peer interface are passed off to Connection so it knows who to send everything to for that connection.
The switch to RakNet doesn’t eliminate any of the other state tracking per-endpoint that the Connection has to do.
It was a pretty boring switch-over. The most excitement was debating where to place the Hash function for RakNet::AddressOrGUID to be used in Urho containers.
Edit: here’s a link to the zip dump for RakNet I did, deliberately not in Github anywhere - but it’s a-ok for someone else to put it there. Just an I will not support you thing.
I actually used your code (@Sinoid) as a base to build everything, but seems like somewhere I made the wrong turn. I’m now digging in a bit deeper and it makes sense how you managed to implement RakNet inside the engine.
So I dug a bit deeper in the @Sinoid implementation of RakNet. The difference is that I was trying to make the server and client work in paralel in host application since kNet implementation allowed that and I was overcomplicating things. Anyway, I did manage to get it to work.
Update:
Everyting seems to be working just fine, only thing that I havent yet tested is the package downloading functionality.
I was able to implement NAT punchtrough functionality which requires server to be hosted on a public host, docker image for that can be found here! You’re welcome!
Server authorization via password is implemented.
LAN broadcasting was already created by @Sinoid.
AngelScript bindings are added to support new functionality. Haven’t yet created a repo for all of these changes but I’m planning to to that this week if everything goes as planned.
I really hope so. I will create a PR later and after that we’ll see how it goes. These are pretty large changes and additional testing is needed to check whether everything else still works as expected. I already know that few samples will have to be fixed but I’m also planning to do that.
So far I have covered these platforms:
Ubuntu 14.04 (native and cross compiling with MinGW)
Ubuntu 16.04 (native. cross compiling with MinGW and Android NDK r15c ARM and x86)
Windows 10 (Visual Studio, Android NDK r15c ARM and x86)
Raspberry PI 3 (native)
Best way to test this out is to build the engine as usual and run the network samples:
16_Chat
17_SceneReplication
52_NATPunchtrough
53_LANDiscovery
Not the OS X specific one. That is a so-called mirror branch and should be short-lived one. If you do a prune then it should be deleted in your local repo.
About the Nat server: where do I have to copy the Urho3D-NAT-server directory exactly, in the Urho build tree? The whole dir or just the files?
cp <+++nat+++server> <Urho3D+++???>
NAT Punchthrough Server failed to compile on my Mac (didn’t check yet on Windows or Linux).
I had to modify the SLikeNet CMakeLists.txt file to make it pass .
-D_RAKNET_SUPPORT_NatPunchthroughServer=1
OK , my bad , missed this CMakeLists.txt
I used the original that came with the ArnisLielturks-SLikeNet branch.
overwriting the original with the one from NAT-server passed compilation also on Mac.