}
}
private void setServerHandler(EventBusNetServer server) {
Handler<NetSocket> sockHandler = socket -> {
RecordParser parser = RecordParser.newFixed(4, null);
Handler<Buffer> handler = new Handler<Buffer>() {
int size = -1;
public void handle(Buffer buff) {
if (size == -1) {
size = buff.getInt(0);
parser.fixedSizeMode(size);
} else {
MessageImpl received = new MessageImpl();
received.readFromWire(socket, buff, userCodecMap, systemCodecs);
parser.fixedSizeMode(4);
size = -1;
if (received.codec() == PING_MESSAGE_CODEC) {
// Just send back pong directly on connection
if (sendPong) {
socket.write(PONG);
}
} else {
receiveMessage(received, -1, null, null);
}
}
}
};
parser.setOutput(handler);
socket.handler(parser);
};
server.setHandler(sockHandler);
}