Babel
Epitech's C++ VoIP project
ITCPServer.hpp
Go to the documentation of this file.
1 //
2 // Created by cbihan on 29/09/2021.
3 //
4 
5 #pragma once
6 
7 #include <cstdint>
8 #include <memory>
9 #include <string>
10 #include <vector>
11 #include "Message.hpp"
12 #include "Utilities/TSQueue.hpp"
14 
15 namespace Babel
16 {
17  template<typename T>
18  class ITCPServer
19  {
20  public:
21 
23  virtual bool start(uint16_t port) = 0;
24 
26  virtual void stop() = 0;
27 
29  virtual void messageClient(std::shared_ptr<ITCPConnection<T>> client, const Message<T> &msg) = 0;
30 
32  virtual void messageAllClients(const Message<T> &msg) = 0;
33 
35  virtual void update(uint64_t nbMessagesToProcess, bool wait) = 0;
36 
39  virtual bool onClientConnect(std::shared_ptr<ITCPConnection<T>> client) = 0;
40 
42  virtual void onClientDisconnect(std::shared_ptr<ITCPConnection<T>> client) = 0;
43 
45  virtual void onMessage(std::shared_ptr<ITCPConnection<T>> client, Message<T> &msg) = 0;
46 
48  virtual ~ITCPServer() = default;
49  };
50 }
Message.hpp
TSQueue.hpp
Babel::ITCPServer::~ITCPServer
virtual ~ITCPServer()=default
default dtor
Babel::ITCPServer::messageClient
virtual void messageClient(std::shared_ptr< ITCPConnection< T >> client, const Message< T > &msg)=0
Send a message to the specified client.
ITCPConnection.hpp
Babel::Message
Definition: Message.hpp:46
Babel::ITCPServer::onClientDisconnect
virtual void onClientDisconnect(std::shared_ptr< ITCPConnection< T >> client)=0
Called when a client disconnect.
Babel
Definition: IAudioManager.hpp:13
Babel::ITCPServer::onMessage
virtual void onMessage(std::shared_ptr< ITCPConnection< T >> client, Message< T > &msg)=0
Called when we received a message from a client.
Babel::ITCPServer::stop
virtual void stop()=0
Stop the server.
Babel::ITCPConnection
Definition: ITCPConnection.hpp:16
Babel::ITCPServer::messageAllClients
virtual void messageAllClients(const Message< T > &msg)=0
Send a message to all connected clients.
Babel::ITCPServer
Definition: ITCPServer.hpp:18
Babel::ITCPServer::update
virtual void update(uint64_t nbMessagesToProcess, bool wait)=0
Forces the server to call callbacks.
Babel::ITCPServer::onClientConnect
virtual bool onClientConnect(std::shared_ptr< ITCPConnection< T >> client)=0
Called when a client connect.
Babel::ITCPServer::start
virtual bool start(uint16_t port)=0
Starts the server on indicated port.