@Override
	public void run()
	{
		while(this.m_client.getConnectionState() != ConnectionState.DISCONNECTED)
		{
			int received = -1;
			try
			{
				received = this.m_inputStream.read(this.m_buffer);
				NetBlade.getServer().getLogger().finer("[" + this.getClient().getConnectionManager().getName() + "] Received " + received + " bytes from client " + this.m_client.getConnectionID());
			}
			catch(Exception e)
			{
				if(this.m_client.getConnectionState() != ConnectionState.DISCONNECTED)
					e.printStackTrace();
			}

			if(received == -1)
			{
				this.m_client.onQuit(QuitReason.DISCONNECT);
				this.m_client.setConnectionState(ConnectionState.DISCONNECTED);
				break;
			}

			if(this.m_buffer[received - 1] != 0x1D)
			{
			    for(int i = 0; i < received; i++)
			    {
			        this.m_temp.add(this.m_buffer[i]);
			    }
			    continue;
			}

			byte[] data;
			if(this.m_temp.size() == 0)
			{
			    data = new byte[received];
			    System.arraycopy(this.m_buffer, 0, data, 0, received);
			}
			else
			{
			    data = new byte[this.m_temp.size() + received];
			    for(int i = 0; i < this.m_temp.size(); i++)
			    {
			        data[i] = this.m_temp.get(i);
			    }

			    System.arraycopy(this.m_buffer, 0, data, this.m_temp.size(), received);
			    this.m_temp.clear();
			}

			for(Packet p : this.readPackets(data))
			{
				this.m_inQueue.offer(p);
			}

			this.m_buffer = new byte[BUFFER_SIZE];
		}

		this.m_buffer = null;
		this.m_worker.cancel();
		this.m_worker = null;
	}