Search Unity

DarkRift Networking 2

Discussion in 'Assets and Asset Store' started by Jamster, Feb 7, 2018.

  1. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    What's DarkRift Networking 2?
    DarkRift 2 is a complete rewrite of the original DarkRift Networking, a networking library released nearly 4 years ago now and highly praised for its speed, lightweightness, and sheer power.

    DarkRift 2 has been in development concurrently with DarkRift 1 for 2 years now, reimplemented from scratch and done with an eye to improve any area DarkRift 1 fell short in.


    What's so good about DarkRift 2 then?
    Well then...
    • Bi-channel UDP and TCP for reliable and unreliable communication
    • Overhead of only 3 bytes on UDP and 7 bytes on TCP (previously 13 bytes in DarkRift 1)
    • IPv6 support
    • Internally multithreaded for maximum throughput
    • Runs standalone from the console or from within Unity
    • Fully authoritative using custom server plugins
    • Fully customizable logging through plugins
    • Extensively configurable
    • Minimal GC intrusion (and we're still optimizing this)
    • Significantly more online documentation than DarkRift 1
    • Plus plenty more, check out the full list
    Oh yeah, and unlimited CCU... All for free...

    I'm interested, tell me more...
    DarkRift Networking is a high power multiplayer solution for games requiring cloud-based, authoritative servers.

    It takes a different approach to many of the other networking systems, using message passing to give you the maximum amount of control possible and to provide minimal intrusion into your project.

    DarkRift Networking's aim is to be flexible and fast - we want to make DarkRift the choice for every game, and we want to outperform all the other multiplayer solutions.

    DarkRift is available in two packages: The free version gives you unlimited CCU and all the stuff listed above; the Pro version gives you even more features like Rooms and AoI*, for serious games. There's genuinely no reason you couldn't release the next Overwatch or PUBG with DarkRift Free - checkout the comparison chart here.

    The latest updates are posted in this thread so to keep up with the news check out the most recent posts!

    How do I get it?
    DarkRift's available on the asset store!

    Be sure to join the community run Discord server as well for more discussion on DarkRift!

    Jamie
    DarkRift Networking

    *OK, Rooms and AoI are actually delayed a version or so, but will be Pro only. There's till plenty of other stuff in Pro to get your hands on though!
     
    Last edited: May 3, 2018
    r137, yuliyF, Ruchir and 9 others like this.
  2. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2 has been submitted to the asset store!
     
    Shadow2k2 likes this.
  3. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    @Jamster Wait a long time. Thank you very much for your work. I have some questions:
    1.Does it support load balancing, like a photon engine?
    2.Include nat punching for udp and tcp heartbeat?

    Thanks again.
     
  4. mixmotion00

    mixmotion00

    Joined:
    Jun 15, 2017
    Posts:
    3
    Thank you very much @Jamster. patiently waiting to see darkrift2 at the assetstore
     
  5. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Not on release unfortunately.

    Interserver communication will be possible in a later version and so loadbalancing will be easy then, however people have done it without.

    NAT punchthrough is beyond the scope of DarkRift as DarkRift isn't for peer-to-peer games, it's for games with managed servers. You can use DarkRift as a relay server similar to UNET though.

    TCP heartbeat isn't in yet but will be added soon :)

    Jamie
     
    LostPanda likes this.
  6. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    @Jamster thanks, waiting for release.

    Sorry, I still have a question, if you do not support p2p, voice functionality will become impossible? Most voice services require p2p support, or you have better advice.
     
  7. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    P2P is certainly better for voice and I'd recommend using that for voice. It is still possible with a server-client architecture, and arguably much easier and more reliable, but your lag will be a bit higher.

    There's a number of packages on the asset store for voice so it could be worth trying some of them (I have no first hand experience with them) alternatively I don't see any reason DarkRift couldn't work side-by-side with a P2P networking system for voice. Similarly, I expect steamworks has voice support already if you're going that route.

    P2P is just outside of DarkRift's scope, it's designed to be used with managed servers and so converting it to work with P2P as well would basically require writing an entirely new system.
     
  8. LostPanda

    LostPanda

    Joined:
    Apr 5, 2013
    Posts:
    173
    thanks very much!
     
  9. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Since DR2 is up on the asset store now it feels like posting the weekly updates on the WIP thread is a little irrelevant!

    Apart from the glaringly obvious thing that happened this week, I've been working away at getting the room system in a shape that could be tested. I've very happy that I didn't release it with Rooms an AoI beacuse frankly we'd be waiting a long time for DR2 otherwise!

    The new room system is very expandable and flexible and so might require a little work to get it working at first, but it should be able to handle anything you throw at it. To give you a taste, the current iteration is made up of 2 main components, both of which are plugins so are able to log, read databases etc.

    The first is the RoomDataConnector. This will be responsible for communicating with your database (or just operating in memory) to load the available rooms, create new rooms and destroy rooms. For the most part, this will rely on a custom implementation for your game's particular settings and database needs but that shouldn't be a tricky exercise.

    The second half is the Matchmaker. This will be largely provided by DarkRift but will hopefully still be largely customisable. Firstly, you will provide it with a IMatchRankingProvider which is a small function taking a room and entity (could be a client, but doesn't have to be) and outputting a value indicating how good a match they are. The matchmaker will then handle queueing up players and finding the best room for them.

    I will also be looking at how to allow groups/squads to queue together since this might need some extra code in the IMatchRankingProvider! :)

    Lots has happened this week!
    Jamie
     
    LostPanda likes this.
  10. Dr_TKL

    Dr_TKL

    Joined:
    Dec 18, 2013
    Posts:
    6
    Hi. Is it possible to launch DarkRift2 server on Linux (Ubuntu) in command line?
     
  11. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Yep! You can use Mono to run it at the moment :) I'd like to port to .NET Core but it's doesn't seem to play well with Unity, at least until Unity ditches .NET3.5.
     
    Dr_TKL and nxrighthere like this.
  12. Dr_TKL

    Dr_TKL

    Joined:
    Dec 18, 2013
    Posts:
    6
    Thanks. Our team will wait for official release on AssetStore.
     
    Jamster likes this.
  13. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Very late update this week but then not much has happened.

    Sadly Unity are still reviewing DarkRift so it's still not available on the asset store yet, I'd hope that it will be up early next week but if I recall new submissions usually take longer than updates.

    I've done a little more on the room system adding a new DataConnector plugin type to DarkRift which will be a specific type of plugin providing database connectivity/operations for DarkRift. I've also updated the matchmaker with a few performance improvements, there are now shortcuts to immediately accept rooms if they're above a given suitability metric threshold and discard others if they're below another threshold these should really reduce the amount of processing matchmakers have to do and should allow you to tune your matchmakers for performance.

    Lastly I had a god at porting DarkRift to .NET standard. Sadly it doesn't look like this will be any time soon as Unity doesn't support it in any way on 5.3 and even later versions are unlikely to play nicely with it :( Maybe one day...

    Jamie
     
    LostPanda likes this.
  14. ramoida

    ramoida

    Joined:
    Jan 3, 2017
    Posts:
    5
    It's out!! Right on time when I was looking for a light network solution, I'll be working with it next month! Can't wait!

    I'll keep reading docs in the mean time. One question, is there a built in way to execute tasks every certain amount of time on the server side? For instance: every 10 mins, broadcast certain message to players. What would be the best way of doing that?

    Thanks!
    Nice new logo btw!
     
  15. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Oh damn! Nice of them to tell me! :)

    Thanks for pointing that out!

    There's not at the moment but I want to implement a form of timers/cron job at some point. You can use the System.Timers namespace to do it though, if you're comfortable with multithreading :)
     
    ramoida likes this.
  16. ramoida

    ramoida

    Joined:
    Jan 3, 2017
    Posts:
    5
    Cool! It's something I will be using further into the future, from what I've read I noticed that feature was't there. So I guess I can write my custom Command, then manually execute it once, on a new thread, and keep it running right? or is there some other way to add a custom call at server initialization?

    Thanks!
     
  17. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    You'll get the constructor call and the Loaded event at startup so you can initialise your timer from there for the time being :)
     
  18. ramoida

    ramoida

    Joined:
    Jan 3, 2017
    Posts:
    5
    Awesome! Thanks! I'll let you know when I try it!
     
    Jamster likes this.
  19. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    (It looks like I posted last weeks update on the wrong thread so here it is a week late!)

    Hey all!

    Firstly, sorry for the lack of update last week, I didn't forget I just had nothing to update with since everything was a little hectic :)

    The most major thing this week is that the previous problems running a server from a Unity build has been fixed. It appears that I was using a socket method that's not supported by the version of Mono that it's built with but is included in the editor version. That's no longer the case and as part of the Unity compatibility mode it DarkRift will now stop using that method and use some more old fashioned socket methods instead. This will be fixed in the next release.

    I have also been working on adding configurable timers to DarkRift. A few people have asked how to periodically call a method and so I've had to direct them to `System.Threading.Timers` but since this is multithreaded it can immediately cause problems for newer users, hence DarkRift will provide a wrapper for the timers that ensures if you mark your plugin as not thread safe it routes the events through the dispatcher first. This might not be in the next release but will be in the next minor version!

    Lastly, I had a play around at the weekend with moving the network layer of DarkRift out into a plugin. This would mean that the TCP/UDP communication part of DarkRift would be part of a specialised plugin that can be easily swapped out for others, as an example the Unity compatibility stuff could be decoupled into a separate network plugin and Websocket/WebRTC layers could be written and easily swapped in and out. In fact there wouldn't be anything stopping you guys from building your own layers that use Hazel/ENET/UNET/Lidgren and probably even Bluetooth/HTTP if you realllllyyy wanted to for some reason! This was just a bit of fun so don't expect this to be in DarkRift any time soon but it is a nice proof of concept, it makes for some quite neat code and has some fun uses as well! :)
     
  20. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    (And now for this week's update!)

    DarkRift 2.0.1 has been submitted to the Asset Store! Hooray!

    This patch fixes the problem with servers in Unity builds not accepting connections and also the Unity crash that occurs when disconnecting and connecting from the same UnityClient component.

    Hopefully this will go through quickly but there's no guarantee so expect about a week before it's actually released to the store :)
     
  21. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2.0.1 is now available on the asset store!
     
    LostPanda likes this.
  22. ramoida

    ramoida

    Joined:
    Jan 3, 2017
    Posts:
    5
    Keep up the good work!
     
    Jamster likes this.
  23. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Hey all! I was on holiday last week hence no post, but a lot's been done!

    Firstly, I've been re-implementing some of the network layer code as plugins since people seemed very open to the idea after some initial discussion. This means that it will be possible to add your own network layers as plugins so the server can operate over any protocol you need, for example websockets or WebRTC; it'll also allow DarkRift to listen on multiple different ports and protocols at the same time. This won't be out any time soon since there's a lot of the interface that still needs to be finalised including as how buffers are recycled when they're being passed to the listener plugins, but it will be out at some point and will be a key cornerstone for WebGL support etc.!

    Improvements have been made to the upcoming room system including adding IDs for rooms and simplifying the different states and pipeline of the matchmaker. The room systems is still very unfinished, but it's not forgotten :)

    Lastly, I've exposed the no delay option for the sockets so Nagle's algorithm can be disabled or enabled from the configuration file.

    Lots to do but lots being done! :)
     
  24. squall-leonhart

    squall-leonhart

    Joined:
    May 5, 2017
    Posts:
    26
    Hi,

    When roughly can we see the room and match making in action ? I have bought your previous DarkRift Pro, do you have any upgrade or discount for previous version owner if to purchase DarkRift Pro 2 ?
     
  25. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Hey!

    I'm hoping I can release a public beta of the rooms and matchmaking within a couple of months, it'll probably be another couple until an official stable release is out.

    There is a discount yes, because DR 2 Pro costs more you only need to pay the difference in price from DR 1 Pro, if you have DR 1 Extreme the upgrade to DR 2 Pro is $1 I think (I wanted it to be free but Unity wouldn't allow it!)

    Jamie
     
  26. Shadowing

    Shadowing

    Joined:
    Jan 29, 2015
    Posts:
    1,648
    How many players can I sync with Darkrift? I've been using Photon Networking and idk ehh. seems max is gonna be liek 20 to 30. Support couldn't really give me a real number.
     
  27. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    I can't give you a real number either because it depends wildly on what hardware you're running and the characteristics of your game. The best advice I can give you if you want to compare the two is to see here, but it's only artificial tests.
     
  28. sammyben

    sammyben

    Joined:
    Nov 12, 2013
    Posts:
    7
    Hi there, excited to try out Darkrift 2 as was a big fan of 1! Trying to upgrade my plugin now but was wondering what happened to message Subject?
     
  29. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Hey!

    There was a lot of discussion on the Discord about it during beta but the general consensus that arose was that most people didn't use the subject field or only used a fraction of the bits in the subject field. We decided that it would be more inline with how people used them if we were to have a 16 bit tag rather than the 8 bit tag and 16 bit subject pair.

    You can still do some bit shifting to get a similar effect or you can always write in an extra field into your message body to replicate the behaviour :)

    Jamie
     
  30. squall-leonhart

    squall-leonhart

    Joined:
    May 5, 2017
    Posts:
    26
    Hi Jamster,

    Need some clarification, so as of now to make DarkRift2 to have lobby, room and match making is to write another program that keep track of the room attributes (like number of player, lowest level allowed etc) and run one instance of the server.exe per room ?something like the master-server framework for UNET in asset store https://assetstore.unity.com/packages/tools/network/master-server-framework-71391?

    Thanks and Regards
     
    Last edited: Apr 5, 2018
  31. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Something along those lines would work yes, you are likely to need some form of master server/matchmaker and then some form of room server. You might find that you can run multiple rooms per server however so it's not necessarily a strict 1-1 room-server ratio (although that might make it easier).

    You could coordinate the servers through a database so it's easier to update/read player stats and slightly more modular.

    Jamie
     
    squall-leonhart likes this.
  32. squall-leonhart

    squall-leonhart

    Joined:
    May 5, 2017
    Posts:
    26
    Guess I would try to use DarkRift2 for my game and see how it goes. Thanks jamster, I will upgrade to pro 2 when I am comfortable with DatkRift2 free :D. Keep up the good work
     
    Jamster likes this.
  33. gugua

    gugua

    Joined:
    Jan 11, 2013
    Posts:
    32
    Hello,Jamster
    How to sent the C# base type(ex:List<string>) to message use the DK2?
    I can't sent the List sever to client.....
     

    Attached Files:

  34. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    To send a list you currently need to send each element individually prefixed by the length of the list so that you can recreate it on the other side. However, since you're using a type supported by DR inside the list you could just convert it to an array and send that way for convenience!
     
  35. gugua

    gugua

    Joined:
    Jan 11, 2013
    Posts:
    32
    Thank you,Jamster
    Does DK2 support IOS mobile platforms?
     
  36. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    I have not been able to test on iOS personally as I don't have access to an iOS device however I don't know of any reason that it wouldn't work.
     
  37. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2.1.0 has been submitted to the store!

    Firstly apologies for the lack of updates, it slipped my mind last week and it was Sunday by the time I realised!
    The last two weeks have been fairly slow for DarkRift development, I'm a little swamped under and my free time has been mainly on Overwatch or PUBG... Sorry! I've cleared a few GitHub issues particularly involving typos in the documentation (thanks for finding them!) and have also exposed tags in the `MessageReceivedEventArgs` objects since people pointed out it seemed wasteful to create a `Message` object just to check if the tag was for that handler.

    The more major thing this week has been adding `ActionDispatcherTask` objects to the object cache so they're now recycled* which should relieve a little GC pressure on users in thread safe mode.

    Lastly I spotted and fixed a bug where the thread safe option in plugins was being overridden by the thread safe option in the server spawn data/config and so the server wasn't actually entering thread safe mode properly.

    Hopefully the update should be pushed fairly promptly!

    *While writing this I've just realised that this is going to make no different because the object caches are unique per thread and so they'll get constantly consumed on one thread and produced on another and never actually recycle back around... I'll fix that...
     
  38. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    DarkRift 2.1.0 is now available on the asset store!
     
    ramoida likes this.
  39. MMOInteractiveRep

    MMOInteractiveRep

    Joined:
    Apr 7, 2015
    Posts:
    88
    So I see alot of the plugin stuff is only available in the paid version. Plugin Installation/upgrading, extended inter-plugin access... How will this effect those of us who use the free version... What exactly does the Plugin Installation and upgrading do? And are we able to access Plugins from with in other plugins. So If I had a Quest Plugin, Combat Plugin, and Inventory Plugin would I be able to notify the Quest Plugin that I just killed a certain Mob from with in the Combat Plugin and would I be able to add an item to the player's inventory in the Inventory Plugin from with in the quest plugin upon completing a Quest?
     
  40. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Hey!

    Plugins are available in the free version, the pro version only offer some minor upgrades at the moment.

    The plugin installation and upgrade system allows gives your plugin extra events that DarkRift will call if it's never seen your plugin before or if you increase the version number allowing you to update DB schemas appropriately for example.

    The Loaded event is another event that gets called just before the server starts, like Start in Unity, so you can more easily setup links to other plugins etc.

    The extended inter-plugin access (I thin it's that on the website) are a few extra methods for accessing other plugins. There's already a set of methods in the free version so your setup is completely possible and you can communicate between plugins easily, but the pro version adds a few other methods that are quite useful.

    Hope that helps,

    Jamie
     
  41. Deleted User

    Deleted User

    Guest

    Is there any tutorial for using darkrift server in unity?. I have been finding it difficult to get it working properly
     
  42. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Unfortunately I haven't had time to write any example code or tutorials for this yet, I would like to rewrite the block demo to have a Unity server example as well so they can be easily compared but this will take a while!

    What problems are you having? Anything I can help with?
     
  43. Deleted User

    Deleted User

    Guest

    I tried to use the ClientConnected event the same way it was used in the Agar.io tutorial but it raised an error saying i need to implement the IClientManager interface
     
    Last edited by a moderator: Apr 24, 2018
  44. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    Interesting error to get, you should just be able to do:
    Code (csharp):
    1.  
    2. server.Server.ClientManager.ClientConnected += YourEvent;
    3.  
    Where server is your reference to the UnityServer component.
     
  45. Deleted User

    Deleted User

    Guest

    Thank you so much, it worked. Anyways, fantastic work on the darkrift 2
     
    Jamster likes this.
  46. gugua

    gugua

    Joined:
    Jan 11, 2013
    Posts:
    32
    hello Jamster
    How to exit the DK2 server in Command(Plugin)?I can‘t use the DarkRiftServer.Dispose();
     
    Last edited: Apr 26, 2018
  47. MostHated

    MostHated

    Joined:
    Nov 29, 2015
    Posts:
    1,235
  48. gugua

    gugua

    Joined:
    Jan 11, 2013
    Posts:
    32
    other question:how to uninstall the plugin?
     

    Attached Files:

  49. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    There's currently no command to close the server, you simply need to Ctrl-C to terminate it. The main reason for this is because plugins (where all the built in commands are written) don't have access to that level of control at the moment.

    Interesting asset, I've not seen that before! There's no reason DarkRift won't work for you barebones (works for a lot of people that way), it's just that you might have to implement more than you would with other systems - that's the trade off between flexibility and development speed. I think the best bet is for you to just dive in and cross that bridge when you come to it, though that may not be your way of working.

    You can't uninstall a plugin while it's currently loaded into the server, if you close the server and delete the plugin from your Plugins folder (may vary if you've modified your configuration) you can then use the plugins uninstall command to remove any artefacts and data left by the plugin.

    Hope that's helped everyone!
    Jamie
     
  50. CommunityUS

    CommunityUS

    Joined:
    Sep 2, 2011
    Posts:
    240
    Hey Jamster, I don't have any questions at present. However, I noticed on your 2.0 asset that is on sale the description still says Rooms and the like are being actively worked on. I then look at the docs and it has a section on rooms, so it seems more complete than the description. Just a heads up. I am 90% sure I will be purchasing this while it is on sale (hopefully this may sale puts you more on the map than you have been [get ready for support madness too lol]) but when I saw rooms still in progress on desc. it gave me a doubt. Which you don't want of course esp. if work has been done so just a heads up. Most people if on the fence will check the forum here, so if just put progress update in bold at top while waiting for desc. update likely would cover you and avoid any loss sales due to misinformation. anyways, that's my 2 cents, I will likely have questions as I get going. Out of curiosity how big is discord group? I know if once you get pass a certain threshold support can start to take care of itself on there and you can focus on the work.

    Side note Hazel sounds neat, I just saw it. Does it compliment DarkRift in a anyway? I imagine you have that for companies that require open source at the low level or the like? Do you plan to tie Hazel and DarkRift development API's or any other tie ins planned?

    Thanks for your time. Chad