SocketConnection(
final TransportSetup setup, final Socket socket, final Reader reader, final OutputStream outputStream, final Executor writerExecutor
) throws Exception {
packetSerializer = setup.packetSerializer;
this.socket = socket;
final SessionClient sessionClient = new SessionClient(setup, this);
try {
writerExecutor.execute(new Runnable() {
@Override public void run() {
try {
write(outputStream);
} catch (final Exception e) {
sessionClient.close(e);
}
}
});
} catch (final Exception e) {
sessionClient.close(e);
return;
}
read(sessionClient, reader);
}