-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessage.go
More file actions
33 lines (26 loc) · 920 Bytes
/
Copy pathMessage.go
File metadata and controls
33 lines (26 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package main
// Message is a struct for message
// websocket -> server : Action, Sender, Data
// server -> websocket : All fields
type Message struct {
// Action:
// "new-room", "join-room", "leave-room", "list-room",
// "start-game", "over-game",
// "block-rotate", "block-left", "block-right", "block-down", "block-drop"
// "gift-full-blocks", "sync-game"
Action string `json:"action"`
Sender string `json:"sender"` // user-nick or game-id
Data string `json:"data,omitempty"`
RoomId int `json:"roomId,omitempty"`
BlockIndexs []int `json:"blockIndexs,omitempty"`
// for list-room
RoomList []RoomInfo `json:"roomList,omitempty"`
// for gift-full-blocks
Cells [][]int `json:"cells,omitempty"`
// for over-game, sync-game
Score int `json:"score,omitempty"`
// sync-game
CurrentBlock *Block `json:"block,omitempty"`
// list-rank
RankList []Rank `json:"rankList,omitempty"`
}