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

Define client-server communication flow #7

Open
Bigorneau opened this issue Mar 19, 2016 · 2 comments
Open

Define client-server communication flow #7

Bigorneau opened this issue Mar 19, 2016 · 2 comments
Milestone

Comments

@Bigorneau
Copy link
Member

Format of messages

Message type and JSON data with a well-defined structure.

emit("type", {"key": "value"})

Client Join

Client -> Server
"join", {
  "nick": "Player nickname",
  "color": "#rrggbb",
  "armaturae": "mirmillo"
}

Server -> Client
(actor:spawn|Error)

Client input

Client -> Server
"input:press", {
  "type": "up"
}
Client -> Server
"input:release", {
  "type": "primary"
}

Available types:

  • up, down, left, right
  • primary, secondary, ternary
  • taunt
  • dash
  • lockDirection

Actor events

Server -> Client
"actor:update", {
  "id": "UUID",
  "changes": {
    "x": 10,
    "y": 0,
    "direction": "east"
  }
}

Available types:

  • create
  • remove
  • update

Examples

# An arrow is shot and hits a player
"actor:create", {
  "id": "arrow_id",
  "x": 0,
  "y": 0
}
"actor:update", {
  "id": "arrow_id",
  "x": 0,
  "y": 10
}
// ...
"actor:update", {
  "id": "player_id",
  "reason": "hit",
  "health": 20,
  "armor": 10
}
"actor:remove", {
  "id": "arrow_id"
}

World state

Server -> Client
"worldstate", {
  "actors": [
    {
      "id": "UUID",
      "type": "player",
      "nick": "Nickname",
      "x": 0,
      "y": 0,
      "direction": "north",
      "armaturae": "mirmillo"
      // ...
    }
    {
      "type": "wall",
      "x": 32,
      "y": 64,
    }
  ]
}

Errors

Server -> Client
"error", {
  "type": "InvalidNickname",
  "message": "Nickname is already in use"
}
@Bigorneau
Copy link
Member Author

Assignee removed

@Bigorneau Bigorneau added this to the 24h milestone Mar 19, 2016
@Bigorneau
Copy link
Member Author

mentioned in commit fd9a7653bdebe54010e5d9c3fb3904b1ffbedd03

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant