Example #1
0
void Network::SendServerPacket(NetworkPacket packet, const bool reliable)
{
	if(_isConnected && _isServer)
	{	
		ENetPacket* enetPacket = enet_packet_create(packet.GetBytes(), packet.GetSize(), reliable);

		enet_host_broadcast(_host, 0, enetPacket);
	}
}
Example #2
0
void Network::SendPacket(NetworkPacket packet, const bool reliable)
{
	if(_isConnected)
	{
		ENetPacket* enetPacket = enet_packet_create(packet.GetBytes(), packet.GetSize(), reliable);
		if(!_isServer)
			enet_peer_send(_peer, 0, enetPacket);
		else
		{
			_mutex.lock();
			_receivedPackets.push_back(NetworkPacket(enetPacket,0));
			_mutex.unlock();
		}
	}
}