Nakama C++ Client SDK 2.5.1
Client for Nakama Server
NRtClientInterface Class Referenceabstract

#include <NRtClientInterface.h>

Public Member Functions

virtual ~NRtClientInterface ()
 
virtual void tick ()=0
 
virtual void setListener (NRtClientListenerInterface *listener)=0
 
virtual void setUserData (void *userData)=0
 
virtual void * getUserData () const =0
 
virtual void connect (NSessionPtr session, bool createStatus, NRtClientProtocol protocol=NRtClientProtocol::Protobuf)=0
 
virtual bool isConnected () const =0
 
virtual void disconnect ()=0
 
virtual NRtTransportPtr getTransport () const =0
 
virtual void joinChat (const std::string &target, NChannelType type, const opt::optional< bool > &persistence=opt::nullopt, const opt::optional< bool > &hidden=opt::nullopt, std::function< void(NChannelPtr)> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void leaveChat (const std::string &channelId, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void writeChatMessage (const std::string &channelId, const std::string &content, std::function< void(const NChannelMessageAck &)> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void updateChatMessage (const std::string &channelId, const std::string &messageId, const std::string &content, std::function< void(const NChannelMessageAck &)> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void removeChatMessage (const std::string &channelId, const std::string &messageId, std::function< void(const NChannelMessageAck &)> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void createMatch (std::function< void(const NMatch &)> successCallback, RtErrorCallback errorCallback=nullptr)=0
 
virtual void joinMatch (const std::string &matchId, const NStringMap &metadata, std::function< void(const NMatch &)> successCallback, RtErrorCallback errorCallback=nullptr)=0
 
virtual void joinMatchByToken (const std::string &token, std::function< void(const NMatch &)> successCallback, RtErrorCallback errorCallback=nullptr)=0
 
virtual void leaveMatch (const std::string &matchId, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void addMatchmaker (const opt::optional< int32_t > &minCount=opt::nullopt, const opt::optional< int32_t > &maxCount=opt::nullopt, const opt::optional< std::string > &query=opt::nullopt, const NStringMap &stringProperties={}, const NStringDoubleMap &numericProperties={}, std::function< void(const NMatchmakerTicket &)> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void removeMatchmaker (const std::string &ticket, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void sendMatchData (const std::string &matchId, int64_t opCode, const NBytes &data, const std::vector< NUserPresence > &presences={})=0
 
virtual void followUsers (const std::vector< std::string > &userIds, std::function< void(const NStatus &)> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void unfollowUsers (const std::vector< std::string > &userIds, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void updateStatus (const std::string &status, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void rpc (const std::string &id, const opt::optional< std::string > &payload=opt::nullopt, std::function< void(const NRpc &)> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void acceptPartyMember (const std::string &partyId, NUserPresence &presence, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void addMatchmakerParty (const std::string &partyId, const std::string &query, int32_t minCount, int32_t maxCount, const NStringMap stringProperties={}, const NStringDoubleMap numericProperties={}, std::function< void(const NPartyMatchmakerTicket &)> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void closeParty (const std::string &partyId, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void createParty (bool open, int maxSize, std::function< void(const NParty &)> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void joinParty (const std::string &partyId, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void leaveParty (const std::string &partyId, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void listPartyJoinRequests (const std::string &partyId, std::function< void(const NPartyJoinRequest &)> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void promotePartyMember (const std::string &partyId, NUserPresence &partyMember, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void removeMatchmakerParty (const std::string &partyId, const std::string &ticket, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void removePartyMember (const std::string &partyId, NUserPresence &presence, std::function< void()> successCallback=nullptr, RtErrorCallback errorCallback=nullptr)=0
 
virtual void sendPartyData (const std::string &partyId, long opCode, NBytes &data)=0
 

Detailed Description

A real-time client interface to interact with Nakama server.

Constructor & Destructor Documentation

◆ ~NRtClientInterface()

virtual NRtClientInterface::~NRtClientInterface ( )
inlinevirtual

Member Function Documentation

◆ acceptPartyMember()

virtual void NRtClientInterface::acceptPartyMember ( const std::string &  partyId,
NUserPresence presence,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Accept a party member's request to join the party.

Parameters
partyIdThe party ID to accept the join request for.
presenceThe presence to accept as a party member.

◆ addMatchmaker()

virtual void NRtClientInterface::addMatchmaker ( const opt::optional< int32_t > &  minCount = opt::nullopt,
const opt::optional< int32_t > &  maxCount = opt::nullopt,
const opt::optional< std::string > &  query = opt::nullopt,
const NStringMap stringProperties = {},
const NStringDoubleMap numericProperties = {},
std::function< void(const NMatchmakerTicket &)>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Join the matchmaker pool and search for opponents on the server.

Parameters
minCountThe minimum number of players to compete against.
maxCountThe maximum number of players to compete against.
queryA matchmaker query to search for opponents.
stringPropertiesA set of k/v properties to provide in searches.
numericPropertiesA set of k/v numeric properties to provide in searches.

◆ addMatchmakerParty()

virtual void NRtClientInterface::addMatchmakerParty ( const std::string &  partyId,
const std::string &  query,
int32_t  minCount,
int32_t  maxCount,
const NStringMap  stringProperties = {},
const NStringDoubleMap  numericProperties = {},
std::function< void(const NPartyMatchmakerTicket &)>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Begin matchmaking as a party.

Parameters
partyIdParty ID.
queryFilter query used to identify suitable users.
minCountMinimum total user count to match together.
maxCountMaximum total user count to match together.
stringPropertiesString properties.
numericPropertiesNumeric properties.

◆ closeParty()

virtual void NRtClientInterface::closeParty ( const std::string &  partyId,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

End a party, kicking all party members and closing it.

Parameters
partyIdThe ID of the party.

◆ connect()

virtual void NRtClientInterface::connect ( NSessionPtr  session,
bool  createStatus,
NRtClientProtocol  protocol = NRtClientProtocol::Protobuf 
)
pure virtual

Connect to the server.

Parameters
sessionThe session of the user.
createStatusTrue if the socket should show the user as online to others.
protocolCommunication protocol. Default is Protobuf.

◆ createMatch()

virtual void NRtClientInterface::createMatch ( std::function< void(const NMatch &)>  successCallback,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Create a multiplayer match on the server.

◆ createParty()

virtual void NRtClientInterface::createParty ( bool  open,
int  maxSize,
std::function< void(const NParty &)>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Create a party.

Parameters
openWhether or not the party will require join requests to be approved by the party leader.
maxSizeMaximum number of party members.

◆ disconnect()

virtual void NRtClientInterface::disconnect ( )
pure virtual

Close the connection with the server.

◆ followUsers()

virtual void NRtClientInterface::followUsers ( const std::vector< std::string > &  userIds,
std::function< void(const NStatus &)>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Follow one or more users for status updates.

Parameters
userIdsThe user Ids to follow.

◆ getTransport()

virtual NRtTransportPtr NRtClientInterface::getTransport ( ) const
pure virtual

Get websocket transport which RtClient uses.

◆ getUserData()

virtual void * NRtClientInterface::getUserData ( ) const
pure virtual

Get user data.

Returns
The user data.

◆ isConnected()

virtual bool NRtClientInterface::isConnected ( ) const
pure virtual
Returns
True if connected to server.

◆ joinChat()

virtual void NRtClientInterface::joinChat ( const std::string &  target,
NChannelType  type,
const opt::optional< bool > &  persistence = opt::nullopt,
const opt::optional< bool > &  hidden = opt::nullopt,
std::function< void(NChannelPtr)>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Join a chat channel on the server.

Parameters
targetThe target channel to join.
typeThe type of channel to join.
persistenceTrue if chat messages should be stored.
hiddenTrue if the user should be hidden on the channel.

◆ joinMatch()

virtual void NRtClientInterface::joinMatch ( const std::string &  matchId,
const NStringMap metadata,
std::function< void(const NMatch &)>  successCallback,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Join a multiplayer match by ID.

Parameters
matchIdA match ID.

◆ joinMatchByToken()

virtual void NRtClientInterface::joinMatchByToken ( const std::string &  token,
std::function< void(const NMatch &)>  successCallback,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Join a multiplayer match with a matchmaker.

Parameters
tokenA matchmaker ticket result object.

◆ joinParty()

virtual void NRtClientInterface::joinParty ( const std::string &  partyId,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Join a party.

Parameters
partyIdParty ID.

◆ leaveChat()

virtual void NRtClientInterface::leaveChat ( const std::string &  channelId,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Leave a chat channel on the server.

Parameters
channelIdThe channel to leave.

◆ leaveMatch()

virtual void NRtClientInterface::leaveMatch ( const std::string &  matchId,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Leave a match on the server.

Parameters
matchIdThe match to leave.

◆ leaveParty()

virtual void NRtClientInterface::leaveParty ( const std::string &  partyId,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Leave the party.

Parameters
partyIdParty ID.

◆ listPartyJoinRequests()

virtual void NRtClientInterface::listPartyJoinRequests ( const std::string &  partyId,
std::function< void(const NPartyJoinRequest &)>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Request a list of pending join requests for a party.

Parameters
partyIdParty ID.

◆ promotePartyMember()

virtual void NRtClientInterface::promotePartyMember ( const std::string &  partyId,
NUserPresence partyMember,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Promote a new party leader.

Parameters
partyIdParty ID.
partyMemberThe presence of an existing party member to promote as the new leader.

◆ removeChatMessage()

virtual void NRtClientInterface::removeChatMessage ( const std::string &  channelId,
const std::string &  messageId,
std::function< void(const NChannelMessageAck &)>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Remove a chat message from a channel on the server.

Parameters
channelIdThe chat channel with the message.
messageIdThe ID of a chat message to remove.

◆ removeMatchmaker()

virtual void NRtClientInterface::removeMatchmaker ( const std::string &  ticket,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Leave the matchmaker pool by ticket.

Parameters
ticketThe ticket returned by the matchmaker on join. See NMatchmakerTicket.ticket.

◆ removeMatchmakerParty()

virtual void NRtClientInterface::removeMatchmakerParty ( const std::string &  partyId,
const std::string &  ticket,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Cancel a party matchmaking process using a ticket.

Parameters
partyIdParty ID.
ticketThe ticket to cancel.

◆ removePartyMember()

virtual void NRtClientInterface::removePartyMember ( const std::string &  partyId,
NUserPresence presence,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Kick a party member, or decline a request to join.

Parameters
partyIdParty ID to remove/reject from.
presenceThe presence to remove or reject.

◆ rpc()

virtual void NRtClientInterface::rpc ( const std::string &  id,
const opt::optional< std::string > &  payload = opt::nullopt,
std::function< void(const NRpc &)>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Send an RPC message to the server.

Parameters
idThe ID of the function to execute.
payloadThe string content to send to the server.

◆ sendMatchData()

virtual void NRtClientInterface::sendMatchData ( const std::string &  matchId,
int64_t  opCode,
const NBytes data,
const std::vector< NUserPresence > &  presences = {} 
)
pure virtual

Send a state change to a match on the server.

When no presences are supplied the new match state will be sent to all presences.

Parameters
matchIdThe Id of the match.
opCodeAn operation code for the match state.
dataThe new state to send to the match.
presencesThe presences in the match to send the state.

◆ sendPartyData()

virtual void NRtClientInterface::sendPartyData ( const std::string &  partyId,
long  opCode,
NBytes data 
)
pure virtual

Send data to a party.

Parameters
partyIdParty ID to send to.
opCodeOp code value.
dataThe input data to send from the byte buffer, if any.

◆ setListener()

virtual void NRtClientInterface::setListener ( NRtClientListenerInterface listener)
pure virtual

Set events listener

Parameters
listenerThe listener of client events.

◆ setUserData()

virtual void NRtClientInterface::setUserData ( void *  userData)
pure virtual

Set user data.

Client just holds this data so you can receive it later when you need it.

Parameters
userDataThe user data.

◆ tick()

virtual void NRtClientInterface::tick ( )
pure virtual

Pumps requests queue in your thread. Call it periodically, each 50 ms is ok.

◆ unfollowUsers()

virtual void NRtClientInterface::unfollowUsers ( const std::vector< std::string > &  userIds,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Unfollow status updates for one or more users.

Parameters
userIdsThe ids of users to unfollow.

◆ updateChatMessage()

virtual void NRtClientInterface::updateChatMessage ( const std::string &  channelId,
const std::string &  messageId,
const std::string &  content,
std::function< void(const NChannelMessageAck &)>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Update a chat message to a channel on the server.

Parameters
channelIdThe ID of the chat channel with the message.
messageIdThe ID of the message to update.
contentThe content update for the message. Must be a JSON object.

◆ updateStatus()

virtual void NRtClientInterface::updateStatus ( const std::string &  status,
std::function< void()>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Update the user's status online.

Parameters
statusThe new status of the user.

◆ writeChatMessage()

virtual void NRtClientInterface::writeChatMessage ( const std::string &  channelId,
const std::string &  content,
std::function< void(const NChannelMessageAck &)>  successCallback = nullptr,
RtErrorCallback  errorCallback = nullptr 
)
pure virtual

Send a chat message to a channel on the server.

Parameters
channelIdThe channel to send on.
contentThe content of the chat message. Must be a JSON object.

The documentation for this class was generated from the following file: