---
tags: Work
---
# 交接 Doc
## Part 1 _ API
- PortalServer api info (server running 的時候才有)
http://localhost:3000/api/docs/
- Client & Broker
- serverDataConfig
- URL: ${brokerServerURL}/Conf
- 修改設定資料(configPage)、新增時有修改 default 設定的時候(createPage)
- endGame
- ${brokerServerURL}/End
- 後台強制關閉(consolePage)
- connectToGameServer
- ${brokerServerURL}/IP
- 開始遊戲(gameContent,點進遊戲那一頁的開始遊戲 button)
- uploadZip
- ${brokerServerURL}/Add
- 新增遊戲, upload game zip file
## Part 2 _ IP、PORT...
### PortalServer
- .env (這個檔案沒有推上 github, 要自己建)
PORT、IP
```javascript=
TOKEN_SECRET = "gaminganywhere" // for JWT, 但是現在註解掉了
PORT="3000"
IP="192.168.43.196"
```
- database.ts
```javascript=
export const connectDB = async () => {
await createConnection({
type: "mysql",
host: "192.168.43.196",
port: 3306,
username: "kitty",
password: "pink",
database: "gamedb",
entities: [
__dirname + "/entities/*.ts"
],
```
- app.ts
PORT、IP
```javascript=
const port: number = Number(process.env.PORT) || 3000;
const ip: string = process.env.IP || "0.0.0.0";
```
- package.js
這邊要照著 DB 的資訊一起修改 => 產生 entity
```javascript=
"db": "rm -rf ./src/entities & npx typeorm-model-generator -h 192.168.43.196 -d gamedb -p 3306 -u kitty -x pink -e mysql -o ./src/entities --noConfig true --ce pascal --cp camel"
```
- 如果要部署到 aws
convert ts to js, create dist dictionary, deploy dist dictionary
```bash=
npm run build
```
---
### Client
- gameContent.component.ts
```javascript=
ip: ip || "192.168.43.196",
```
- common.ts
API 的 URL 從這裡 import
localhost 可以用 Web 測試 (上面),但是在手機上 run的話要改成 IP (下面)
```javascript=
export const webServerURL = "http://localhost:3000"
// export const webServerURL = "http://192.168.43.196:3000"
export const brokerServerURL = "http://192.168.43.196:5000"
```
- 如果要部署到 aws
```bash=
ng build
```
---
## Part3_Process
#### 開遊戲 (gameContent.component)
1. button 開始遊戲
2. connectServer
3. call broker api: connectToGameServer to get ip
4. call PortalServer to record in Gaconnection table: recordGameServerIp
5. give Android ip : Android.opengame (interface)
#### 觀看遊戲 (gameContent.component)
1. viewGame
2. call PortalServer 取得要觀看的遊戲 IP: getProcessingGameIp
3. give Android ip : Android.viewGame (interface)
#### 結束遊戲 (consolePage.component)
1. consolePage
2. button 強制關閉
3. endGame
4. call broker api: endGame
5. update status in Gaconnection table to "FALSE"
---
---
## DB table
- Login
- 註冊、登入
- Provider
- 點進個別遊戲裡面的那些資訊 是假的
- GameList
- dashboard 的遊戲列表
- 新增遊戲時新增一筆資料在這個 table
- Gaconnection
- 開啟遊戲 -> 紀錄一筆資料
- 觀看遊戲的列表從這個 table 來的 -> 判斷 status: 'TRUE'
- 關閉遊戲 -> 改狀態 status: 'FALSE'
- ConfigTemplate
- 設定檔案的 default value
- ConfigOption
- 設定欄位的選項,下拉選單
- ConfigData
- 修改過的設定紀錄在這裡
---
## Angular
UI component:
https://material.angular.io/components/categories