Implemented socket message templates. (#40)

Implemented socket message templates to support broadcast (shared_ptr) and to achieve buffer zero-copy.
This commit is contained in:
Ravin Perera
2019-10-23 13:04:57 +05:30
committed by GitHub
parent b4237f1285
commit 61b38bb0a0
16 changed files with 636 additions and 539 deletions

View File

@@ -7,28 +7,30 @@ namespace sock
{
// Forward declaration
template <class T>
class socket_session;
/**
* Represents a WebSocket sessions handler. Can inherit from this class and access websocket events
*/
template <class T>
class socket_session_handler
{
public:
/**
* Executes on initiation of a new connection
*/
virtual void on_connect(socket_session *session) = 0;
virtual void on_connect(socket_session<T> *session) = 0;
/**
* Executes on recieval of new message
*/
virtual void on_message(socket_session *session, std::string &&message) = 0;
virtual void on_message(socket_session<T> *session, std::string_view message) = 0;
/**
* Executes on websocket connection close
*/
virtual void on_close(socket_session *session) = 0;
virtual void on_close(socket_session<T> *session) = 0;
};
} // namespace sock