Rehti MMORPG  1.0.0
Rehti MMORPG is a free and open source MMORPG game.
Client Class Reference

#include <Client.hpp>

Collaboration diagram for Client:
Collaboration graph

Public Member Functions

 Client (std::string ip, std::string port)
 
boost::asio::awaitable< bool > connect ()
 Connects to the server. More...
 
boost::asio::awaitable< void > attack (const int &targetId)
 Sends an attack message to the server. More...
 
boost::asio::awaitable< void > move (const int &x, const int &y)
 Sends a move message to the server. More...
 
boost::asio::awaitable< void > interactWithObject (const int &objectId)
 Sends an object interaction message to the server. More...
 
boost::asio::awaitable< void > pickUpItem (const int &itemId, const int &x, const int &y)
 Sends a PickUpItemMessage to the server. More...
 
boost::asio::awaitable< void > useItem (const int itemInstanceId)
 Send a UseItemMessage for item with given instance id. More...
 
boost::asio::awaitable< void > dropItem (const int itemInstanceId)
 Send a DropItemMessage for item with given instance id. More...
 
boost::asio::awaitable< void > unequipItem (const int itemInstanceId)
 Send a UnequipMessage for item with given instance id. More...
 
boost::asio::awaitable< void > talk (const int &npcId)
 Send talk message to the server. More...
 
void start ()
 Starts the client. More...
 
boost::asio::awaitable< bool > login ()
 Prompts user for login information and sends a LoginMessage with that information. Currently only username used for identification. More...
 
void processMessages ()
 Processes messages from the server. More...
 
void startGraphics ()
 Starts the graphics library. More...
 
void handleMouseClick (const Hit &hit)
 Handles a mouse click hit on the graphics window. More...
 

Private Attributes

boost::asio::io_context ioContextM
 
boost::asio::ip::tcp::resolver resolverM
 
boost::asio::ip::tcp::resolver::results_type endpointsM
 
boost::asio::executor_work_guard< boost::asio::io_context::executor_type > workGuardM
 
MessageQueue messagesM
 
std::unique_ptr< Connection > connectionM
 
std::thread graphicsThreadM
 
std::thread connectionThreadM
 
std::thread ioThreadM
 
RehtiGraphicspGraphLibM
 
std::condition_variable graphLibReadyM
 GraphLib ready lock. More...
 
bool graphLibReadyFlagM = false
 GraphLib ready flag. More...
 
std::mutex graphLibMutexM
 
RehtiAudio audioLibM
 
Hit lastHitM
 Last detected hit from a mouse click. More...
 
GameStateMessage prevGameStateMsgM
 Previous game state message. More...
 
AssetCacheassetCacheM = AssetCache::getInstance()
 

Constructor & Destructor Documentation

◆ Client()

Client::Client ( std::string  ip,
std::string  port 
)
Here is the call graph for this function:

Member Function Documentation

◆ attack()

boost::asio::awaitable< void > Client::attack ( const int &  targetId)

Sends an attack message to the server.

Parameters
targetIdId of the target entity
Here is the caller graph for this function:

◆ connect()

boost::asio::awaitable< bool > Client::connect ( )

Connects to the server.

Returns
true if connection was successful. False otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dropItem()

boost::asio::awaitable< void > Client::dropItem ( const int  itemInstanceId)

Send a DropItemMessage for item with given instance id.

Parameters
itemInstanceId
Here is the caller graph for this function:

◆ handleMouseClick()

void Client::handleMouseClick ( const Hit hit)

Handles a mouse click hit on the graphics window.

Parameters
hitcontains hit information. See Hit.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ interactWithObject()

boost::asio::awaitable< void > Client::interactWithObject ( const int &  objectId)

Sends an object interaction message to the server.

Parameters
objectIdthe id of the object to interact with
Here is the caller graph for this function:

◆ login()

boost::asio::awaitable< bool > Client::login ( )

Prompts user for login information and sends a LoginMessage with that information. Currently only username used for identification.

Returns
True if user inputs a valid username, false otherwise.
Here is the caller graph for this function:

◆ move()

boost::asio::awaitable< void > Client::move ( const int &  x,
const int &  y 
)

Sends a move message to the server.

Parameters
xcoordinate to move to
ycoordinate to move to
Here is the caller graph for this function:

◆ pickUpItem()

boost::asio::awaitable< void > Client::pickUpItem ( const int &  itemId,
const int &  x,
const int &  y 
)

Sends a PickUpItemMessage to the server.

Parameters
itemIdinstance id of the item to be picked up
xx coordinate of the item
yy coordinate of the item
Here is the caller graph for this function:

◆ processMessages()

void Client::processMessages ( )

Processes messages from the server.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ start()

void Client::start ( )

Starts the client.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startGraphics()

void Client::startGraphics ( )

Starts the graphics library.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ talk()

boost::asio::awaitable< void > Client::talk ( const int &  npcId)

Send talk message to the server.

Parameters
npcIdId of the npc to talk to
Here is the caller graph for this function:

◆ unequipItem()

boost::asio::awaitable< void > Client::unequipItem ( const int  itemInstanceId)

Send a UnequipMessage for item with given instance id.

Parameters
itemInstanceId
Here is the caller graph for this function:

◆ useItem()

boost::asio::awaitable< void > Client::useItem ( const int  itemInstanceId)

Send a UseItemMessage for item with given instance id.

Parameters
itemInstanceId
Here is the caller graph for this function:

Member Data Documentation

◆ assetCacheM

AssetCache& Client::assetCacheM = AssetCache::getInstance()
private

◆ audioLibM

RehtiAudio Client::audioLibM
private

◆ connectionM

std::unique_ptr<Connection> Client::connectionM
private

◆ connectionThreadM

std::thread Client::connectionThreadM
private

◆ endpointsM

boost::asio::ip::tcp::resolver::results_type Client::endpointsM
private

◆ graphicsThreadM

std::thread Client::graphicsThreadM
private

◆ graphLibMutexM

std::mutex Client::graphLibMutexM
private

◆ graphLibReadyFlagM

bool Client::graphLibReadyFlagM = false
private

GraphLib ready flag.

◆ graphLibReadyM

std::condition_variable Client::graphLibReadyM
private

GraphLib ready lock.

◆ ioContextM

boost::asio::io_context Client::ioContextM
private

◆ ioThreadM

std::thread Client::ioThreadM
private

◆ lastHitM

Hit Client::lastHitM
private

Last detected hit from a mouse click.

◆ messagesM

MessageQueue Client::messagesM
private

◆ pGraphLibM

RehtiGraphics* Client::pGraphLibM
private

◆ prevGameStateMsgM

GameStateMessage Client::prevGameStateMsgM
private

Previous game state message.

◆ resolverM

boost::asio::ip::tcp::resolver Client::resolverM
private

◆ workGuardM

boost::asio::executor_work_guard<boost::asio::io_context::executor_type> Client::workGuardM
private

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