Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Colyseus for self-hosted multiplayer (Node.js server)

Discussion in 'Multiplayer' started by endeld, Aug 30, 2019.

  1. endeld

    endeld

    Joined:
    Oct 20, 2017
    Posts:
    6
    Hey everyone!

    Recently I've released version 0.11 of Colyseus. If you haven't heard of it, it is an open-source authoritative server using Node.js/WebSockets: https://docs.colyseus.io/getting-started/unity3d-client/

    A lot has changed since its inception, and the Unity support on version 0.11 is a lot better than it used to be!

    A member of the community created a full tutorial on making a "Naval Battle" game both in the client-side and server-side using Colyseus, which you can check out here: http://mobyinc.com/labs/lets-code-online-multiplayer-web-game

    When using Colyseus, you need to define how your "state" looks like in the server, and generate C# code to be used in the client. As in authoritative servers, the clients are a dumb representation of what's in the server. Most of the game logic should live in the server, and the clients only send commands to update the game state, which is later broadcasted for all clients in a performant way.

    If you haven't tried it yet, I highly recommend! Any feedback is always welcome, too!
    Cheers ❤️
     
    bladtherf and jushiip like this.
  2. galtan_six

    galtan_six

    Joined:
    Sep 28, 2019
    Posts:
    1
    Hi there, I have downloaded Colyseus and I must say I am impressed on how easy it is to use. I have built games with Google Play services, Game Center and GameSpark but this is exactly what I was looking for!
    Are there any guides on how to move everything to the cloud? Especially on how to secure things. I am still wondering on how to make sure only "my game" is able to call the ws endpoints and to make sure the mongoDB can only be called by the game server. Any guidance on this would be much appreciated.
     
    tobizion likes this.
  3. tobizion

    tobizion

    Joined:
    Mar 16, 2019
    Posts:
    2
    Hi, did you get an answer?
    I have the same doubts as you and I also worry about how stable Colyseus is. What happens if they leave the Colyseus project?
     
  4. Serve

    Serve

    Joined:
    Nov 8, 2012
    Posts:
    13
    @tobizion I did not get an answer but I will post the same question on Github. As for stability: I have tested Colyseus locally and it did not crash once. Right now, I have integrated the Colyseus into my game. Developing mulitplayer has now become so easy. Actually I am developing for mobile but for the time being I have switched the build target to Mac / Pc standalone. If you then build you will get an executable. If you copy that executable lets say two times and start them both, you can test multiplayer on your computer. If you then start the Editor as well you can even start a 3 player game. You get the idea! With build times much faster for Mac / PC target, console feedback from the Colyseus server and console feedback from your multiplayer clients, things have become much easier to debug.

    But still I have to check for things like memory consumption and storage size over time to see if the server behaves in a normal fashion.
     
  5. xikxp1

    xikxp1

    Joined:
    Jan 13, 2020
    Posts:
    1
    Hello @Serve!

    I am in the process of prototyping my own turn-based game and so far Colyseus looks very promising to me as well after some initial hacking. Do you have any updates on your experience regarding its performance and storage consumption? Have you found any caveats? What is your database of choice?
     
  6. endeld

    endeld

    Joined:
    Oct 20, 2017
    Posts:
    6
    MalyaWka and HeadClot88 like this.
  7. tommox86

    tommox86

    Joined:
    Apr 30, 2015
    Posts:
    81
    @endeld excellent work. your client code for unity is highly reflective. is there a performance hit for this?