Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. /*
  2. ** EPITECH PROJECT, 2018
  3. ** Rtype
  4. ** File description:
  5. ** rtype
  6. */
  7.  
  8. #ifndef UDPSERVER_H_
  9. #define UDPSERVER_H_
  10.  
  11. #include <boost/array.hpp>
  12. #include <boost/bind.hpp>
  13. #include <boost/shared_ptr.hpp>
  14. #include <boost/asio.hpp>
  15. #include <boost/asio/ip/udp.hpp>
  16. #include <queue>
  17. #include "MessageUDP.h"
  18.  
  19. namespace Rtype {
  20. class UDPServer {
  21. public:
  22. UDPServer(boost::asio::io_service& io_service, int port);
  23. ~UDPServer();
  24.  
  25. std::unique_ptr<IMessageUDP> popMessage();
  26. void sendMessage(std::unique_ptr<IMessageUDP> message);
  27.  
  28. private:
  29. void start_receive();
  30.  
  31. void handle_receive(const boost::system::error_code& error, std::size_t /*bytes_transferred*/);
  32.  
  33. void handle_send(const boost::system::error_code& /*error*/,
  34. std::size_t /*bytes_transferred*/)
  35. {
  36. }
  37.  
  38. boost::asio::ip::udp::socket socket_;
  39. boost::asio::ip::udp::endpoint remote_endpoint_;
  40. boost::array<char, 100> buffer;
  41. std::queue<std::unique_ptr<IMessageUDP>> _receivedMessages;
  42.  
  43. bool _isConnected;
  44. };
  45. }
  46.  
  47.  
  48. #endif /* !UDPSERVER_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement