예제 #1
0
void	ServerNetwork::send_reliable_packet(const IPAddress& address, const PacketWriter& packet) {
	Peer*	peer = get_peer(address);
	if (!peer) {
		// Can only send reliable packets to registered peers
		return;
	}

	PacketHeader	header(packet.packet_type(), peer->next_sequence_no++, peer->connection_id);
	send_packet(address, header, packet.packet_data());
	m_ack_manager.add_packet(address, header, packet.packet_data());
}
예제 #2
0
void	ServerNetwork::broadcast_reliable_packet(const PacketWriter& packet, const IPAddress* exclude_peer) {
	AckManager::PacketHandle	ack_handle(m_ack_manager.add_broadcast_packet(packet.packet_data()));

	for (std::map<IPAddress, Peer>::iterator it(m_peers.begin()); it != m_peers.end(); ++it) {
		if (exclude_peer && *exclude_peer == it->first) {
			continue;
		}

		PacketHeader	header(packet.packet_type(), it->second.next_sequence_no++, it->second.connection_id);
		send_packet(it->first, header, packet.packet_data());
		m_ack_manager.add_broadcast_recipient(ack_handle, it->first, header);
	}
}