Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ** EPITECH PROJECT, 2018
- ** Rtype
- ** File description:
- ** rtype
- */
- #ifndef UDPSERVER_H_
- #define UDPSERVER_H_
- #include <boost/array.hpp>
- #include <boost/bind.hpp>
- #include <boost/shared_ptr.hpp>
- #include <boost/asio.hpp>
- #include <boost/asio/ip/udp.hpp>
- #include <queue>
- #include "MessageUDP.h"
- namespace Rtype {
- class UDPServer {
- public:
- UDPServer(boost::asio::io_service& io_service, int port);
- ~UDPServer();
- std::unique_ptr<IMessageUDP> popMessage();
- void sendMessage(std::unique_ptr<IMessageUDP> message);
- private:
- void start_receive();
- void handle_receive(const boost::system::error_code& error, std::size_t /*bytes_transferred*/);
- void handle_send(const boost::system::error_code& /*error*/,
- std::size_t /*bytes_transferred*/)
- {
- }
- boost::asio::ip::udp::socket socket_;
- boost::asio::ip::udp::endpoint remote_endpoint_;
- boost::array<char, 100> buffer;
- std::queue<std::unique_ptr<IMessageUDP>> _receivedMessages;
- bool _isConnected;
- };
- }
- #endif /* !UDPSERVER_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement