Skip to content
Zacky edited this page Mar 18, 2017 · 5 revisions

Welcome to the Game Lord Wiki!

Menu

Design

Overview

overview

  • Nginx proxy_pass should be configured according to user_id.
  • GameLord service should deployed to several pods, and the containers in a pod run the instance.
  • Redis holds hashed users' tokens.

Detail

detail

  • Users get login_token by /sign_up or /login. When it expires or /logout by yourself, you need /login again.
  • Users get game_token by /load_game. When it expires or /leave_game by yourself, you need /load_game again.
  • Take Hangman as an example:
    • If you start to play hangman for the first time, you should /list_category and /pick_word for initialization.
    • If you have played hangman before, you should load_status to continue.
    • Every time you /validate your selected letter, you will get the current_word. And you will be told whether it's over.
    • During the game, you can reset anytime. Once you leave_game, your game_status will be saved automatically.

Token

Type Generation
login_token_key Sha1Hash("[user.Salt][user.Id][CurrentDevice]")
login_token_value Sha1Hash("[user.Salt][time.Now")
game_token_key Sha1Hash("[user.Salt][user.Id][game.Id][CurrentDevice]")
game_token_value Sha1Hash("[user.Salt][time.Now")

APIs

Response Code Explanation

Code Overview
10[1-9] Common Error
11[1-9] User Error
12[1-9] Game Error
13[1-9] Hangman Error
Code MessageType Detail
101 err_internal Internal Error
102 err_missing_data Missing API Data
103 err_invalid_data Invalid API Data
110 user_success User Request Succeed
111 err_duplicate_name Duplicate User Name
112 err_user_not_exist User Name Doesn't Exist
113 err_password_mismatch Password Mismatch
114 err_login_token_mismatch Login Token Mismatch
115 err_game_token_mismatch Game Token Mismatch
121 err_game_not_exist Game Doesn't Exist
130 hangman_success Hangman Request Succeed
131 err_user_record_not_exist User Record Doesn't Exist

User Routes

Name Method Pattern Notes
Signup POST /v1/signup get login_token
Login POST /v1/login get login_token
Logout POST /v1/logout lose login_token
LoadGame POST /v1/load_game get game_token
LeaveGame POST /v1/leave_game lose game_token
  • About data format, plz see more at gameLord Req/Resp file.

Hangman Routes

Name Method Pattern
ListCategory POST /v1/hangman/list_category
PickWord POST /v1/hangman/pick_word
LoadStatus POST /v1/hangman/load_status
Validate POST /v1/hangman/validate
Reset POST /v1/hangman/reset
  • About data format, plz see more at hangman Req/Resp file.