Dose colyseus provide any api for determining turn ?

i want to make multiplayer playing card game so , is there any way to determine the turn or restrict players if it is not their turn. or i just have write my own logic??

Hi @hardik_sl, it's up to you how to represent turns in the state. A common approach is to set the sessionId of the current player in a variable, like currentTurn:

onInit () {
  this.state = { 
    players: {/* add players here when they join */},
    currentTurn: "" // sessionId of the current player

onJoin(client, options) {
  this.state.players[client.sessionId] = {/* player data */}

onMessage (client, data) {
  if (client.sessionId === this.state.currentTurn) {
    // perform your action

  } else {
    console.log("only the current active player can send messages this time")

Thanks @endel it is really helpfull