Просмотр исходного кода

src/network cleaned, TODO: bitmessage rework

mikymod 12 лет назад
Родитель
Сommit
b8c2c78835
4 измененных файлов с 0 добавлено и 915 удалено
  1. 0 545
      src/network/AsyncConnection.cpp
  2. 0 179
      src/network/AsyncConnection.h
  3. 0 138
      src/network/PacketQueue.cpp
  4. 0 53
      src/network/PacketQueue.h

+ 0 - 545
src/network/AsyncConnection.cpp

@@ -1,545 +0,0 @@
-#include <algorithm>
-#include "AsyncConnection.h"
-
-namespace crown
-{
-namespace network
-{
-
-AsyncConnection::AsyncConnection(Allocator& allocator) :
-	m_remote_address(0, 0, 0, 0, 0),
-	m_mode(NONE),
-	m_state(DISCONNECTED),
-	m_max_rate(MAX_RATE),
-	m_max_rtt(MAX_RTT),	//in milliseconds
-	m_rtt(0),
-	m_timeout(DEFAULT_TIMEOUT),
-	m_timeout_acc(0),
-	m_sent_packets(0),
-	m_recv_packets(0),
-	m_dropped_packets(0.0f),
-	m_local_sequence(0),
-	m_remote_sequence(0),
-	m_max_sequence(MAX_SEQUENCE),
-	m_sent_queue(allocator),
-	m_received_queue(allocator),
-	m_running(false),
-	m_sent_packet(allocator),
-	m_received_packet(allocator),
-	m_pending_ack(allocator),
-	m_acked(allocator),
-	m_allocator(&allocator)
-{
-  
-}
-
-//-----------------------------------------------------------------------------
-AsyncConnection::~AsyncConnection()
-{
-  
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::init(const int32_t id, const real timeout)
-{
-	// set connection's id
-	m_id = id;
-	// set connection's timeout
-	m_timeout = timeout;
-}
-
-//-----------------------------------------------------------------------------
-bool AsyncConnection::start(uint16_t port)
-{
-	// if connection is not running
-	assert(!m_running);
-	os::printf("Start connection on port %d\n", port);
-	// open socket
-	if (!m_socket.open(port))
-	{
-		return false;
-	}
-	m_running = true;
-	return true;  
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::stop()
-{
-	// if connection is running
-	assert(m_running);
-	os::printf("stopping connection...\n");;
-
-	if (is_connected())
-	{
-		os::printf("connection stopped\n");;
-		_clear_data();
-		// close socket
-		m_socket.close();
-		m_running = false;
-		return;
-	}
-	
-	os::printf("connection is running yet");
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::listen()
-{
-	os::printf("server listening for connection...\n");;
-	// Set connection mode and state
-	_clear_data();
-	m_mode = SERVER;
-	m_state = LISTENING;  
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::connect(const os::NetAddress& addr)
-{
-	assert(m_running);
-	
-  	_clear_data();
-
-	os::printf("client connecting to ");
-	os::printf("%i.", (uint8_t)addr.address[0]);
-	os::printf("%i.", (uint8_t)addr.address[1]);
-	os::printf("%i.", (uint8_t)addr.address[2]);
-	os::printf("%i:", (uint8_t)addr.address[3]);
-	os::printf("%i\n", (uint16_t)addr.port);
-
-	m_mode = CLIENT;
-	m_state = CONNECTING;
-	m_remote_address = addr;
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::reset_rate()
-{
-
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::set_max_outgoing_rate(int rate)
-{
-	m_max_rate = rate;
-}
-
-//-----------------------------------------------------------------------------
-int AsyncConnection::get_max_outgoing_rate()
-{
-	return m_max_rate;
-}
-
-//-----------------------------------------------------------------------------
-os::NetAddress AsyncConnection::get_remote_address() const
-{
-	return m_remote_address;
-}
-
-//-----------------------------------------------------------------------------
-int AsyncConnection::get_outgoing_rate() const
-{
-  
-}
-
-//-----------------------------------------------------------------------------
-int AsyncConnection::get_incoming_rate() const
-{
-  
-}
-
-//-----------------------------------------------------------------------------
-float AsyncConnection::get_packets_loss() const
-{
-	return m_dropped_packets;
-}
-
-//-----------------------------------------------------------------------------
-uint16_t AsyncConnection::get_local_sequence() const
-{
-	return m_local_sequence;
-}
-
-//-----------------------------------------------------------------------------
-uint16_t AsyncConnection::get_remote_sequence() const
-{
-	return m_remote_sequence;
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::send_message(BitMessage& msg, const uint32_t time)
-{
-	assert(m_running);
-	// set header
-	msg.set_header(m_id, m_local_sequence, m_remote_sequence, _generate_ack_bits());
-	// evaluate message size	
-	size_t size = msg.get_header_size() + msg.get_size();
-	uint8_t* data = (uint8_t*)m_allocator->allocate(size);
-	// merge header with data 
-	memcpy(data, msg.get_header(), 12);
-	memcpy(data + 12, msg.get_data(), size - 12);
-	// send message
-	m_socket.send(m_remote_address, data, size);
-	
-	_packet_sent(msg.get_size());
-	// storage outgoing message
-	m_sent_queue.push_back(msg);
-}
-
-//-----------------------------------------------------------------------------
-int32_t AsyncConnection::receive_message(BitMessage& msg, const uint32_t time)
-{
-	assert(m_running);
-	
-	os::NetAddress sender(0, 0, 0, 0, 0);
-
-	size_t size = msg.get_max_size();
-	
-	uint8_t* data = (uint8_t*)m_allocator->allocate(msg.get_header_size() + size);
-
-	// receive message
-	int32_t received_bytes = m_socket.receive(sender, data, size);
-	if (received_bytes <= 0)
-	{
-		return 0;
-	}
-
-	// header-taking
-	uint32_t protocol_id = data[0] << 24 | data[1] << 16 | data[2] << 8 | data[3];
-	uint16_t sequence = data[4] << 8 | data[5];
-	uint16_t ack = data[6] << 8 | data[7];
-	uint32_t ack_bits = data[8] << 24 | data[9] << 16 | data[10] << 8 | data[11];
-	
-	msg.begin_writing();
-	msg.set_header(protocol_id, sequence, ack, ack_bits);
-	
-	//data-taking
- 	uint8_t* tmp_ptr = &data[12];
-	memcpy(msg.get_data(), tmp_ptr, msg.get_max_size());
-	msg.set_size(size);
-	// sets BitMessage in read-only for processing
-	msg.begin_reading();
-	
-	_packet_received(sequence, msg.get_size());
-	_process_ack(ack, ack_bits);
- 	// storage incoming message	
-	m_received_queue.push_back(msg);
-	
-	// establish connection after first packet is received
-	if (m_mode == SERVER && !is_connected())
-	{
-		os::printf("server accepts connection from client ");
-		os::printf("%i.", (uint8_t)sender.address[0]);
-		os::printf("%i.", (uint8_t)sender.address[1]);
-		os::printf("%i.", (uint8_t)sender.address[2]);
-		os::printf("%i:", (uint8_t)sender.address[3]);
-		os::printf("%i\n", (uint16_t)sender.port);
-		
-		m_state = CONNECTED;
-		m_remote_address = sender;
-	}
-	
-	// completes connection after first packet is received from server
-	if (sender == m_remote_address)
-	{
-		if (m_mode == CLIENT && m_state == CONNECTING)
-		{
-			os::printf("client completes connection with server");
-			m_state = CONNECTED;
-		}
-		m_timeout_acc = 0.0f;
-		return msg.get_size();
-	}
-	return 0;
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::clear_reliable_messages()
-{
-	m_sent_queue.clear();
-	m_received_queue.clear();
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::update(real delta)
-{
-	assert(m_running);
-	// improve timeout accumulator of delta time
-	m_timeout_acc += delta;
-	// if timeout accumulator > generic timeout
-	if (m_timeout_acc > m_timeout)
-	{
-		if (m_state == CONNECTING)
-		{
-			os::printf("Connect timed out\n");
-			_clear_data();
-			m_state = CONNECT_FAIL;
-		}
-		else if (m_state == CONNECTED)
-		{
-			os::printf("Connection timed out\n");
- 			_clear_data();
-			if (m_state == CONNECTING)
-			{
-				m_state = CONNECT_FAIL;
-			}
-		}
-	}
-}	
-
-//-----------------------------------------------------------------------------
-bool AsyncConnection::ready_to_send(const int time) const
-{
-
-}
-
-//-----------------------------------------------------------------------------
-bool AsyncConnection::is_connecting() const
-{ 
-	return m_state == CONNECTING; 
-}
-
-//-----------------------------------------------------------------------------
-bool AsyncConnection::is_listening() const
-{ 
-	return m_state == LISTENING; 
-}
-
-//-----------------------------------------------------------------------------
-bool AsyncConnection::is_connected() const 
-{ 
-	return m_state == CONNECTED; 
-}
-
-//-----------------------------------------------------------------------------
-bool AsyncConnection::is_connect_fail() const
-{ 
-	return m_state == CONNECT_FAIL; 
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::_packet_sent(size_t size)
-{
-	bool seq_exists_in_sent_queue = false;
-	bool seq_exists_in_pending_ack_queue = false;
-  
-	PacketData tmp;
-	
-	tmp.sequence = m_local_sequence;
-
-	// If local_sequence_number exists
-	PacketData* h_ptr;
-	h_ptr = std::find(m_sent_packet.begin(), m_sent_packet.end(), tmp);
-	if (h_ptr != m_sent_packet.end())
-	{
-		seq_exists_in_sent_queue = true;
-	}
-
-	h_ptr = std::find(m_pending_ack.begin(), m_pending_ack.end(), tmp);
-	if(h_ptr != m_pending_ack.end())
-	{
-		seq_exists_in_pending_ack_queue = true;
-	}	
-	// Else
-	assert(!seq_exists_in_sent_queue);
- 	assert(!seq_exists_in_pending_ack_queue);
-	
-	// Creates Header for saving in queues
-	PacketData packet;
-	packet.sequence = m_local_sequence;
-	packet.time = 0.0f;
-	packet.size = size;
-	// Push packet data in sent_queue
-	m_sent_packet.push_back(packet);
-	// push packet data in pending_ack_queue
-	m_pending_ack.push_back(packet);
-	// Increments sent packets
-	m_sent_packets++;
-	// Increments local sequence
-	m_local_sequence++;
-
-	if (m_local_sequence >= MAX_SEQUENCE)
-	{
-		m_local_sequence = 0;
-	}
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::_packet_received(uint16_t sequence, size_t size)
-{
-	PacketData tmp;
-	PacketData* h_ptr;
-
-	tmp.sequence = sequence;
-
-	// Increment received packets
-	m_recv_packets++;
-	
-	// If packet's sequence exists, return
-	h_ptr = std::find(m_received_packet.begin(), m_received_packet.end(), tmp);
-	if (h_ptr != m_received_packet.end())
-	{
-		return;
-	}
-	
-	PacketData packet;
-	packet.sequence = sequence;
-	packet.time = 0.0f;
-	packet.size = size;
-	// Push packet data in received_queue
-	m_received_packet.push_back(packet);
-	// update m_remote_sequence
-	if (_sequence_more_recent(sequence, m_remote_sequence))
-	{
-		m_remote_sequence = sequence;
-	}  
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::_process_ack(uint16_t ack, int32_t ack_bits)
-{
-	if (m_pending_ack.empty())
-	{
-		return;
-	}
-	
-	uint32_t index = 0;
-	
-	PacketData* i = m_pending_ack.begin();
-	for(i = m_pending_ack.begin(), index = 0; i != m_pending_ack.end(); i++, index++)
-	{
-		bool acked = false;
-
-		if (i->sequence == ack)
-		{
-			acked = true;
-		}
-		else if (!_sequence_more_recent(i->sequence, ack))
-		{
-			uint32_t bit_index = _bit_index_for_sequence(i->sequence, ack);
-			if (bit_index <= 31)
-			{
-				acked = (ack_bits >> bit_index) & 1;
-			}
-		}
-  
-		PacketData packet;
-		if (acked)
-		{
-			m_rtt += (i->time - m_rtt) * 0.1f;
-			m_acked.push_back(*i);
-			m_pending_ack[index] = packet;
-		}
-	}
-}
-
-
-//-----------------------------------------------------------------------------
-bool AsyncConnection::_sequence_more_recent(uint16_t s1, uint16_t s2)
-{
-	return ((s1 > s2) && (s1 - s2 <= m_max_sequence / 2)) || ((s2 > s1) && (s2 - s1<= m_max_sequence / 2 ));
-}
-
-//-----------------------------------------------------------------------------
-int32_t AsyncConnection::_bit_index_for_sequence(uint16_t seq, uint16_t ack)
-{
-	assert(seq != ack);
-	assert(!_sequence_more_recent(seq, ack));
-	
-	if (seq > ack)
-	{
-		assert(ack < 33);
-		assert(seq <= m_max_sequence);
-		return ack + (m_max_sequence - seq);
-	}
-	else
-	{
-		assert(ack >= 1);
-		assert(seq <= ack - 1);
-		return ack - 1 - seq;
-	}  
-}
-
-//-----------------------------------------------------------------------------
-int32_t AsyncConnection::_generate_ack_bits()
-{
-	int32_t ack_bits = 0;
-	
-	for (PacketData* i = m_received_packet.begin(); i != m_received_packet.end(); i++)
-	{
-		if (i->sequence == m_remote_sequence || _sequence_more_recent(i->sequence, m_remote_sequence))
-		{
-			break;
-		}
-		
-        int32_t bit_index = _bit_index_for_sequence(i->sequence, m_remote_sequence);
-		if (bit_index <= 31)
-		{
-			ack_bits |= 1 << bit_index;
-		}
-	}
-	return ack_bits;
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::_update_packet_queues(uint32_t delta)
-{
-	PacketData* i;
-	
-	// updates queues time
-	for (i = m_sent_packet.begin(); i != m_sent_packet.end(); i++)
-	{
-		i->time += delta;
-	}
-	for (i = m_received_packet.begin(); i != m_received_packet.end(); i++)
-	{
-		i->time += delta;
-	}
-	for (i = m_pending_ack.begin(); i != m_pending_ack.end(); i++)
-	{
-		i->time += delta;
-	}
-	for (i = m_acked.begin(); i != m_acked.end(); i++)
-	{
-		i->time += delta;
-	}
-	
-	// cleans queues from old packets
-	/*
-	while (m_sent_packet.size() && m_sent_packet.front().time > MAX_RTT)
-	{
-		m_sent_packet.pop_front();
-	}
-	if (m_received_packet.size())
-	{
-		while()
-	}
-	while (m_acked.size() && m_acked.front().time > MAX_RTT * 2)
-	{
-		m_acked.pop_front();
-	}
-	while (m_pending_ack.size() && m_pending_ack.front().time > MAX_RTT)
-	{
-		m_pending_ack
-		m_dropped_packets++;
-	}*/
-
-}
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::_update_stats()
-{
-  
-}
-
-
-//-----------------------------------------------------------------------------
-void AsyncConnection::_clear_data()
-{
-	m_state = DISCONNECTED;
-	m_timeout_acc = 0.0f;
-	m_remote_address = os::NetAddress();
-}
-
-} // namespace network
-} // namespace crown

+ 0 - 179
src/network/AsyncConnection.h

@@ -1,179 +0,0 @@
-#pragma once
-
-#include "Types.h"
-#include "OS.h"
-#include "Allocator.h"
-#include "BitMessage.h"
-#include "Queue.h"
-
-namespace crown
-{
-namespace network
-{
-
-/**
- * Reliable connection over UDP
- */
-class AsyncConnection
-{
-public:
-  
-	struct PacketData
-	{
-		  uint32_t 	sequence;
-		  real		time;
-		  size_t	size;
-		  
-		  PacketData()
-		  {
-			  sequence = 0;
-			  time = 0.0f;
-			  size = 0;
-		  }
-		  
-		  bool operator==(const PacketData& packet)
-		  {
-			  return sequence == packet.sequence;
-		  }
-	};
-  
-public:
-
-									AsyncConnection(Allocator& allocator);
-									~AsyncConnection();
-
-	void							init(const int32_t id = DEFAULT_PROTOCOL_ID, const real timeout = DEFAULT_TIMEOUT);
-	bool 							start(uint16_t port);
-	void 							stop();
-	void 							listen();
-	void 							connect(const os::NetAddress& addr);
-	void							reset_rate();
-
-								  // Sets the maximum outgoing rate.
-	void							set_max_outgoing_rate(int32_t rate);
-									// Gets the maximum outgoing rate.
-	int32_t							get_max_outgoing_rate();
-									// Returns the address of the entity at the other side of the channel.
-	os::NetAddress					get_remote_address() const;
-									// Returns the average outgoing rate over the last second.
-	int32_t							get_outgoing_rate() const;
-									// Returns the average incoming rate over the last second.
-	int32_t							get_incoming_rate() const;
-									// Returns the average incoming packet loss over the last 5 seconds.
-	real							get_packets_loss() const;
-									// returns the current local sequence number
-	uint16_t						get_local_sequence() const;
-									// returns the current remote sequence number
-	uint16_t						get_remote_sequence() const;
-									// Sends message
-	void							send_message(BitMessage& msg, const uint32_t time);
-									// Receive message and process
-	int32_t							receive_message(BitMessage& msg, const uint32_t time);
-									// Removes any pending outgoing or incoming reliable messages.
-	void							clear_reliable_messages();
-									// Update AsyncConnection
-	void 							update(real delta);
-									// Returns true if the connection is ready to send new data based on the maximum rate.
-	bool							ready_to_send(const int32_t time) const;
-	
-	bool 							is_connecting() const;
-	bool 							is_listening() const; 
-	bool 							is_connected() const;
-	bool 							is_connect_fail() const;
-	
-private:
-	
-	// connection mode
-	enum Mode
-	{
-		NONE,
-		CLIENT,
-		SERVER
-	};
-	
-	// connection states
-	enum State
-	{
-		DISCONNECTED,
-		LISTENING,
-		CONNECTING,
-		CONNECT_FAIL,
-		CONNECTED
-	};  
-  
-private:
-
-									 // methods which provides a reliability system
-	void 							_packet_sent(size_t size);
-	void 							_packet_received(uint16_t sequence, size_t size);
-	void 							_process_ack(uint16_t ack, int32_t ack_bits);
-	bool							_sequence_more_recent(uint16_t s1, uint16_t s2);
-	int32_t							_bit_index_for_sequence(uint16_t seq, uint16_t ack);
-	int32_t							_generate_ack_bits();
-	void							_update_stats();
-	void							_update_packet_queues(uint32_t delta);
-// 	void							_insert_sorted_in_queue(PacketData* begin, PacketData* end);
-									// methods which provides a flow control system
-
-	
-	void							_clear_data();
-
-
-private:
-  
-	os::NetAddress					m_remote_address;			// address of remote host
-	os::UDPSocket					m_socket;					// socket
-	uint32_t						m_id;						// our identification used instead of port number
-	Mode							m_mode;						// connection mode
-	State							m_state;					// connection state
-	uint32_t						m_max_rate;					// maximum number of bytes that may go out per second
-	real							m_max_rtt;					// Maximum round trip time
-	real							m_rtt;						// Round trip time
-	real							m_timeout;					// connection timeout value
-	real							m_timeout_acc;				// timeout accumulator
-
-									// variables to keep track of the incoming packet loss
-	uint32_t						m_sent_packets;		
-	uint32_t						m_recv_packets;
-	real							m_dropped_packets;
-
-									// sequencing variables
-	uint16_t						m_local_sequence;
-	uint16_t						m_remote_sequence;
-	uint16_t						m_max_sequence;
-
-									// message queues
-	Queue<BitMessage>				m_sent_queue;
-	Queue<BitMessage>				m_received_queue;
-	
-									// flag variables
-	bool							m_running;
-	
-									// packet queues
-	Queue<PacketData>				m_sent_packet;					// Sent messages queue
-	Queue<PacketData>				m_received_packet;				// Received messages queue
-	Queue<PacketData>				m_pending_ack;					// Pending acknokledges queue
-	Queue<PacketData>				m_acked;						// Acknowledges queue
-	
-									// statistic variables
-	real							m_sent_bytes_per_sec;
-	real							m_acked_bytes_per_sec;
-	real							m_sent_bandwidth;
-	real							m_acked_bandwidth;
-	
-	Allocator*						m_allocator;					// dynamic allocator
-									
-									// constants
-	static const uint32_t			DEFAULT_PROTOCOL_ID	= 0xFFFFFFFF;
-	static const uint32_t			DEFAULT_TIMEOUT		= 10;
-	static const uint32_t			MAX_RATE			= 64000;
-	static const uint32_t			MAX_SEQUENCE		= 0xFFFF;
-	static const uint32_t			MAX_RTT				= 1000;
-	static const uint32_t			MAX_PACKET_LEN		= 1400;
-	static const uint32_t			MAX_MESSAGE_SIZE	= 16384;
-	static const uint32_t			MAX_QUEUE_SIZE		= 16384;
-
-};
-
-} // namespace network
-} // namespace crown

+ 0 - 138
src/network/PacketQueue.cpp

@@ -1,138 +0,0 @@
-#include "PacketQueue.h"
-
-namespace crown
-{
-namespace network
-{
-
-//-------------------------------------------------------------
-PacketQueue::PacketQueue() :
-	m_first(0),
-	m_last(0),
-	m_start_index(0),
-	m_end_index(0)
-{
-
-}
-
-//-------------------------------------------------------------
-PacketQueue::~PacketQueue()
-{
-
-}
-
-//-------------------------------------------------------------
-bool PacketQueue::add(const PacketData& pd)
-{	
-	if (get_space_left() < sizeof(PacketData))
-	{
-		return false;
-	}
-	// update last sequence number
-	write_uint16(pd.sequence);
-	write_int32(pd.time);
-	write_int32(pd.time);
-	last++; 
-	return true;
-}
-
-//-------------------------------------------------------------
-bool PacketQueue::get(PacketData& pd)
-{	
-	// empty queue
-	if (first == last)
-	{
-		return false;
-	}
-
-	pd.sequence = read_uint16();
-	pd.time = read_int32();
-	pd.size = read_int32();
-
-	assert(pd.sequence == first);
-	first++;
-	return true;
-}
-
-//-------------------------------------------------------------
-size_t PacketQueue::get_total_size() const
-{
-	if (m_start_index <= m_end_index) 
-	{
-		return endIndex - startIndex;
-	} 
-	else 
-	{
-		return sizeof(buffer) - startIndex + endIndex;
-	}
-}
-
-//-------------------------------------------------------------
-size_t PacketQueue::get_space_left() const
-{
-	if (m_start_index <= m_end_index) 
-	{
-		return sizeof(buffer) - (endIndex - startIndex) - 1;
-	} 
-	else 
-	{
-		return (startIndex - endIndex) - 1;
-	}
-}
-
-//-------------------------------------------------------------
-int32_t PacketQueue::get_first() const
-{
-	return m_first;
-}
-
-//-------------------------------------------------------------
-int32_t PacketQueue::get_last() const
-{
-	return m_last;
-}
-
-//-------------------------------------------------------------
-void PacketQueue::write_uint8(uint8_t value)
-{
-	m_buffer[m_end_index] = value;
-	m_end_index = (m_end_index + 1) & (MAX_QUEUE_SIZE - 1);
-}
-
-//-------------------------------------------------------------
-void PacketQueue::write_uint16(int32_t value)
-{
-	write_uint8((value >> 0) & 255); 
-	write_uint8((value >> 8) & 255);
-}
-
-//-------------------------------------------------------------
-void PacketQueue::write_int32(int32_t value)
-{
-	write_uint8((value >> 0) & 255); 
-	write_uint8((value >> 8) & 255);
-	write_uint8((value >> 16) & 255); 
-	write_uint8((value >> 24) & 255);	
-}
-
-//-------------------------------------------------------------
-int8_t PacketQueue::read_uint8()
-{
-	uint8_t value = m_buffer[m_start_index];
-	m_start_index = (m_start_index + 1) & (MAX_QUEUE_SIZE - 1);
-}
-
-//-------------------------------------------------------------
-int32_t PacketQueue::read_uint16()
-{
-	return (read_uint8()) | (read_uint8() << 8);
-}
-
-//-------------------------------------------------------------
-int32_t PacketQueue::read_int32()
-{
-	return (read_uint8()) | (read_uint8() << 8) | (read_uint8() << 16) | (read_uint8() << 24);
-}
-
-}
-} // namespace crown

+ 0 - 53
src/network/PacketQueue.h

@@ -1,53 +0,0 @@
-#pragma once
-#include "Types.h"
-
-namespace crown
-{
-namespace network
-{
-
-class PacketQueue
-{
-public:
-
-	struct PacketData
-	{
-		uint16_t sequence;	
-		uint32_t time;
-		size_t size;
-	};
-
-public:
-
-							PacketQueue();
-							~PacketQueue();
-
-	bool					add(const PacketData& pd);
-	bool					get(PacketData& pd);
-	size_t					get_total_size() const;
-	size_t					get_space_left() const;
-	int32_t					get_first() const; 
-	int32_t					get_last() const;
-
-private:
-
-	void 					write_uint8(int32_t value);
-	void					write_uint16(int32_t value);
-	void 					write_int32(int32_t value);
-
-	int32_t					read_uint8();
-	int32_t					read_uint16();
-	int32_t					read_int32();
-
-private:
-	static const uint32_t 	MAX_QUEUE_SIZE = 16384;	
-
-	uint8_t					m_buffer[MAX_QUEUE_SIZE];
-	uint32_t				m_first;							// sequence number of first message in queue
-	uint32_t				m_last;							// sequence number of last message in queue
-	uint32_t				m_start_index;					// index pointing to the first byte of the first message
-	uint32_t				m_end_index;						// index pointing to the first byte after the last message
-};
-
-} // namespace network
-} // namespace crown