Teams #

Read more about the Teams system in Hiro here.

Functions #

Create #

Create a new team (i.e. Nakama group) with additional metadata which configures the team.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
request := &hiro.TeamCreateRequest{
  Name:          "MyTeam",
  Desc:          "My team description",
  Open:          true,
  Icon:          "iconUrl",
  LangTag:       "",
  SetupMetadata: "<metadata>",
}

team, err := systems.GetTeamsSystem().Create(ctx, logger, nk, request)
if err != nil {
  return err
}

List #

List teams which the user can join.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
request := &hiro.TeamListRequest{
  Cursor:   "",
  Location: "uk",
  Limit:    10,
}

teams, err := systems.GetTeamsSystem().List(ctx, logger, nk, request)
if err != nil {
  return err
}

Search for teams based on given criteria.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
request := &hiro.TeamSearchRequest{
  Input:   "TeamName",
  Limit:   10,
  LangTag: "uk",
}

teams, err := systems.GetTeamsSystem().Search(ctx, db, logger, nk, request)
if err != nil {
  return err
}

WriteChatMessage #

Send a message to the user’s team, even when they’re not connected on a realtime socket.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
userId := "userId"
request := &hiro.TeamWriteChatMessageRequest{
  Id:      "teamId",
  Content: "Heya team!",
}

resp, err := systems.GetTeamsSystem().WriteChatMessage(ctx, logger, nk, userId, request)
if err != nil {
  return err
}