Wrath of Zeus
Made by Torchlight Games for CSE 125 SP24
Loading...
Searching...
No Matches
Public Member Functions
Session Class Reference

#include <session.hpp>

Inheritance diagram for Session:

Public Member Functions

 Session (tcp::socket socket, SessionInfo info)
 
 ~Session ()
 
bool isOkay () const
 
std::vector< EventhandleAllReceivedPackets ()
 
bool connectTo (basic_resolver_results< class boost::asio::ip::tcp > endpoints)
 
void sendPacket (std::shared_ptr< PackagedPacket > packet)
 
void sendEvent (Event evt)
 
const SessionInfogetInfo () const
 
void setDM (bool is_dm)
 

Detailed Description

A class which wraps around the concept of a Client <-> Server relationship. This works from both the client perpsective and the Server perspective. It essentially provides a wrapper around a tcp::socket and lets us easily send and receive our packet types.

Constructor & Destructor Documentation

◆ Session()

Session::Session ( tcp::socket  socket,
SessionInfo  info 
)

Constructs a new session, with the specified info

Parameters
socketThe boost asio socket which is already open and contains the connection.
infoSession Information

◆ ~Session()

Session::~Session ( )

Member Function Documentation

◆ connectTo()

bool Session::connectTo ( basic_resolver_results< class boost::asio::ip::tcp >  endpoints)

Connects to the ip

Returns
true/false if the connection was successful

◆ getInfo()

const SessionInfo & Session::getInfo ( ) const

Get the information associated with this session.

◆ handleAllReceivedPackets()

std::vector< Event > Session::handleAllReceivedPackets ( )

handles all of the incoming packets and puts the events in the event queue, which you can get by calling getEvents

Returns
list of all received events

◆ isOkay()

bool Session::isOkay ( ) const
Returns
true if there has been no fatal socket error, false otherwise

◆ sendEvent()

void Session::sendEvent ( Event  evt)

Sends an event on the socket after packaging it into the packet format.

Parameters
evtThe event object to send

◆ sendPacket()

void Session::sendPacket ( std::shared_ptr< PackagedPacket packet)

Puts a packet in the queue of packets to send

Parameters
packetThe packet to send.

◆ setDM()

void Session::setDM ( bool  is_dm)

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