Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void channelRead(ChannelHandlerContext ctx, Object message) throws Exception {
- ByteBuf byteBuf = (ByteBuf) message;
- ActionType actionType = ActionType.fromByte(byteBuf.readByte());
- switch (actionType) {
- case ACCOUNT:
- AccountOptionType accountOptionType = AccountOptionType.fromByte(byteBuf.readByte());
- switch (accountOptionType) {
- case AUTH:
- new AccountAuthRequest(ctx, byteBuf);
- break;
- case CHANGE_PASS:
- case CHANGE_LOGIN:
- case DELETE_ACCOUNT:
- default:
- new ErrorRequest(ctx, actionType, accountOptionType, 404, "UNKNOWN_REQUEST");
- }
- break;
- case DOWNLOAD:
- DownloadOptionType downloadOptionType = DownloadOptionType.fromByte(byteBuf.readByte());
- switch (downloadOptionType) {
- case FILE:
- new DownloadFileRequest(ctx, byteBuf);
- break;
- default:
- new ErrorRequest(ctx, actionType, downloadOptionType, 404, "UNKNOWN_REQUEST");
- }
- break;
- case UPLOAD:
- UploadOptionType uploadOptionType = UploadOptionType.fromByte(byteBuf.readByte());
- switch (uploadOptionType) {
- case FILE:
- new UploadFileRequest(ctx, byteBuf);
- break;
- default:
- new ErrorRequest(ctx, actionType, uploadOptionType, 404, "UNKNOWN_REQUEST");
- }
- break;
- case COMMAND:
- CommandOptionType commandOptionType = CommandOptionType.fromByte(byteBuf.readByte());
- switch (commandOptionType) {
- case FILE_LIST:
- new CommandFileListRequest(ctx, byteBuf);
- break;
- default:
- new ErrorRequest(ctx, actionType, commandOptionType, 404, "UNKNOWN_REQUEST");
- }
- break;
- default:
- new ErrorRequest(ctx, actionType, ErrorOptionType.UNKNOWN, 404, "UNKNOWN_REQUEST");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement