// Path: Source/src/de/tum/in/www1/jReto/module/api/Connection.java
// public interface Connection {
// 	/** 
// 	* The Connection.Handler interface allows the Connection to inform its delegate about various events.
// 	*/
// 	public static interface Handler {
// 	    /** Called when the connection connected successfully.*/
// 		void onConnect(Connection connection);
// 	    /** Called when the connection closes. Has an optional error parameter to indicate issues. (Used to report problems to the user). */
// 		void onClose(Connection connection);
// 	    /** Called when data was received. */
// 		void onDataReceived(Connection connection, ByteBuffer data);
// 	    /** Called for each writeData call, when it is complete. */
// 		void onDataSent(Connection connection);
// 	}
// 	
//     /** Sets the connection's delegate. */
// 	void setHandler(Handler handler);
//     /** The connection's delegate. */
// 	Handler getHandler();
// 	
//     /** Whether this connection is currently connected. */
// 	boolean isConnected();
//     /** Reto sends packets which may vary in size. This property may return an ideal packet size that should be used if possible. */
// 	int getRecommendedPacketSize();
// 	
//     /** Connects the connection. */
// 	void connect();
//     /** Closes the connection. */
// 	void close();
// 	
//     /** Sends data using the connection. */
// 	void writeData(ByteBuffer data);
// }
// 
// Path: Source/src/de/tum/in/www1/jReto/packet/Packet.java
// public interface Packet {
// 	public ByteBuffer serialize();
// }


import java.nio.ByteBuffer;
import de.tum.in.www1.jReto.module.api.Connection;
import de.tum.in.www1.jReto.packet.Packet;
package de.tum.in.www1.jReto.routing;



public class SinglePacketHelper {
	public static interface OnPacketHandler {
		void onPacket(ByteBuffer data);
	}
	public static interface OnSuccessHandler {
		void onSuccess();
	}
	public static interface OnFailHandler {
		void onFail();
	}
	
// Path: Source/src/de/tum/in/www1/jReto/module/api/Connection.java
// public interface Connection {
// 	/** 
// 	* The Connection.Handler interface allows the Connection to inform its delegate about various events.
// 	*/
// 	public static interface Handler {
// 	    /** Called when the connection connected successfully.*/
// 		void onConnect(Connection connection);
// 	    /** Called when the connection closes. Has an optional error parameter to indicate issues. (Used to report problems to the user). */
// 		void onClose(Connection connection);
// 	    /** Called when data was received. */
// 		void onDataReceived(Connection connection, ByteBuffer data);
// 	    /** Called for each writeData call, when it is complete. */
// 		void onDataSent(Connection connection);
// 	}
// 	
//     /** Sets the connection's delegate. */
// 	void setHandler(Handler handler);
//     /** The connection's delegate. */
// 	Handler getHandler();
// 	
//     /** Whether this connection is currently connected. */
// 	boolean isConnected();
//     /** Reto sends packets which may vary in size. This property may return an ideal packet size that should be used if possible. */
// 	int getRecommendedPacketSize();
// 	
//     /** Connects the connection. */
// 	void connect();
//     /** Closes the connection. */
// 	void close();
// 	
//     /** Sends data using the connection. */
// 	void writeData(ByteBuffer data);
// }
// 
// Path: Source/src/de/tum/in/www1/jReto/packet/Packet.java
// public interface Packet {
// 	public ByteBuffer serialize();
// }


// Path: Source/src/de/tum/in/www1/jReto/routing/SinglePacketHelper.java
import java.nio.ByteBuffer;
import de.tum.in.www1.jReto.module.api.Connection;
import de.tum.in.www1.jReto.packet.Packet;

package de.tum.in.www1.jReto.routing;



public class SinglePacketHelper {
	public static interface OnPacketHandler {
		void onPacket(ByteBuffer data);
	}
	public static interface OnSuccessHandler {
		void onSuccess();
	}
	public static interface OnFailHandler {
		void onFail();
	}
	
	public static void read(Connection connection, final OnPacketHandler packetHandler, final OnFailHandler onFail) {