Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Assets DarkRift Networking 2: The next level of networking

Discussion in 'Works In Progress' started by Jamster, Jan 20, 2016.

  1. Dr_TKL

    Dr_TKL

    Joined:
    Dec 18, 2013
    Posts:
    6
    Sorry, but I have more questions.
    1. Which console command stops the server?
    2. Does plugins runs in its own threads, or in one?
    3. What is more performant: many plugins (WorldManagerPlugin, PlayerManagerPlugin, EventGeneratorPlugin, ...) or one big plugin with all logic inside?
    4. Can I call methods from other plugin?
    5. How can I write to console/log from C# plugin? In DarkRift example Interface("..."); but I can't find this method in DarkRift2 API.
    Thanks for your patience.
     
    Last edited: Feb 22, 2018
  2. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    No problem :)
    1. Currently you can just press Ctrl+C to close the server, I may add a stop command though as a few people have asked for plugins to be able to close the server and it would follow nicely.
    2. It can run in the thread pool (i.e. multiple threads) or from the main thread only for Unity compatibility/general ease.
    3. It doesn't matter, many plugins give you modularity so I tend to do that but there's no performance reason why you should have one or more really. Technically there would be a tiny performance increase with fewer but it's fairly negligible.
    4. Yep
    5. Plugins now have a protected WriteEvent method that replaces Interface.Log :)
    Sorry about the delayed reply!

    Jamie
     
    Dr_TKL likes this.
  3. Dr_TKL

    Dr_TKL

    Joined:
    Dec 18, 2013
    Posts:
    6
    Should I write login and MySQL plugins or it will be in DarkRift2? And yes, when it will be on AssetStore? Thanks.
     
  4. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    Yes, you'll need to write your own login and database connectors for DR2. For login I recommend using HTTPS and then leaving an authentication token in the database; DarkRift isn't security focused so there is always a chance of a data leak which could be nasty.

    Not sure when it will be on the store, I won't hear anything until it gets approved I'm afraid!
     
  5. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    So it appears Unity published DarkRift without telling me!

    You can grab the released Free version here!
    Or the Pro version here!

    So now comes the pleading part... Unity assets only really get downloads if they're well rated, otherwise people don't know what they're getting and don't go for it. If you've enjoyed DarkRift 2 and you want to help support it, one of the best things you can do for the community is head over and review it for us :)

    Thanks all, here's to DarkRift 2!
     
  6. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    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! :)
     
  7. Ohmit

    Ohmit

    Joined:
    Nov 1, 2013
    Posts:
    1
    Hello Jamster!
    I am making a small MMORPG oriented for like 300-400 players at one time. At first I was testing a SmartFoxServer and it seemed like a nice solution but then I've found DarkRift 2 and now I'm interested in it too. I have few questions about it, hoping that your answers will help me to choose better solution for my game.
    So, as I said, I am planning to make a small MMORPG.
    What I've liked in SmartFoxServer is that it has built-in Area-Of-Interest system that will cause a better perfomance. As far as I know, DarkRift2 does not support it yet.
    But, if I understood everything correctly, DarkRift2 supports Unity's physics and colliders, which SFS doesn't, so it will be easier to make AI.
    What would you advice me to choose?
     
  8. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    You are correct, DarkRift has an AoI system planned but it's not available yet. DR2 does allow you to run from an instance of Unity so you get physics and navmesh simulated easily, that generally makes a lot of things easier.

    I haven't personally used SmartFoxServer so I don't think I'm the best person to comment on it. Perhaps someone else will be able to help who has tried it :)
     
  9. Imperatoss

    Imperatoss

    Joined:
    Mar 24, 2018
    Posts:
    24
    Hi, i´m pretty new to Darkrift and i´m looking for a Linux Server tutorial. Is it even possible to setup a linux darkrift server?
     
  10. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    It is yes! It'll be almost identical to running on Windows but you'll need to run the server via mono if you're using the standalone server. If you're using a Unity based server it'll be exactly the same though!
     
  11. Supergeek

    Supergeek

    Joined:
    Aug 13, 2010
    Posts:
    90
    .NET Core has really improved in the past couple years, with regards to API robustness and compatibility, as well as network performance. It would be great if DarkRift supported Core for the server instead of Mono.
     
  12. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    I agree, sadly it's not possible at the moment. Because DarkRift is embeddable into Unity >5.3 it needs to target .NET3.5 until enough people switch to a version of Unity that defaults to .NET4.6 runtime (then I believe DR can target .NET Standard 1.1, still old tech but better than it has been) at which point it will be compatible with .NET Core.

    It'll be here eventually :)
     
    Supergeek likes this.
  13. Vedrit

    Vedrit

    Joined:
    Feb 8, 2013
    Posts:
    505
    I also used to use SFS, and would recommend DR2 over SFS. As Jamster stated, Area of Interest is coming to DR2, and running the server embedded in Unity gives you access to all that Unity has to offer.
     
  14. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    @Supergeek A little further research today suggests this won't be possible until DR uses Unity 2018 as a minimum version, which won't be soon at all...

    It's a real shame, I would love to be able to take advantage of .NET Core but this puts a complete blocker on it...
     
  15. Levr01

    Levr01

    Joined:
    Jun 6, 2017
    Posts:
    4
    No any guides for work with it ????!
     
  16. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    Yep! There's a tutorial and plenty of documentation here!

    Jamie
     
    Cushmily likes this.
  17. fedecaccia

    fedecaccia

    Joined:
    Apr 5, 2015
    Posts:
    12
    I can't add the MySQLConnector. I was following this
    guide but I have trouble when I try to compile the connector.cs. Is there a complete guide to do it?
     
  18. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    That tutorial is for the original version of DarkRift and didn't get updated by the author for the new version sadly!

    The official tutorial for DarkRift 2 is here if you're looking to learn :)
     
    fedecaccia likes this.
  19. fedecaccia

    fedecaccia

    Joined:
    Apr 5, 2015
    Posts:
    12
    Thanks a lot!
    I am moving from HLAPI to DarkRift. I'm wondering if there exist something like "NetworkProximityChecker", I should have to implement it with DarkReift. Thanks!
     
  20. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    Currently, there is not. I do plan on adding it as one of the first major features after Christmas though :) you'll need to implement this yourself at the moment, though.
     
    theuncas and fedecaccia like this.
  21. theuncas

    theuncas

    Joined:
    Feb 21, 2015
    Posts:
    23
    Hello, I'm currently writing a serie of article regarding the usage of DarkRift2. I'm making to encourage people to use this library.

    I'm aware that more we'll have users, more DarkRift2 will be used and thus more it will be improved !

    Here is the link :
    https://materiagame.com/category/tutorials/dark-rift-2

    Don't hesitate to give me your feedback. I need it to improve the content ;)

    Cheers!
     
    Kinami37 and Vytek like this.
  22. Kinami37

    Kinami37

    Joined:
    Jun 12, 2016
    Posts:
    3
    Good S*** my dude!
     
  23. WsdServers

    WsdServers

    Joined:
    Jan 28, 2017
    Posts:
    8
    Hi Jamster, thanks for creating Darkrift 1-2, both are great solutions, I love them!

    I have a liitle problem though... I am building a mmo game and I would like to create my market website for the users, and I would need to website communicate with the darkrift server, so I can noitfy players if someone uploaded a new item, or if they purchased some item, I would like to update the inventory in the game.

    What approach would you suggest?
     
  24. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    Hey,

    It sounds like you want a shared database that you can persist the inventory in, my usual suggestion being something like Postgres. If someone purchases an item or you need to list their inventory in game you can query the database from the DarkRift server and then if someone purchases an item on the website you can update the database similarly from the web server.

    How are you currently persisting inventory, do you not already have a database?

    Jamie
     
  25. WsdServers

    WsdServers

    Joined:
    Jan 28, 2017
    Posts:
    8
    Thanks, for your reply, sorry, I wasn't quite clear... yes I have an MS SQL db, and no problem with updating it from game or website... my problem is, that if I update the database, for example at a purchase I would like the game to be updated WITHOUT user action.. let's say I would like to display a popup in game saying "XY item added to inventory".

    If the website could work like a client of the server, it could send the Darkrift message to server (hey game, user bought some stuff, here is a message with "update inventory" tag, with the item itself in the message ), just like a game client, without continously querying the DB (asking "hey is there an update?") So I was trying to get DarkRift work inside my ASP.Net Core web app, to avoid querying the DB from the game on Update, which is my main concern.

    I could get Darkrift client connect in ASP.Net web app, but .Net Core 2.1 has a bug, and can't handle application lifecycle, so I can't clean up and close my connection to DR server, if a user closes the website. This results in the website hanging up if you close it and repoen it. So I was wondering maybe I am on wrong track, and you have already came up with some kind of plan to have Darkrift connected to the web, not only to a Unity Client... for some reason, I don't know why, maybe I read it somewhere, but I thought DarkRift could also be used for web apps like for chatting functionality or other network based stuff, like html5 gaming...
     
  26. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    987
    Sorry, is that DarkRift has a bug in .NET Core 2.1 or ASP.Net does?

    It should just be a case of connecting with DarkRiftClient as I think you already have done.

    DarkRift should work fine from any C# platform, besides that you'd have to rewrite a lot of logic to get it working on any other platform. HTML 5 would require a lot of work and a custom listener to handle websockets if you wanted to do it from pure Javascript!