コード例 #1
0
 @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);
   }
 }
コード例 #2
0
 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("游戏记录不存在");
   }
 }