|
R-Type 0.1
|
Game level layer over NetworkServer that decodes client messages and encodes server messages. More...
#include <Server.hpp>
Classes | |
| struct | ConnectionEvent |
| Client connection or disconnection. More... | |
| struct | InputEvent |
| Input message received from a client. More... | |
| struct | QueryEntityEvent |
| QueryEntity message received from a client. More... | |
Public Member Functions | |
| Server (std::uint16_t port) | |
| Creates the server on a UDP port, without starting it. | |
| ~Server () | |
| Stops the network thread. | |
| void | start () |
| Starts the network thread. | |
| void | stop () |
| Stops the network thread. | |
| void | send (std::uint32_t connectionId, const std::vector< std::uint8_t > &payload) |
| Sends already encoded messages to a client. | |
| bool | pollInput (InputEvent &event) |
| Pops the oldest Input message. | |
| bool | pollConnectionEvent (ConnectionEvent &event) |
| Pops the oldest connection change. | |
| bool | pollQueryEntity (QueryEntityEvent &event) |
| Pops the oldest QueryEntity message. | |
| bool | sendCreateEntity (std::uint32_t connectionId, const protocol::CreateEntityPayload &payload) |
| Sends a CreateEntity message. | |
| bool | sendDestroyEntity (std::uint32_t connectionId, const protocol::DestroyEntityPayload &payload) |
| Sends a DestroyEntity message. | |
| bool | sendSnapshot (std::uint32_t connectionId, const protocol::SnapshotPayload &payload) |
| Sends a Snapshot message. | |
Game level layer over NetworkServer that decodes client messages and encodes server messages.
Decoded messages are pushed by the network thread into mutex protected queues that the game loop drains with the poll methods.
|
explicit |
Creates the server on a UDP port, without starting it.
| port | Local port to listen on. |
| void rtype::server::Server::send | ( | std::uint32_t | connectionId, |
| const std::vector< std::uint8_t > & | payload ) |
Sends already encoded messages to a client.
| connectionId | Destination connection. |
| payload | Messages, headers included. |
| bool rtype::server::Server::pollInput | ( | InputEvent & | event | ) |
Pops the oldest Input message.
| event | Receives the message. |
| bool rtype::server::Server::pollConnectionEvent | ( | ConnectionEvent & | event | ) |
Pops the oldest connection change.
| event | Receives the change. |
| bool rtype::server::Server::pollQueryEntity | ( | QueryEntityEvent & | event | ) |
Pops the oldest QueryEntity message.
| event | Receives the message. |
| bool rtype::server::Server::sendCreateEntity | ( | std::uint32_t | connectionId, |
| const protocol::CreateEntityPayload & | payload ) |
Sends a CreateEntity message.
| connectionId | Destination connection. |
| payload | Message payload. |
| bool rtype::server::Server::sendDestroyEntity | ( | std::uint32_t | connectionId, |
| const protocol::DestroyEntityPayload & | payload ) |
Sends a DestroyEntity message.
| connectionId | Destination connection. |
| payload | Message payload. |
| bool rtype::server::Server::sendSnapshot | ( | std::uint32_t | connectionId, |
| const protocol::SnapshotPayload & | payload ) |
Sends a Snapshot message.
| connectionId | Destination connection. |
| payload | Message payload. |