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
Auctions Read more about the Auctions system in Hiro here .
Creating a New Auction
# To create a new auction, use the auctionsCreate function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void onAuctionCreate ( const Hiro :: Auction & auction )
{
for ( auto it = auction . reward . items . begin (); it != auction . reward . items . end (); it ++ )
{
std :: cout << "Found codex item: " << it -> second . name << '\n' ;
}
}
void onError ( const Nakama :: NError & error )
{
std :: cout << Nakama :: toString ( error . code ) << ": " << error . message << '\n' ;
}
Hiro :: AuctionCreateRequest request ;
request . templateId = "template_auction_001" ;
request . conditionId = "condition_001" ;
request . instanceIds . insert ( std :: make_pair < std :: string , std :: string > ( "item_instance_001" , "1" ));
hiroClient -> auctionsCreate ( session , request , onAuctionCreate , onError );
Placing a Bid on an Auction
# You can place a bid on an auction using the auctionsBid function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
void OnAuctionsBid ( const Hiro :: Auction & auction )
{
for ( auto it = auction . reward . items . begin (); it != auction . reward . items . end (); it ++ )
{
std :: cout << "Found codex item: " << it -> second . name << '\n' ;
}
}
void onError ( const Nakama :: NError & error )
{
std :: cout << Nakama :: toString ( error . code ) << ": " << error . message << '\n' ;
}
Hiro :: AuctionBidRequest request ;
request . id = "auction_instance_123" ;
request . version = "condition_001" ;
request . bid . currencies . insert ( std :: make_pair < std :: string , std :: string > ( "gold" , "1000" ));
hiroClient -> auctionsBid ( session , request , OnAuctionsBid , onError );
Canceling an Auction
# If an auction needs to be canceled before it ends, the auctionsCancel method can be used.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void OnAuctionsCancel ( const Hiro :: AuctionCancel & auctionCancel )
{
for ( auto it = auctionCancel . reward . items . begin (); it != auctionCancel . reward . items . end (); it ++ )
{
std :: cout << "Found codex item: " << it -> second . name << '\n' ;
}
}
void onError ( const Nakama :: NError & error )
{
std :: cout << Nakama :: toString ( error . code ) << ": " << error . message << '\n' ;
}
Hiro :: AuctionsCancelRequest request ;
request . id = "auction_instance_123" ;
hiroClient -> auctionsCancel ( session , request , OnAuctionsBid , onError );
Claiming a Winning Bid
# Once an auction has ended, the winning bidder can claim their item using auctionsClaimBid.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void OnAuctionsClaimBid ( const Hiro :: AuctionClaimBid & auctionClaimBid )
{
for ( auto it = auctionClaimBid . reward . items . begin (); it != auctionClaimBid . reward . items . end (); it ++ )
{
std :: cout << "Found codex item: " << it -> second . name << '\n' ;
}
}
void onError ( const Nakama :: NError & error )
{
std :: cout << Nakama :: toString ( error . code ) << ": " << error . message << '\n' ;
}
Hiro :: AuctionClaimBidRequest request ;
request . id = "auction_instance_123" ;
hiroClient -> auctionsClaimBid ( session , request , OnAuctionsBid , onError );
Listing Available Auctions
# You can list the currently available auctions using the auctionsList function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void OnAuctionsList ( const Hiro :: AuctionList & auctionList )
{
for ( auto it = auctions . begin (); it != auctions . end (); it ++ )
{
std :: cout << "Auction found: " << it -> second . id << '\n' ;
}
}
void onError ( const Nakama :: NError & error )
{
std :: cout << Nakama :: toString ( error . code ) << ": " << error . message << '\n' ;
}
Hiro :: AuctionListRequest request ;
hiroClient -> auctionsList ( session , request , OnAuctionsBid , onError );