Skip to content

Commit

Permalink
Support MatchZy v0.7.11 (#51)
Browse files Browse the repository at this point in the history
* Updated for MatchZy Schema

* Deleted Examples and Fiber for upcoming refactoring.
Replaced MatchID with generics(currently int only).

* Update ID generics

* 認証方法を変更

* MatchIDが実態stringのintだったので対応化

* Updated MatchZy demo upload headers
  • Loading branch information
FlowingSPDG authored Jun 23, 2024
1 parent 979f385 commit 2555867
Show file tree
Hide file tree
Showing 28 changed files with 127 additions and 6,310 deletions.
67 changes: 7 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,86 +67,33 @@ type EventHandler interface {

#### MatchLoader
[MatchLoader](https://github.com/FlowingSPDG/Got5/blob/75996d44058558ca7453af1c4b4f9e73115924d4/controller/got5.go#L54-L57) interface should handle ``get5_loadmatch_url`` request from game server.
You need to respond game server with JSON.
You need to respond JSON.
https://splewis.github.io/get5/latest/match_schema/
```go
// MatchLoader is for Read Operation(get5_loadmatch_url)
type MatchLoader interface {
// Auth Checker
CheckMatchAuth(ctx context.Context, mid string, auth string) error
CheckMatchAuth(ctx context.Context, mid int, auth string) error

// Load respond to get5_loadmatch_url
Load(ctx context.Context, mid string) (got5.G5Match, error)
Load(ctx context.Context, mid string) (got5.Match, error)
}
```

got5.G5Match is interface for generating get5 supported format JSON.
```go
// G5Match 別の構造体にG5Matchインターフェースを実装すれば型が違っても変換してGet5に渡してくれる
type G5Match interface {
ToG5Format() Match
}
```
```go
type Match struct {
MatchTitle string `json:"match_title"`
MatchID string `json:"matchid"`
ClinchSeries bool `json:"clinch_series"`
NumMaps int `json:"num_maps"`
PlayersPerTeam int `json:"players_per_team"`
CoachesPerTeam int `json:"coaches_per_team"`
CoachesMustReady bool `json:"coaches_must_ready"`
MinPlayersToReady int `json:"min_players_to_ready"`
MinSpectatorsToReady int `json:"min_spectators_to_ready"`
SkipVeto bool `json:"skip_veto"`
VetoFirst string `json:"veto_first"`
SideType string `json:"side_type"`
Spectators Spectators `json:"spectators"`
Maplist []string `json:"maplist"`
MapSides []string `json:"map_sides"`
Team1 Team `json:"team1"`
Team2 Team `json:"team2"`
Cvars map[string]string `json:"cvars"`
}
```

#### DemoUploader
[DemoUploader](https://github.com/FlowingSPDG/Got5/blob/75996d44058558ca7453af1c4b4f9e73115924d4/controller/got5.go#L59-L62) interface should handle demo upload from game server.
You may want to add auth middleware to prevend unauthorized demo uploads.
```go
// DemoUploader is for Demo Upload Operation(get5_dem_upload_url)
type DemoUploader interface {
CheckDemoAuth(ctx context.Context, mid string, filename string, mapNumber int, serverID string, auth string) error
Upload(ctx context.Context, mid string, filename string, r io.Reader) error // demoファイルの登録処理
CheckDemoAuth(ctx context.Context, mid int, filename string, mapNumber int, serverID string, auth string) error
Upload(ctx context.Context, mid int, filename string, r io.Reader) error // demoファイルの登録処理
}
```

## Authentication
There are some CVARs for authenticating Got5 and get5 gameserver.
- `get5_remote_log_url` - For specifying where to send Event Data.
- `get5_remote_log_header_key` - HTTP Header key for event request.
- `get5_remote_log_header_value` - HTTP header value for event request.
- `get5_demo_upload_url` - For specifying where to upload demo data.
- `get5_demo_upload_header_key` - HTTP Header key for demo upload.
- `get5_demo_upload_header_value` - HTTP Header value for demo upload.
- `get5_loadmatch_url "https://example.com/match_config.json" "Authorization" "Bearer <token>"` - For loading match info.
TODO...

## Examples
### logger
[logger](https://github.com/FlowingSPDG/Got5/tree/main/examples/discord) is most simple implemention for Got5 interfaces.
logger simply prints what happens.
No write operation, No Data store system.

### firebase
[firebase](https://github.com/FlowingSPDG/Got5/tree/main/examples/firebase) interfaces will read/write match/event informations.
You may need to enable firestore on your Google Cloud Platform project.

### Discord
[discord](https://github.com/FlowingSPDG/Got5/tree/main/examples/discord) is most complicated implemention of Got5 interfaces.
Discord struct implements all Got5 interfaces.
You can create match, store event datas and post what happens.

### Discord webhook
[discord_webhook](https://github.com/FlowingSPDG/Got5/tree/main/examples/discord_webhook) posts received get5 events.
This is fairly simple and nice example for learning your first Got5 based system.

TODO...
10 changes: 5 additions & 5 deletions controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (

// Auth Auth interface handles auth
type Auth interface {
EventAuth(ctx context.Context, serverID string, auth string) error
MatchAuth(ctx context.Context, mid string, auth string) error
CheckDemoAuth(ctx context.Context, mid string, filename string, mapNumber int, serverID string, auth string) error
EventAuth(ctx context.Context, auth string) error
MatchAuth(ctx context.Context, mid int, auth string) error
CheckDemoAuth(ctx context.Context, mid int, filename string, mapNumber int, serverID string, auth string) error
}

// EventHandler EventHandler interface handles read operation by get5 events
Expand Down Expand Up @@ -58,10 +58,10 @@ type EventHandler interface {
// MatchLoader is for Read Operation(get5_loadmatch_url)
type MatchLoader interface {
// Load respond to get5_loadmatch_url
Load(ctx context.Context, mid string) (G5Match, error)
Load(ctx context.Context, mid int) (*Match, error)
}

// DemoUploader is for Demo Upload Operation(get5_dem_upload_url)
type DemoUploader interface {
Upload(ctx context.Context, mid string, filename string, r io.Reader) error // demoファイルの登録処理
Upload(ctx context.Context, mid int, filename string, mapNumber int, r io.Reader) error // demoファイルの登録処理
}
37 changes: 0 additions & 37 deletions examples/discord/auth.go

This file was deleted.

60 changes: 0 additions & 60 deletions examples/discord/cmd/main.go

This file was deleted.

12 changes: 0 additions & 12 deletions examples/discord/demo.go

This file was deleted.

Loading

0 comments on commit 2555867

Please sign in to comment.