Client
.NET/Unity C++/Unreal/Cocos2d-x JavaScript/Cocos2d-js Godot 3 Godot 4 Java/Android Defold cURL REST Swift Dart/Flutter
Server
TypeScript Go Lua
Teams
# Read more about the Teams system in Hiro here .
Create a team
# Create a team which other players can join.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void onTeamsCreate ( const Hiro :: Team & team )
{
std :: cout << "Successfully created team: " << team . name << '\n' ;
}
void onError ( const Nakama :: NError & error )
{
std :: cout << Nakama :: toString ( error . code ) << ": " << error . message << '\n' ;
}
Hiro :: TeamCreateRequest request ;
request . name = "Example team" ;
request . desc = "Example description" ;
request . open = true ;
request . icon = "icon.png" ;
request . langTag = "en" ;
request . setupMetadata = "{}" ;
hiroClient -> teamsCreate ( session , request , onTeamsCreate , onError );
List one or more teams
# List one or more teams which the player can join.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void onTeamsList ( const Hiro :: TeamList & teamList )
{
for ( auto it = teamList . teams . begin (); it != teamList . teams . end (); it ++ )
{
std :: cout << "Found team: " << it -> name << '\n' ;
}
}
void onError ( const Nakama :: NError & error )
{
std :: cout << Nakama :: toString ( error . code ) << ": " << error . message << '\n' ;
}
Hiro :: TeamListRequest request ;
request . cursor = "" ;
request . location = "UK" ;
request . limit = 100 ;
hiroClient -> teamsList ( session , request , onTeamsList , onError );
Search for a team
# Search for a team by name or optional short code.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
void onTeamsSearch ( const Hiro :: TeamList & teamList )
{
for ( auto it = teamList . teams . begin (); it != teamList . teams . end (); it ++ )
{
std :: cout << "Found team: " << it -> name << '\n' ;
}
}
void onError ( const Nakama :: NError & error )
{
std :: cout << Nakama :: toString ( error . code ) << ": " << error . message << '\n' ;
}
Hiro :: TeamSearchRequest request ;
request . input = "Example team" ;
request . limit = 100 ;
hiroClient -> teamsSearch ( session , request , onTeamsSearch , onError );
Send team chat message
# Write a chat message to the Team’s chat channel.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
void onTeamsWriteChatMessage ( const Hiro :: ChannelMessageAck & channelMessageAck )
{
std :: cout << channelMessageAck . username << " sent a team chat message on channel: " << channelMessageAck . channelId << " \n " ;
}
void onError ( const Nakama :: NError & error )
{
std :: cout << Nakama :: toString ( error . code ) << ": " << error . message << '\n' ;
}
Hiro :: TeamWriteChatMessageRequest request ;
request . id = "example_team_id" ;
request . content = "{ \" message \" : \" Hey everyone! \" }" ;
hiroClient -> teamsWriteChatMessage ( session , request , onTeamsWriteChatMessage , onError );