@Override
 public void processRequest(ProcessorContext context, DataInputStream dis) throws IOException {
   switch (context.getHeadWrapper().getCommand()) {
     case Constant.RECORD_CMD_SAVE:
       processCommandSave(context, dis);
       break;
     case Constant.RECORD_CMD_READ:
       processCommandRead(context, dis);
       break;
     case Constant.RECORD_CMD_QUERY_DESC_LIST:
       processCommandQueryDescList(context, dis);
       break;
     case Constant.RECORD_CMD_UPDATE:
       processCommandUpdate(context, dis);
       break;
     default:
       String msg = "无效的协议命令, cmd=" + context.getHeadWrapper().getCommand();
       context.setErrorCode(Constant.EC_INVALID_CMD);
       context.setMessage(msg);
       throw new RequestProcessException(msg);
   }
 }
 @SuppressWarnings("unchecked")
 private void processCommandQueryDescList(ProcessorContext context, DataOutputStream dos)
     throws IOException {
   dos.writeInt(context.getHeadWrapper().getHead());
   dos.writeInt(0); /*result*/
   List<GameRecordDesc> descList = (List<GameRecordDesc>) context.getResult();
   if (descList != null && descList.size() > 0) {
     dos.writeShort(descList.size());
     for (GameRecordDesc desc : descList) {
       dos.writeInt(desc.getRecordId());
       dos.writeInt(desc.getPlayDuration());
       dos.writeInt(desc.getScores());
       dos.writeUTF(desc.getRemark());
       dos.writeUTF(DateFormatUtils.format(desc.getTime(), "yyyy/MM/dd HH:mm:ss"));
     }
   } else {
     dos.writeShort(0);
   }
 }
 @Override
 public void processResponse(ProcessorContext context, DataOutputStream dos)
     throws ServiceException, IOException {
   switch (context.getHeadWrapper().getCommand()) {
     case Constant.RECORD_CMD_SAVE:
       processCommandSave(context, dos);
       break;
     case Constant.RECORD_CMD_READ:
       processCommandRead(context, dos);
       break;
     case Constant.RECORD_CMD_QUERY_DESC_LIST:
       processCommandQueryDescList(context, dos);
       break;
     case Constant.RECORD_CMD_UPDATE:
       processCommandUpdate(context, dos);
       break;
     default:
       break;
   }
 }
 private void processCommandRead(ProcessorContext context, DataOutputStream dos)
     throws IOException {
   dos.writeInt(context.getHeadWrapper().getHead());
   GameRecord record = (GameRecord) context.getResult();
   if (record != null) {
     dos.writeInt(0);
     dos.writeInt(record.getRecordId());
     dos.writeInt(record.getPlayDuration());
     dos.writeInt(record.getScores());
     dos.writeUTF(record.getRemark());
     dos.writeUTF(DateFormatUtils.format(record.getTime(), "yyyy/MM/dd HH:mm:ss"));
     byte[] data = record.getData();
     if (data != null && data.length > 0) {
       dos.writeInt(data.length);
       dos.write(data, 0, data.length);
     } else {
       dos.writeInt(0);
     }
   } else {
     dos.writeInt(Constant.EC_RECORD_NOT_EXIST);
     dos.writeUTF("游戏记录不存在");
   }
 }
 private void processCommandSave(ProcessorContext context, DataOutputStream dos)
     throws IOException {
   dos.writeInt(context.getHeadWrapper().getHead());
   dos.writeInt(0); /*result*/
 }