Leo Yang
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Web final - front-end -- react -- motion dection -- socket.io - back-end -- express -- server (local and online <eg. heroku>) -- login system (GraphQL?) -- database (MySQL, or graphQL) -- socket.io - OpenCV -- OpenCV.js tutorial -- ## Schedule - 李昌 - Webcam - OpenCV - Leo - Session (done) - Home - Room ## API - HomePage - `GET /rooms` 取得所有房間資訊(首頁) - dump all rooms in database - Input: NO - Output: an array of rooms ``` [ { primary_k: primary key of the room in database (used for routing) name: name of room player_num: number of waiting players in this room }, ... ] ``` - `GET /highScore` 取得最高分及玩家 - get highScore player (10 player most) - Input: - none - Output: - player info (an array with objects) in ordered based on score, high to low ``` [ { "id": 6, "name": "ryanhu", "score": 88 }, ] ``` - `POST /rooms` 新增房間 - create a new empty room - Input: - `req.body.roomName` - Output: - `{ roomid: primary_k }` of the new room (primary_k as "id" used in backend) - `post /record` 記錄玩家得分 - record the score of certain player - Input: - `req.headers.id` - `req.body.score` - `req.body.roomid` - Output: - none ## Socket.io for Room ### server - utilities - Response an error - Action: 'err' - Data: `string message` - on `reqRoomInfo` - Data: ``` { roomid: primary_k of the room } ``` - return requesting info of the room - RESPONSE SINGLE - Action: `resRoomInfo` - Data: ``` { name: name of the room, active: bool, if a room is activated (game starts) } ``` - On `enter` - Data: ``` { userid: primary_k of the requester roomid: primary_k of the room } ``` - If the room is inactive, **and the userid of requester not yet in that room**(might already in that due to another tab), add requester into the room and broadcast the update - BROADCAST ROOM - Action: `players` - Data: ``` [ { id: primary_k of the player name: full name of the player } ] ``` - If the room is active or **requester's userid already in that room due to another tab**, notify the requester in this tab - RESPONSE SINGLE - Action: `kickout` - Data: `null` - On `leave` - Data: ``` { userid: primary_k of the requester roomid: primary_k of the room } ``` - remove requester from the room - If there are some remaining players - BROADCAST ROOM - Action: `players` - Data: ``` [ { id: primary_k of the player name: full name of the player } ] ``` - If no player is left, delete the room - No need to response - On `step` - Data: ``` { userid: primary_k of the requester roomid: primary_k of the room step: movement amount of the the requester } ``` - broadcast the step info of requester to all players in room - BROADCAST ROOM - Action: `update` - Data: ``` { id: primary_k of requester step: movement amount of requester } ``` - On `start` - Data: ``` { roomid: primary_k of the room } ``` - broadcast to the whole room that the game starts, and force the room to become inactive - BROADCAST ROOM - Action: `start` - Data: `null` ## Toward Socket.io for `Home` - Client will only listen on action `update_rooms` - Action `update_rooms` - Data (server broadcast to room `home`): ``` [ { primary_k: primary key of the room in database (used for routing) name: name of room player_num: number of waiting players in this room }, ... ] ``` - This action will appear many times below - On `enter_home` - add the requester socket into room `home` - On `leave_home` - remove the requester socket from room `home` - Modify socket.io `enter` action handling - When someone enter a room, the number of players in that room is changed, need to sync the update to all clients staying at Home - Send action `update_rooms` as specified above - Modify socket.io `leave` action handling - Similar as `enter`, need to update the player num showing in Home - When the last user leave the room, the room is automatically deleted, also need to sync with all clients in Home - Send action `update_rooms` as specified above - Modify API `POST /rooms` - New room is created - Send action `update_rooms` as specified above ## Database - schema (columns) - User - id - first_name - last_name - email - password - created - Room - id (int) - name (string) - active (bool) - playerID (array)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully