int actionId = channelBuffer.readInt();
int transactionId = channelBuffer.readInt();
Action action = Action.byId(actionId);
ClientRequest request;
switch (action) {
case CONNECT:
request = new ConnectionRequest();
break;
case ANNOUNCE:
request = new AnnounceRequest();
break;
case SCRAPE:
request = new ScrapeRequest();
break;
default:
logger.debug("Incorrect action supplied");
ErrorResponse.send(e, transactionId, "Incorrect action");
return;
}
request.setContext(ctx);
request.setMessageEvent(e);
request.setChannelBuffer(channelBuffer);
request.setConnectionId(connectionId);
request.setAction(action);
request.setTransactionId(transactionId);
request.read();
}