com.github.thorbenkuck.network.connection.Connection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easy-net Show documentation
Show all versions of easy-net Show documentation
An EventStream driven, simple to use Client/Server framework
The newest version!
package com.github.thorbenkuck.network.connection;
import com.github.thorbenkuck.network.stream.DataStream;
import com.github.thorbenkuck.network.stream.EventStream;
import java.io.IOException;
import java.net.DatagramSocket;
import java.net.Socket;
import java.net.SocketAddress;
import java.nio.channels.SocketChannel;
import java.util.function.Consumer;
public interface Connection {
static Connection wrap(Socket socket) throws IOException {
return new BlockingConnection(socket);
}
static Connection wrap(SocketChannel socketChannel) {
return new NonBlockingConnection(socketChannel);
}
static Connection wrap(DatagramSocket datagramSocket) {
return new UdpConnection(datagramSocket);
}
void listen();
Protocol getProtocol();
void setProtocol(Protocol protocol);
byte[] readFromProtocol() throws IOException;
void writeToProtocol(byte[] data) throws IOException;
EventStream output();
DataStream input();
EventStream systemOutput();
DataStream systemInput();
SocketAddress remoteAddress();
SocketAddress localAddress();
Consumer getOnDisconnect();
void setOnDisconnect(Consumer onDisconnect);
boolean isOpen();
void closeSilently();
void close() throws IOException;
void pauseOutput();
void unpauseOutput();
}