public void received(byte packetID, byte[] packet) {
		executor.execute(() -> {

			// Parse message
			Tree data;
			try {
				data = serializer.read(packet);
			} catch (Exception cause) {
				logger.warn("Unable to parse incoming message!", cause);
				return;
			}

			// Send message to proper component
			try {

				switch (packetID) {
				case PACKET_EVENT_ID:

					// Incoming event
					if (debug) {
						logger.info("Event message received:\r\n" + data);
					}
					eventbus.receiveEvent(data);
					return;

				case PACKET_REQUEST_ID:

					// Incoming request
					if (debug) {
						logger.info("Request message received:\r\n" + data);
					}
					registry.receiveRequest(data);
					return;

				case PACKET_RESPONSE_ID:

					// Incoming response
					if (debug) {
						logger.info("Response message received:\r\n" + data);
					}
					registry.receiveResponse(data);
					return;

				case PACKET_PING_ID:

					// Send pong
					if (debug) {
						logger.info("Ping message received:\r\n" + data);
					}
					String sender = data.get("sender", "");
					if (sender == null || sender.isEmpty()) {
						logger.warn("Missing \"sender\" property:\r\n" + data);
						return;
					}
					data.put("sender", this.nodeID);
					data.put("arrived", System.currentTimeMillis());
					writer.send(sender, serialize(PACKET_PONG_ID, data));
					return;

				case PACKET_PONG_ID:

					// Pong received
					if (debug) {
						logger.info("Pong message received:\r\n" + data);
					}
					registry.receivePong(data);
					return;

				case PACKET_GOSSIP_REQ_ID:

					// Incoming gossip request
					processGossipRequest(data);
					return;

				case PACKET_GOSSIP_RSP_ID:

					// Incoming gossip request
					processGossipResponse(data);
					return;

				case PACKET_GOSSIP_HELLO_ID:

					// Incoming "hello" message
					processGossipHello(data);
					return;

				default:
					logger.warn("Unsupported message ID (" + packetID + ")!");
				}

			} catch (Exception cause) {
				logger.warn("Unable to process incoming message!", cause);
			}
		});
	}
public void received ( byte packetID , byte [ ] packet ) { executor . execute ( ( ) -> { Tree data ; try { data = serializer . read ( packet ) ; } catch ( Exception cause ) { logger . warn ( "Unable to parse incoming message!" , cause ) ; return ; } try { switch ( packetID ) { case PACKET_EVENT_ID : if ( debug ) { logger . info ( "Event message received:\r\n" + data ) ; } eventbus . receiveEvent ( data ) ; return ; case PACKET_REQUEST_ID : if ( debug ) { logger . info ( "Request message received:\r\n" + data ) ; } registry . receiveRequest ( data ) ; return ; case PACKET_RESPONSE_ID : if ( debug ) { logger . info ( "Response message received:\r\n" + data ) ; } registry . receiveResponse ( data ) ; return ; case PACKET_PING_ID : if ( debug ) { logger . info ( "Ping message received:\r\n" + data ) ; } String sender = data . get ( "sender" , "" ) ; if ( sender == null || sender . isEmpty ( ) ) { logger . warn ( "Missing \"sender\" property:\r\n" + data ) ; return ; } data . put ( "sender" , this . nodeID ) ; data . put ( "arrived" , System . currentTimeMillis ( ) ) ; writer . send ( sender , serialize ( PACKET_PONG_ID , data ) ) ; return ; case PACKET_PONG_ID : if ( debug ) { logger . info ( "Pong message received:\r\n" + data ) ; } registry . receivePong ( data ) ; return ; case PACKET_GOSSIP_REQ_ID : processGossipRequest ( data ) ; return ; case PACKET_GOSSIP_RSP_ID : processGossipResponse ( data ) ; return ; case PACKET_GOSSIP_HELLO_ID : processGossipHello ( data ) ; return ; default : logger . warn ( "Unsupported message ID (" + packetID + ")!" ) ; } } catch ( Exception cause ) { logger . warn ( "Unable to process incoming message!" , cause ) ; } } ) ; }
--- MESSAGE RECEIVED ---