GitHub | Documentation | Become a Patron

Configuring Room and Timeline



  • Hi everyone,

    I recently started implementing Colyseus for my game, which is real time and thus
    is potentially a good candidate for lag compensation.

    A quick look through the Room class shows that there is a method Room#useTimeline(maxSnapshots)
    and that Room#setState(state) takes a snapshot if there is a timeline object.

    To use the timeline for lag compensation, I am currently implementing this via Room#onMessage and/or
    the simulation interval function. I just want to make sure that I'm not missing something - is there any
    implementation or abstract function that I should be using/implementing instead?

    Secondly, regarding Room creation: suppose I have a BattleRoom class that implements the core server logic.
    Is there a way that I can pass parameters to this BattleRoom in order to instantiate it with different max player
    settings, different map selection, or different objectives?

    I could see creating subclasses such as FFARoom and TDMRoom to represent different objectives, but if I wanted
    to have N different maps, M different objectives, and P different max player settings then I would end
    up with NMP different subclasses of BattleRoom and that explodes really fast!

    I appreciate your help.

    Thank you,
    Nick

    Edit:
    Some additional information - I started this project by rolling my own server implementation and used the
    strategy pattern to plug in different objectives such as FFA, and JSON configuration objects to set map
    rotation and max players.

    I'm sure there's better ways to go about it, I appreciate any ideas or feedback :)



  • I found the options / parameters :)
    In case anyone else makes the same mistake, you can pass options/parameters into a Room when you call
    Server#register(name, handler[, options]) - see http://colyseus.io/docs/api-server/

    I'm still wondering about the first part of my question regarding Timeline - is that part completely left up to me to implement (with the exception of snapshots being taken in Room#setState)?

    Thank you,
    Nick