Exemplo n.º 1
0
bool DCCChatConnection::write_connection_data(IRCRawString &write_line, IRCRawString::size_type &write_pos, clan::TCPConnection &connection)
{
	while (true)
	{
		if (write_line.length() != write_pos)
		{
			int bytes_written = connection.write(write_line.data() + write_pos, write_line.length() - write_pos);
			if (bytes_written == -1)
				return true;
			write_pos += bytes_written;
		}
		else
		{
			write_line.clear();
			write_pos = 0;
			if (!send_queue.empty())
			{
				if (send_queue.front().type == Message::type_disconnect)
				{
					send_queue.erase(send_queue.begin());
					return false;
				}
				else
				{
					write_line = send_queue.front().text + "\r\n";
					send_queue.erase(send_queue.begin());
				}
			}
		}
	}
}
Exemplo n.º 2
0
bool IRCConnection::write_connection_data(IRCRawString &write_line, IRCRawString::size_type &write_pos, clan::TCPConnection &connection)
{
	if (write_line.length() != write_pos)
	{
		//int old_pos = write_pos;
		write_pos += connection.write(write_line.data()+write_pos, write_line.length()-write_pos);
		//clan::Console::write_line(std::string8(write_line.data()+old_pos, write_pos-old_pos, false));
	}
	else
	{
		write_line = queues.pop_send();
		write_pos = 0;
	}
	return true;
}