Last active
August 29, 2015 14:17
-
-
Save jbrisbin/686e565660b27b9b0f91 to your computer and use it in GitHub Desktop.
New RIPC abstractions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface TcpConnection<R, W> { | |
Reader<R> reader(); | |
Writer<W> writer(); | |
public interface Reader<R> extends Publisher<R> { | |
<NEWR> Reader<NEWR> intercept(Interceptor<R, NEWR> interceptor); | |
} | |
public interface Writer<W> extends Processor<W, W> { | |
<NEWW> Writer<NEWW> intercept(Interceptor<W, NEWW> interceptor); | |
void flush(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface TcpConnectionHandler<R, W> { | |
void onOpen(TcpConnection<R, W> connection); | |
void onAbort(TcpConnection<R, W> connection); | |
void onClose(TcpConnection<R, W> connection); | |
void onError(TcpConnection<R, W> connection); | |
void onReadable(TcpConnection<R, W> connection); | |
void onWritable(TcpConnection<R, W> connection); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onOpen(TcpConnection<ByteBuf, ByteBuf> connection) { | |
connection | |
.reader() | |
.intercept(new Interceptor<ByteBuf, String>() { | |
@Override | |
public String intercept(ByteBuf obj) { | |
return obj.toString(Charset.defaultCharset()); | |
} | |
}) | |
.subscribe(new Subscriber<String>() { | |
@Override | |
public void onSubscribe(Subscription s) { | |
} | |
@Override | |
public void onNext(String s) { | |
} | |
@Override | |
public void onError(Throwable t) { | |
} | |
@Override | |
public void onComplete() { | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment