@Override
  public void messageReceived(ChannelHandlerContext ctx, MessageEvent e, XmlDocument d) {

    MessageEvent s = e;

    // Convert to a String first.
    XmlDocument doc = d; // new XmlDocument();
    // doc.LoadXml((String)message);

    // String cAction = doc.DocumentElement.ChildNodes[0].Attributes["action"].Value;

    String cAction =
        doc.getDocumentElement().getChildren().get(0).getAttribute("action").getValue();

    InetSocketAddress remoteAddress = (InetSocketAddress) s.getChannel().getRemoteAddress();
    String strIpPort =
        remoteAddress.getAddress().getHostAddress() + ":" + String.valueOf(remoteAddress.getPort());

    //
    //        //create item
    SessionMessage item = new SessionMessage(e, doc, false, true);
    //
    //        //save
    ChChessLPU.getInstance().getmsgList().Opp(QueueMethod.Add, item);
    //
    //        //
    if (cAction.equals(ClientAction.heartBeat)) {
      // 不打印
    } else {
      // log
      Log.WriteStrByRecv(cAction, strIpPort);
    }
  }
示例#2
0
  @Override
  public void msgTimedEvent() throws UnsupportedEncodingException {

    SmqOppResult ruCount = getmsgList().Opp(QueueMethod.Count, null);

    int len = ruCount.count;

    for (int i = 0; i < len; i++) {

      // C# TO JAVA CONVERTER TODO TASK: There is no preprocessor in Java:
      /// #region 获取消息及Session

      SmqOppResult ruShift = getmsgList().Opp(QueueMethod.Shift, null);

      if (!ruShift.oppSucess) {
        Log.WriteStrByArgument(
            RCLogicLPU.class.getName(), "msgTimedEvent", "QueueMethod.Shift", "oppSucess is false");
        continue;
      }

      if (null == ruShift.item) {
        Log.WriteStrByArgument(
            RCLogicLPU.class.getName(), "msgTimedEvent", "QueueMethod.Shift", "item is null");
        continue;
      }

      SessionMessage item = ruShift.item;

      //
      XmlDocument doc = item.doc();
      String strIpPort = item.strIpPort();
      String action = item.action();
      ChannelEvent e = item.e();

      item.Dereference();
      AppSession c = new AppSession(e.getChannel(), e);

      //
      if (action.equals(RCClientAction.loadG)) {
        RCLogic.doorLoadG(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.betG)) {
        RCLogic.doorBetG(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.updG)) {
        RCLogic.doorUpdG(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.updHonor)) {
        RCLogic.doorUpdHonor(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.login)) {
        RCLogic.doorLogin(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.hasReg)) {
        RCLogic.doorHasReg(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.reg)) {
        RCLogic.doorReg(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.chkEveryDayLoginAndGet)) {
        RCLogic.doorChkEveryDayLoginAndGet(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.loadChart)) {
        RCLogic.doorLoadChart(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.loadTopList)) {
        RCLogic.doorLoadTopList(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.hasProof)) {
        RCLogic.doorHasProof(c, doc);

        continue;
      }

      if (action.equals(RCClientAction.loadDBType)) {
        RCLogic.doorLoadDBType(c, doc);

        continue;
      }

      // Logger.WriteStr("无效协议号:" + clientServerAction);
      Log.WriteStr(SR.GetString(SR.getInvalid_protocol_num(), action));
    }
  }