26 #include "network/protocol_enum.hpp"
27 #include "utils/no_copy.hpp"
49 virtual void callback(
Protocol *protocol) = 0;
52 namespace ProtocolUtils
54 NetworkString* getNetworkString(ProtocolType type,
size_t capacity = 16);
66 class Protocol :
public std::enable_shared_from_this<Protocol>,
99 bool reliable =
true);
Class that must be inherited to pass objects to protocols.
Definition: protocol.hpp:44
Class representing an event that need to pass trough the system. This is used to remove ENet dependen...
Definition: event.hpp:73
A new implementation of NetworkString, which has a fixed format: Byte 0: The type of the message,...
Definition: network_string.hpp:422
Utility class, you can inherit from this class to disallow the assignment operator and copy construct...
Definition: no_copy.hpp:26
Abstract class used to define the global protocol functions.
Definition: protocol.hpp:68
ProtocolType m_type
The type of the protocol.
Definition: protocol.hpp:71
virtual void asynchronousUpdate()=0
Called by the protocol listener as often as possible.
bool checkDataSize(Event *event, unsigned int minimum_size)
functions to check incoming data easily
Definition: protocol.cpp:65
virtual bool notifyEventAsynchronous(Event *event)
Notify a protocol matching the Event type of that event.
Definition: protocol.hpp:113
void setHandleConnections(bool b)
Sets if this protocol should receive connection events.
Definition: protocol.hpp:120
bool m_handle_disconnections
TRue if this protocol should recceiver disconnection events.
Definition: protocol.hpp:77
Protocol(ProtocolType type)
Constructor Sets the basic protocol parameters, as the callback object and the protocol type.
Definition: protocol.cpp:46
virtual void requestTerminate()
Submits a request to the ProtocolManager to terminate this protocol.
Definition: protocol.cpp:89
void sendMessageToPeers(NetworkString *message, bool reliable=true)
Sends a message to all validated peers in game, encrypt the message if needed.
Definition: protocol.cpp:101
bool m_handle_connections
True if this protocol should receive connection events.
Definition: protocol.hpp:74
void setHandleDisconnections(bool b)
Sets if this protocol should receive disconnection events.
Definition: protocol.hpp:123
virtual void setup()=0
Called when the protocol is going to start.
virtual bool notifyEvent(Event *event)
Notify a protocol matching the Event type of that event.
Definition: protocol.hpp:107
virtual bool handleConnects() const
Return true if this protocol should be informed about connects.
Definition: protocol.hpp:126
void sendMessageToPeersInServer(NetworkString *message, bool reliable=true)
Sends a message to all validated peers in server, encrypt the message if needed.
Definition: protocol.cpp:112
ProtocolType getProtocolType() const
Method to get a protocol's type.
Definition: protocol.hpp:117
virtual void update(int ticks)=0
Called by the protocol listener, synchronously with the main loop.
virtual bool handleDisconnects() const
Return true if this protocol should be informed about disconnects.
Definition: protocol.hpp:129
virtual ~Protocol()
Destructor.
Definition: protocol.cpp:56
void sendToServer(NetworkString *message, bool reliable=true)
Sends a message from a client to the server.
Definition: protocol.cpp:121
virtual void requestStart()
Starts a request in the protocol manager to start this protocol.
Definition: protocol.cpp:80
Represents a peer. This class is used to interface the ENetPeer structure.
Definition: stk_peer.hpp:76
Declares the general types that are used by the network.