-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServerCode.h
More file actions
53 lines (42 loc) · 1.4 KB
/
Copy pathServerCode.h
File metadata and controls
53 lines (42 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <iostream>
#include <string>
#include <boost/array.hpp>
#include <boost/bind/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
#include <boost/asio.hpp>
#include <boost/thread.hpp>
#include <queue>
using boost::asio::ip::udp;
class ServerCode
{
public:
ServerCode(boost::signals2::signal<void()>* bufferEvent, boost::asio::io_context& io_context, std::mutex* m, std::queue<boost::array<unsigned char, 1>>* bufferQueue)
: socket(io_context, udp::endpoint(udp::v4(), 23000))
{
bufferQueues = bufferQueue;
mMutex = m;
bufferPointer = bufferEvent;
start_receive();
}
void PushQueue(const boost::array<unsigned char, 1> bufferToPush);
boost::array<unsigned char, 1> getRecv_Buffer();
const boost::array<unsigned char, 1> BufferFactory();
void StartSend();
private:
void handle_receive(const boost::system::error_code& error,
std::size_t /*bytes_transferred*/);
void HandleSend(boost::shared_ptr<boost::array<unsigned char, 1>> /*message*/,
const boost::system::error_code& /*error*/,
std::size_t /*bytes_transferred*/);
void start_receive();
udp::socket socket;
udp::endpoint recvEP;
udp::endpoint sendEP;
std::string output;
boost::array<unsigned char, 1> recvBuffer;
boost::signals2::signal<void()>* bufferPointer;
std::mutex* mMutex;
std::queue<boost::array<unsigned char, 1>>* bufferQueues;
};