示例#1
0
  public static class IndexArrayItem implements IMessageEncoder {
    private int index;

    private static IntMessageParameterHandler indexHandler =
        MessageParameterContext.getInstance().getIntMessageParameterHandler("Index");

    public static IndexArrayItem create() {
      IndexArrayItem item = new IndexArrayItem();
      return item;
    }

    /** @return the index */
    public int getIndex() {
      return index;
    }

    /** @param index the index to set */
    public void setIndex(int index) {
      this.index = index;
    }
    /** 编码 */
    @Override
    public void encode(Data data) {
      data.writeInt(this.index);
    }

    /** 解码 */
    @Override
    public void decode(Data data) {
      this.index = data.getInt();
    }

    @Override
    public boolean validate() {
      if (!indexHandler.validate(index)) {
        return false;
      }
      return true;
    }

    public String toString() {
      StringBuilder bb = new StringBuilder();
      bb.append("index:").append(this.index);
      return bb.toString();
    }
  }
示例#2
0
  private static void bootstrap() {
    try {
      MessageParameterContext.getInstance().init();
      ConfigContext.getInstance().init();
      readConfig();
    } catch (Exception e) {
      e.printStackTrace();
      System.exit(0);
    }

    int serverId = ConfigContainer.getInstance().getConfig().getServerId();
    String serverIp = ConfigContainer.getInstance().getConfig().getServerIp();
    int paltformId = ConfigContainer.getInstance().getConfig().getPlatformId();
    String account = ConfigContainer.getInstance().getConfig().getAccount();
    String password = ConfigContainer.getInstance().getConfig().getPassword();
    Client client = new Client(serverId, serverIp, paltformId, account, password);
    client.start();

    // String serverIp = "119.29.25.197";
    // Client client = new Client(serverIp, 100, "safziy", "safziymy");
    // Client client = new Client(serverIp, 100, "62683011", "woshiziyi");
    // client.start();

  }
  public static class PrincessPropertyArrayItem implements IMessageEncoder {
    private int propertyKey;
    private int level;
    private int experience;

    private static IntMessageParameterHandler propertyKeyHandler =
        MessageParameterContext.getInstance().getIntMessageParameterHandler("PropertyKey");
    private static IntMessageParameterHandler levelHandler =
        MessageParameterContext.getInstance().getIntMessageParameterHandler("Level");
    private static IntMessageParameterHandler experienceHandler =
        MessageParameterContext.getInstance().getIntMessageParameterHandler("Experience");

    public static PrincessPropertyArrayItem create() {
      PrincessPropertyArrayItem item = new PrincessPropertyArrayItem();
      return item;
    }

    /** @return the propertyKey */
    public int getPropertyKey() {
      return propertyKey;
    }

    /** @param propertyKey the propertyKey to set */
    public void setPropertyKey(int propertyKey) {
      this.propertyKey = propertyKey;
    }
    /** @return the level */
    public int getLevel() {
      return level;
    }

    /** @param level the level to set */
    public void setLevel(int level) {
      this.level = level;
    }
    /** @return the experience */
    public int getExperience() {
      return experience;
    }

    /** @param experience the experience to set */
    public void setExperience(int experience) {
      this.experience = experience;
    }
    /** 编码 */
    @Override
    public void encode(Data data) {
      data.writeInt(this.propertyKey);
      data.writeInt(this.level);
      data.writeInt(this.experience);
    }

    /** 解码 */
    @Override
    public void decode(Data data) {
      this.propertyKey = data.getInt();
      this.level = data.getInt();
      this.experience = data.getInt();
    }

    @Override
    public boolean validate() {
      if (!propertyKeyHandler.validate(propertyKey)) {
        return false;
      }
      if (!levelHandler.validate(level)) {
        return false;
      }
      if (!experienceHandler.validate(experience)) {
        return false;
      }
      return true;
    }

    public String toString() {
      StringBuilder bb = new StringBuilder();
      bb.append("propertyKey:").append(this.propertyKey).append(", ");
      bb.append("level:").append(this.level).append(", ");
      bb.append("experience:").append(this.experience);
      return bb.toString();
    }
  }
示例#4
0
  public static class UserIdNameArrayItem implements IMessageEncoder {
    private long userId;
    private String userName;
    private int career;
    private int level;

    private static LongMessageParameterHandler userIdHandler =
        MessageParameterContext.getInstance().getLongMessageParameterHandler("UserId");
    private static IntMessageParameterHandler careerHandler =
        MessageParameterContext.getInstance().getIntMessageParameterHandler("Career");
    private static IntMessageParameterHandler levelHandler =
        MessageParameterContext.getInstance().getIntMessageParameterHandler("Level");

    public static UserIdNameArrayItem create() {
      UserIdNameArrayItem item = new UserIdNameArrayItem();
      return item;
    }

    /** @return the userId */
    public long getUserId() {
      return userId;
    }

    /** @param userId the userId to set */
    public void setUserId(long userId) {
      this.userId = userId;
    }
    /** @return the userName */
    public String getUserName() {
      return userName;
    }

    /** @param userName the userName to set */
    public void setUserName(String userName) {
      this.userName = userName;
    }
    /** @return the career */
    public int getCareer() {
      return career;
    }

    /** @param career the career to set */
    public void setCareer(int career) {
      this.career = career;
    }
    /** @return the level */
    public int getLevel() {
      return level;
    }

    /** @param level the level to set */
    public void setLevel(int level) {
      this.level = level;
    }
    /** 编码 */
    @Override
    public void encode(Data data) {
      data.writeLong(this.userId);
      data.writeString(this.userName);
      data.writeInt(this.career);
      data.writeInt(this.level);
    }

    /** 解码 */
    @Override
    public void decode(Data data) {
      this.userId = data.getLong();
      this.userName = data.getString();
      this.career = data.getInt();
      this.level = data.getInt();
    }

    @Override
    public boolean validate() {
      if (!userIdHandler.validate(userId)) {
        return false;
      }
      if (!careerHandler.validate(career)) {
        return false;
      }
      if (!levelHandler.validate(level)) {
        return false;
      }
      return true;
    }

    public String toString() {
      StringBuilder bb = new StringBuilder();
      bb.append("userId:").append(this.userId).append(", ");
      bb.append("userName:"******", ");
      bb.append("career:").append(this.career).append(", ");
      bb.append("level:").append(this.level);
      return bb.toString();
    }
  }
示例#5
0
/**
 * 返回 领取满星奖励
 *
 * @author codeGenerator
 */
@SuppressWarnings("unused")
public class Message_1004_7 implements IMessage {

  private static int MAIN = 1004;
  private static int SUB = 7;
  private static String MESSAGE_KEY = DummyUtils.getCompositeKey(1004, 7);

  private int storyLineId;

  private static IntMessageParameterHandler storyLineIdHandler =
      MessageParameterContext.getInstance().getIntMessageParameterHandler("StoryLineId");

  public static Message_1004_7 create() {
    return new Message_1004_7();
  }

  /** @return the storyLineId */
  public int getStoryLineId() {
    return storyLineId;
  }

  /** @param storyLineId the storyLineId to set */
  public void setStoryLineId(int storyLineId) {
    this.storyLineId = storyLineId;
  }

  /** 编码 */
  @Override
  public void encode(Data data) {
    data.writeInt(this.storyLineId);
  }

  /** 解码 */
  @Override
  public void decode(Data data) {
    this.storyLineId = data.getInt();
  }

  @Override
  public boolean validate() {
    if (!storyLineIdHandler.validate(storyLineId)) {
      return false;
    }
    return true;
  }

  @Override
  public int getMain() {
    return MAIN;
  }

  @Override
  public int getSub() {
    return SUB;
  }

  @Override
  public String getMessageKey() {
    return MESSAGE_KEY;
  }

  public String toString() {
    StringBuilder bb = new StringBuilder();
    bb.append("storyLineId:").append(this.storyLineId);
    return bb.toString();
  }
}
示例#6
0
/**
 * 返回 比武大会英雄信息
 *
 * @author codeGenerator
 */
public class Message_1016_6 implements IMessage {

  private static int MAIN = 1016;
  private static int SUB = 6;
  private static String MESSAGE_KEY = DummyUtils.getCompositeKey(1016, 6);

  private long userId;
  private int formationId;
  private PlaceIDArray2 placeIDArray2;
  private int zhanli;

  private static LongMessageParameterHandler userIdHandler =
      MessageParameterContext.getInstance().getLongMessageParameterHandler("UserId");
  private static IntMessageParameterHandler formationIdHandler =
      MessageParameterContext.getInstance().getIntMessageParameterHandler("FormationId");
  private static IntMessageParameterHandler zhanliHandler =
      MessageParameterContext.getInstance().getIntMessageParameterHandler("Zhanli");

  public static Message_1016_6 create() {
    return new Message_1016_6();
  }

  /** @return the userId */
  public long getUserId() {
    return userId;
  }

  /** @param userId the userId to set */
  public void setUserId(long userId) {
    this.userId = userId;
  }

  /** @return the formationId */
  public int getFormationId() {
    return formationId;
  }

  /** @param formationId the formationId to set */
  public void setFormationId(int formationId) {
    this.formationId = formationId;
  }

  /** @return the placeIDArray2 */
  public PlaceIDArray2 getPlaceIDArray2() {
    return placeIDArray2;
  }

  /** @param placeIDArray2 the placeIDArray2 to set */
  public void setPlaceIDArray2(PlaceIDArray2 placeIDArray2) {
    this.placeIDArray2 = placeIDArray2;
  }

  /** @return the zhanli */
  public int getZhanli() {
    return zhanli;
  }

  /** @param zhanli the zhanli to set */
  public void setZhanli(int zhanli) {
    this.zhanli = zhanli;
  }

  /** 编码 */
  @Override
  public void encode(Data data) {
    data.writeLong(this.userId);
    data.writeInt(this.formationId);
    placeIDArray2.encode(data);
    data.writeInt(this.zhanli);
  }

  /** 解码 */
  @Override
  public void decode(Data data) {
    this.userId = data.getLong();
    this.formationId = data.getInt();
    placeIDArray2 = PlaceIDArray2.create();
    placeIDArray2.decode(data);
    this.zhanli = data.getInt();
  }

  @Override
  public boolean validate() {
    if (!userIdHandler.validate(userId)) {
      return false;
    }
    if (!formationIdHandler.validate(formationId)) {
      return false;
    }
    if (!placeIDArray2.validate()) {
      return false;
    }
    if (!zhanliHandler.validate(zhanli)) {
      return false;
    }
    return true;
  }

  @Override
  public int getMain() {
    return MAIN;
  }

  @Override
  public int getSub() {
    return SUB;
  }

  @Override
  public String getMessageKey() {
    return MESSAGE_KEY;
  }

  public String toString() {
    StringBuilder bb = new StringBuilder();
    bb.append("userId:").append(this.userId).append(", ");
    bb.append("formationId:").append(this.formationId).append(", ");
    bb.append("placeIDArray2:").append(placeIDArray2.toString()).append(", ");
    bb.append("zhanli:").append(this.zhanli);
    return bb.toString();
  }
}