-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathteams.go
48 lines (38 loc) · 2.09 KB
/
teams.go
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2023 Heroic Labs & Contributors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package hiro
import (
"context"
"database/sql"
"github.com/heroiclabs/nakama-common/runtime"
)
// TeamsConfig is the data definition for a TeamsSystem type.
type TeamsConfig struct {
MaxTeamSize int `json:"max_team_size,omitempty"`
}
// A TeamsSystem is a gameplay system which wraps the groups system in Nakama server.
type TeamsSystem interface {
System
// Create makes a new team (i.e. Nakama group) with additional metadata which configures the team.
Create(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, req *TeamCreateRequest) (team *Team, err error)
// List will return a list of teams which the user can join.
List(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, req *TeamListRequest) (teams *TeamList, err error)
// Search for teams based on given criteria.
Search(ctx context.Context, db *sql.DB, logger runtime.Logger, nk runtime.NakamaModule, req *TeamSearchRequest) (teams *TeamList, err error)
// WriteChatMessage sends a message to the user's team even when they're not connected on a realtime socket.
WriteChatMessage(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID string, req *TeamWriteChatMessageRequest) (resp *ChannelMessageAck, err error)
}
// ValidateCreateTeamFn allows custom rules or velocity checks to be added as a precondition on whether a team is
// created or not.
type ValidateCreateTeamFn func(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID string, req *TeamCreateRequest) *runtime.Error