All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.thorbenkuck.network.connection.Protocol Maven / Gradle / Ivy

There is a newer version: 0.4.0
Show newest version
package com.github.thorbenkuck.network.connection;

import java.io.IOException;
import java.nio.ByteBuffer;

public interface Protocol {

	default int toInt(byte[] data) {
		if (data.length != 4) {
			throw new IllegalArgumentException("Integer requires 4 byte");
		}
		ByteBuffer byteBuffer = ByteBuffer.wrap(data);
		return byteBuffer.getInt();
	}

	byte[] readNext(DataConnection dataConnection) throws IOException;

	void write(byte[] data, DataConnection dataConnection) throws IOException;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy