Exemple #1
0
void MultiplayerAPI::poll() {

	if (!network_peer.is_valid() || network_peer->get_connection_status() == NetworkedMultiplayerPeer::CONNECTION_DISCONNECTED)
		return;

	network_peer->poll();

	if (!network_peer.is_valid()) // It's possible that polling might have resulted in a disconnection, so check here.
		return;

	while (network_peer->get_available_packet_count()) {

		int sender = network_peer->get_packet_peer();
		const uint8_t *packet;
		int len;

		Error err = network_peer->get_packet(&packet, len);
		if (err != OK) {
			ERR_PRINT("Error getting packet!");
		}

		rpc_sender_id = sender;
		_process_packet(sender, packet, len);
		rpc_sender_id = 0;

		if (!network_peer.is_valid()) {
			break; // It's also possible that a packet or RPC caused a disconnection, so also check here.
		}
	}
}
Exemple #2
0
unsigned char
handle_interrupt() {
    unsigned char bytes_received = _receive_packet();

    rfm12_DisableRx();
    rfm12_DisableFifo();

    // Process the packet, but only if the application has dealt with the
    // last packet.  If not, it will be silently dropped..
    if (!data_arrived) {
        _process_packet(bytes_received);
    }

    rfm12_EnableFifo();
    rfm12_EnableRx();

    return 1;
}