![]() |
Leviathan
0.8.0.0
Leviathan game engine
|
Class that encapsulates common networking functionality that is required by all networked programs. More...
#include <NetworkInterface.h>
Public Member Functions | |
DLLEXPORT | NetworkInterface (NETWORKED_TYPE type) |
virtual DLLEXPORT | ~NetworkInterface () |
virtual DLLEXPORT std::vector< std::shared_ptr< Connection > > & | GetClientConnections ()=0 |
If this is a server returns all the clients. More... | |
virtual DLLEXPORT void | HandleRequestPacket (const std::shared_ptr< NetworkRequest > &request, Connection &connection)=0 |
Called by ConnectionInfo to handle incoming packets. More... | |
virtual DLLEXPORT bool | PreHandleResponse (const std::shared_ptr< NetworkResponse > &response, SentNetworkThing *originalrequest, Connection &connection) |
Called by ConnectionInfo to verify that a response is good. More... | |
virtual DLLEXPORT void | HandleResponseOnlyPacket (const std::shared_ptr< NetworkResponse > &message, Connection &connection)=0 |
Called by ConnectionInfo when it receives a response without a matching request object. More... | |
virtual DLLEXPORT bool | CanConnectionTerminate (Connection &connection) |
Called by Connection just before terminating an inactive connection. More... | |
virtual DLLEXPORT void | TickIt ()=0 |
Should be used to update various network interfaces. More... | |
virtual DLLEXPORT void | CloseDown ()=0 |
Called when the program is closing. More... | |
DLLEXPORT void | VerifyType (NETWORKED_TYPE type) const |
Asserts if types don't match. More... | |
NetworkHandler * | GetOwner () |
Protected Member Functions | |
virtual bool | _CustomHandleRequestPacket (const std::shared_ptr< NetworkRequest > &request, Connection &connection) |
virtual bool | _CustomHandleResponseOnlyPacket (const std::shared_ptr< NetworkResponse > &message, Connection &connection) |
DLLEXPORT bool | _HandleDefaultRequest (const std::shared_ptr< NetworkRequest > &request, Connection &connectiontosendresult) |
Utility function for subclasses to call for default handling. More... | |
DLLEXPORT bool | _HandleDefaultResponseOnly (const std::shared_ptr< NetworkResponse > &message, Connection &connection) |
Utility function for subclasses to call for default handling of non-request responses. More... | |
DLLEXPORT void | SetOwner (NetworkHandler *owner) |
Protected Attributes | |
NETWORKED_TYPE | OurNetworkType |
NetworkHandler * | Owner = nullptr |
Class that encapsulates common networking functionality that is required by all networked programs.
Definition at line 18 of file NetworkInterface.h.
DLLEXPORT NetworkInterface::NetworkInterface | ( | NETWORKED_TYPE | type | ) |
Definition at line 16 of file NetworkInterface.cpp.
|
virtual |
Definition at line 18 of file NetworkInterface.cpp.
|
inlineprotectedvirtual |
Definition at line 93 of file NetworkInterface.h.
|
inlineprotectedvirtual |
Definition at line 99 of file NetworkInterface.h.
|
protected |
Utility function for subclasses to call for default handling.
Handles default types of request packages and returns true if processed.
Definition at line 38 of file NetworkInterface.cpp.
|
protected |
Utility function for subclasses to call for default handling of non-request responses.
Handles default types of response packages and returns true if processed.
Definition at line 99 of file NetworkInterface.cpp.
|
virtual |
Called by Connection just before terminating an inactive connection.
Return true if you want to allow the connection to close (it will close before next packet receive update) By default will allow all requesting connections to terminate.
Definition at line 149 of file NetworkInterface.cpp.
|
pure virtual |
Called when the program is closing.
Implemented in Leviathan::NetworkClientInterface, Leviathan::NetworkServerInterface, and Leviathan::NetworkMasterServerInterface.
|
pure virtual |
If this is a server returns all the clients.
Implemented in Leviathan::NetworkClientInterface, Leviathan::NetworkServerInterface, and Leviathan::NetworkMasterServerInterface.
|
inline |
Definition at line 86 of file NetworkInterface.h.
|
pure virtual |
Called by ConnectionInfo to handle incoming packets.
This function is responsible for interpreting the packet data and generating a response. If the response could take a long time to generate it is recommended to queue a task to the ThreadingManager.
Implemented in Leviathan::NetworkClientInterface, Leviathan::NetworkServerInterface, and Leviathan::NetworkMasterServerInterface.
Definition at line 27 of file NetworkInterface.cpp.
|
pure virtual |
Called by ConnectionInfo when it receives a response without a matching request object.
This is called when the host on the connection sends a response without a matching request. Usually the other program instance wants us to do something without expecting a response, for example they could want us to add a new message to our inbox without expecting a response (other than an ack which is automatically sent) from us. The function can optionally ignore keepalive acks (to reduce spam between clients) by setting dontmarkasreceived as true. This function shouldn't throw any exceptions.
Implemented in Leviathan::NetworkClientInterface, Leviathan::NetworkServerInterface, and Leviathan::NetworkMasterServerInterface.
|
virtual |
Called by ConnectionInfo to verify that a response is good.
By default this will always return true, but that can be overloaded to return false if the response is no good When returning false the connection will pretend that the response never arrived and possibly resends the request
Definition at line 20 of file NetworkInterface.cpp.
|
protected |
Definition at line 160 of file NetworkInterface.cpp.
|
pure virtual |
Should be used to update various network interfaces.
Implemented in Leviathan::NetworkClientInterface, Leviathan::NetworkServerInterface, and Leviathan::NetworkMasterServerInterface.
DLLEXPORT void NetworkInterface::VerifyType | ( | NETWORKED_TYPE | type | ) | const |
Asserts if types don't match.
Definition at line 155 of file NetworkInterface.cpp.
|
protected |
Definition at line 122 of file NetworkInterface.h.
|
protected |
Definition at line 123 of file NetworkInterface.h.