Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol #61

Open
jeffladiray opened this issue Mar 18, 2019 · 1 comment
Open

Protocol #61

jeffladiray opened this issue Mar 18, 2019 · 1 comment
Assignees
Labels
client client related stuff enhancement Enhancement of an existing feature server server related stuff

Comments

@jeffladiray
Copy link
Collaborator

jeffladiray commented Mar 18, 2019

Made this on to define once and for all a basic and extensible protocol for UTL related stuff

I prefixed all the "message" with an identifier, so redux code will be easier to segment.

  • ON - connection : (client)

  • ON - disconnect : EMIT - lobby/update && if connected to channel channel/update && (if don't reconnected => disconnect from game after 45 s)

  • ON - init/createPlayer : ({player})

    • EMIT - INITIATOR ONLY - init/playerCreated : () => ({player}) # Send created user
    • JOIN IO ROOM -> LOBBY # Since user exist, add it to lobby
    • EMIT - `lobby/update
  • ON - channel/create : ({channel})

    • EMIT - lobby/update # Update lobby with new channel
    • EMIT - INITIATOR ONLY - channel/created
    • EMIT - channel/update # Contains info to redirect the user to the correct page
  • ON - channel/join : ({channelId})

    • EMIT - lobby/update : () => ({lobby}) # Update lobby, without initiator
    • JOIN IO ROOM -> UTL_GAME_ROOM(channelId) # Since user exist, add it to lobby
    • EMIT - channel/update: # Update current channel for all player # contains info to redirect the user to the correct page
  • ON - utl/nextRound : ()

    • EMIT - channel/update # Update current channel for all player
  • ON - utl/selectedAnswers : ({answers})

    • EMIT - channel/update: # Update current channel for all player
  • ON - utl/selectedJudgment : ({judgment})

    • EMIT - channel/update: # Update current channel for all player

We should also strictly define and serialize response message sent from the server in order to avoid ppl looking trough js code to find opponents card

EMIT - lobby/update

{
  $id: 'lobby',
    type: 'object',
    properties: {
      lobbyUsers: { type: 'User', default: '' },
      channels: {
       name: {type: 'string', default: '' },
       id: {type: 'integer', default: '' },
    },
  };

EMIT - channel/update (UTLGame & UTLPlus (protocol)

{
  $id: 'channel',
    type: 'object',
    properties: {
      id: {type: 'integer', default: '' },
      name: {type: 'string', default: '' },
      admin: {type: PLAYER (NEED TO BE CHANGED)},
      players: {
       id: {type: 'integer', default: '' },
       name: {type: 'string', default: '' },
       score: {type: 'integer', default: '0' },
       hand: {type: Answer, default: '' },
       answers: {type: Array[type: 'integer'], default: '0' },
       isGameMaster: {type: 'boolean', default: '0' },
      },
      currentStatus: {type: 'string', default: 'IDLE' },
      timer: {type: 'integer', default: '0' },
      deckQuestion: {type: 'string', default: '' },
    },
  };

This is the UTL games definition of a channel.

EMIT/ON/EMIT - INITIATOR ONLY : BROADCAST/ON NEW REQ RECEIVED/SEND RES ONLY TO THE SPECIFIC CLIENT

@jeffladiray jeffladiray added enhancement Enhancement of an existing feature client client related stuff server server related stuff labels Mar 18, 2019
@Thenkei
Copy link
Owner

Thenkei commented Mar 20, 2019

I started to update the protocol as they are set today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client related stuff enhancement Enhancement of an existing feature server server related stuff
Projects
None yet
Development

No branches or pull requests

3 participants