Skip to content

Class netWorth::ServerInterface

ClassList > netWorth > ServerInterface

More...

  • #include <ServerInterface.hpp>

Inherits the following classes: netWorth::NetworkingInterface

Public Functions

Type Name
bool Initialize () override
size_t SelectAction (const cse491::WorldGrid & grid, const cse491::type_options_t & typeOptions, const cse491::item_map_t & itemMap, const cse491::agent_map_t & agentMap) override
ServerInterface (size_t id, const std::string & name)
Port used by server manager to handle world updates.

Public Functions inherited from netWorth::NetworkingInterface

See netWorth::NetworkingInterface

Type Name
NetworkingInterface (size_t id, const std::string & name)
the destination port of the machine this communicates with
virtual bool bindSocket (UdpSocket & socket, unsigned short port)
virtual UdpSocket * getSocket ()
virtual bool receivePacket (Packet & pkt, std::optional< IpAddress > & sender, unsigned short & port)
virtual bool sendPacket (Packet packet, IpAddress destAddr, const unsigned short port)

Public Static Functions

Type Name
Packet gridToPacket (const cse491::WorldGrid & grid, const cse491::type_options_t & typeOptions, const cse491::item_map_t & itemMap, const cse491::agent_map_t & agentMap)

Protected Attributes inherited from netWorth::NetworkingInterface

See netWorth::NetworkingInterface

Type Name
std::optional< IpAddress > m_ip
The socket we are going to make our connection.
unsigned short m_port = = 0
the destination IP of the machine this communicates with
UdpSocket m_socket

Detailed Description

The server that will be running and that allows clients to connect to, acts as a sort of clone

Public Functions Documentation

function Initialize

inline bool netWorth::ServerInterface::Initialize () override

Function that initializes server interface

Returns:

boolean stating whether initialization was successful or not

function SelectAction

inline size_t netWorth::ServerInterface::SelectAction (
    const cse491::WorldGrid & grid,
    const cse491::type_options_t & typeOptions,
    const cse491::item_map_t & itemMap,
    const cse491::agent_map_t & agentMap
) override

Choose action for player agent (mirror client agent)

Parameters:

  • grid the server-side grid
  • typeOptions different cell types of the world
  • itemMap the items that may be apart of the grid
  • agentMap the agents that may be apart of the grid

Returns:

action ID of the interface

function ServerInterface

Port used by server manager to handle world updates.

inline netWorth::ServerInterface::ServerInterface (
    size_t id,
    const std::string & name
) 

Default constructor (AgentBase)

Parameters:

  • id agent ID
  • name agent name

Public Static Functions Documentation

function gridToPacket

static inline Packet netWorth::ServerInterface::gridToPacket (
    const cse491::WorldGrid & grid,
    const cse491::type_options_t & typeOptions,
    const cse491::item_map_t & itemMap,
    const cse491::agent_map_t & agentMap
) 

The grid that will be sent to the client from the server after the connection so the client can start asking to make moves

Parameters:

  • grid the grid to send to the server
  • typeOptions different cell types of the world
  • itemMap the items that may be apart of the grid
  • agentMap the agents that may be apart of the grid

Returns:

the grid that will be sent to the client


The documentation for this class was generated from the following file source/Interfaces/NetWorth/server/ServerInterface.hpp