com.firefly.net.tcp.codec.flex.stream.Stream Maven / Gradle / Ivy
package com.firefly.net.tcp.codec.flex.stream;
import com.firefly.net.tcp.codec.flex.protocol.ControlFrame;
import com.firefly.net.tcp.codec.flex.protocol.DataFrame;
import com.firefly.utils.concurrent.Callback;
import java.util.concurrent.CompletableFuture;
/**
* @author Pengtao Qiu
*/
public interface Stream extends ContextAttribute {
int getId();
CompletableFuture send(ControlFrame controlFrame);
CompletableFuture send(DataFrame dataFrame);
void send(ControlFrame controlFrame, Callback callback);
void send(DataFrame dataFrame, Callback callback);
void setListener(Listener listener);
State getState();
Session getSession();
boolean isCommitted();
interface Listener {
void onControl(ControlFrame controlFrame);
void onData(DataFrame dataFrame);
}
enum State {
OPEN, LOCALLY_CLOSED, REMOTELY_CLOSED, CLOSED
}
}