当前位置: 首页>>代码示例>>Java>>正文


Java Packet.getID方法代码示例

本文整理汇总了Java中org.xmpp.packet.Packet.getID方法的典型用法代码示例。如果您正苦于以下问题:Java Packet.getID方法的具体用法?Java Packet.getID怎么用?Java Packet.getID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xmpp.packet.Packet的用法示例。


在下文中一共展示了Packet.getID方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * Here we process the response of the remote command sent to Spectrum. We have to identify what kind of response it
 * is, as no tag for the command being responded is being sent. Currently these commands are used in Gojara
 * TransportSessionManager: online_users ( Chatmsg of online users for specific transport), usernames seperated by
 * newlines
 */
@Override
public void process(Packet packet, String subdomain, String to, String from) throws PacketRejectedException {
    Message message = (Message) packet;

    // handle different commands
    Log.debug("Intercepted spectrum message: " + message.toString());
    String command = packet.getID();
    if (command.equals("online_users")) {
        handleOnlineUsers(message, subdomain);
    } else if (command.equals("unregister")) {
        handleUnregister(message, subdomain);
    } else if (command.equals("config_check")) {
        handleConfigCheck(subdomain);
    } else if (command.equals("uptime")) {
        handleStatistic(message, subdomain, "uptime");
    } else if (command.equals("messages_from_xmpp")) {
        handleStatistic(message, subdomain, "messages_from_xmpp");
    } else if (command.equals("messages_to_xmpp")) {
        handleStatistic(message, subdomain, "messages_to_xmpp");
    } else if (command.equals("used_memory")) {
        handleStatistic(message, subdomain, "used_memory");
    } else if (command.equals("average_memory_per_user")) {
        handleStatistic(message, subdomain, "average_memory_per_user");
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:32,代码来源:GojaraAdminProcessor.java

示例2: getReply

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
static public Packet getReply(Connection connection, Packet packet,
        long timeout) throws XMPPException {
    PacketFilter responseFilter = new PacketIDFilter(packet.getID());
    PacketCollector response = connection
            .createPacketCollector(responseFilter);

    connection.sendPacket(packet);

    // Wait up to a certain number of seconds for a reply.
    Packet result = response.nextResult(timeout);

    // Stop queuing results
    response.cancel();

    if (result == null) {
        throw new XMPPException(SmackError.NO_RESPONSE_FROM_SERVER);
    } else if (result.getError() != null) {
        throw new XMPPException(result.getError());
    }
    return result;
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:22,代码来源:SyncPacketSend.java

示例3: process

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * Here we process the response of the remote command sent to Spectrum. We have to identify what kind of response it
 * is, as no tag for the command being responded is being sent. Currently these commands are used in Gojara
 * TransportSessionManager: online_users ( Chatmsg of online users for specific transport), usernames seperated by
 * newlines
 */
@Override
public void process(Packet packet, String subdomain, String to, String from) throws PacketRejectedException {
	Message message = (Message) packet;

	// handle different commands
	Log.debug("Intercepted spectrum message: " + message.toString());
	String command = packet.getID();
	if (command.equals("online_users")) {
		handleOnlineUsers(message, subdomain);
	} else if (command.equals("unregister")) {
		handleUnregister(message, subdomain);
	} else if (command.equals("config_check")) {
		handleConfigCheck(subdomain);
	} else if (command.equals("uptime")) {
		handleStatistic(message, subdomain, "uptime");
	} else if (command.equals("messages_from_xmpp")) {
		handleStatistic(message, subdomain, "messages_from_xmpp");
	} else if (command.equals("messages_to_xmpp")) {
		handleStatistic(message, subdomain, "messages_to_xmpp");
	} else if (command.equals("used_memory")) {
		handleStatistic(message, subdomain, "used_memory");
	} else if (command.equals("average_memory_per_user")) {
		handleStatistic(message, subdomain, "average_memory_per_user");
	}
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:32,代码来源:GojaraAdminProcessor.java

示例4: send

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * Sends the given XMPP packet over the backing transport. This accepts a
 * callback which is guaranteed to be invoked at a later point, either through
 * a normal response, error response, or timeout.
 *
 * @param packet packet to be sent
 * @param callback callback to be invoked on response or timeout
 * @param timeout timeout, in seconds, for this callback
 */
public void send(Packet packet, final PacketCallback callback, int timeout) {
  final String key = packet.getID() + "#" + packet.getTo() + "#" + packet.getFrom();

  final OutgoingCall call = new OutgoingCall(packet.getClass(), callback);
  if (callbacks.putIfAbsent(key, call) == null) {
    // Timeout runnable to be invoked on packet expiry.
    Runnable timeoutTask = new Runnable() {
      @Override
      public void run() {
        if (callbacks.remove(key, call)) {
          callback.error(
              FederationErrors.newFederationError(FederationError.Code.REMOTE_SERVER_TIMEOUT));
        } else {
          // Likely race condition where success has actually occurred. Ignore.
        }
      }
    };
    call.start(timeoutExecutor.schedule(timeoutTask, timeout, TimeUnit.SECONDS));
    transport.sendPacket(packet);
  } else {
    String msg = "Could not send packet, ID already in-flight: " + key;
    LOG.warning(msg);

    // Invoke the callback with an internal error.
    callback.error(
        FederationErrors.newFederationError(FederationError.Code.UNDEFINED_CONDITION, msg));
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:38,代码来源:XmppManager.java

示例5: causeImmediateTimeout

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * Cause an immediate timeout for the given packet, which is presumed to have
 * already been sent via {@link #send}.
 */
@VisibleForTesting
void causeImmediateTimeout(Packet packet) {
  String key = packet.getID() + "#" + packet.getTo() + "#" + packet.getFrom();
  OutgoingCall call = callbacks.remove(key);
  if (call != null) {
    call.callback.error(FederationErrors.newFederationError(
        FederationError.Code.REMOTE_SERVER_TIMEOUT, "Forced immediate timeout"));
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:14,代码来源:XmppManager.java

示例6: response

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * Invoke the callback for a packet already identified as a response. This may
 * either invoke the error or normal callback as necessary.
 */
private void response(Packet packet) {
  String key = packet.getID() + "#" + packet.getFrom() + "#" + packet.getTo();
  OutgoingCall call = callbacks.remove(key);

  if (call == null) {
    LOG.warning("Received response packet without paired request: " + packet.getID());
  } else {
    // Cancel the outstanding timeout.
    call.timeout.cancel(false);

    // Look for error condition and invoke the relevant callback.
    Element element = packet.getElement().element("error");
    if (element != null) {
      LOG.fine("Invoking error callback for: " + packet.getID());
      call.callback.error(toFederationError(new PacketError(element)));
    } else {
      if (call.responseType.equals(packet.getClass())) {
        LOG.fine("Invoking normal callback for: " + packet.getID());
        call.callback.run(packet);
      } else {
        String msg =
            "Received mismatched response packet type: expected " + call.responseType
                + ", given " + packet.getClass();
        LOG.warning(msg);
        call.callback.error(FederationErrors.newFederationError(
            FederationError.Code.UNDEFINED_CONDITION, msg));
      }
    }

    // Clear call's reference to callback, otherwise callback only
    // becomes eligible for GC once the timeout expires, because
    // timeoutExecutor holds on to the call object till then, even
    // though we cancelled the timeout.
    call.callback = null;
  }
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:41,代码来源:XmppManager.java

示例7: processIncoming

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
@Override
public void processIncoming(Packet packet) {
  if (packet instanceof Message) {
    Message message = (Message) packet;
    JID fromJID = packet.getFrom();
    JID toJID = packet.getTo();
    packet.setTo(fromJID);

    Element mmx = message.getChildElement(Constants.MMX, Constants.MMX_NS_MSG_PAYLOAD);
    Element meta = mmx.element(Constants.MMX_META);
    if (meta == null) {
      LOGGER.info("No meta in the message with id:{}", message.getID());
      return;
    }
    //Simulate SDK ack
    String originalMessageId = packet.getID();
    String from = fromJID.toString();
    String to = toJID.toString();

    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Attempting to deliver ack");
    }
    IQ ackIQ = BotRegistrationImpl.buildAckIQ(from, to, originalMessageId);
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Ack IQ:{}", ackIQ.toXML());
    }
    connection.sendPacket(ackIQ);
    String metaJSON = meta.getText();
    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Meta JSON:{}", metaJSON);
    }
    RPSLSGameInfo gameInfo = GsonData.getGson().fromJson(metaJSON, RPSLSGameInfo.class);

    if (gameInfo.getType() == RPSLSMessageType.INVITATION) {
      //process an invitation
      //step 1. Send an acceptance
      //step 2. Send a choice after 2 seconds.
      processRPSLSInvitationMessage(fromJID, toJID, gameInfo);
    } else {
      //ignore the other types
      LOGGER.info("Ignoring a message with type:{} message:{}", gameInfo.getType(), message);
    }
  }
}
 
开发者ID:magnetsystems,项目名称:message-server,代码行数:45,代码来源:RPSLSPlayerBotProcessor.java


注:本文中的org.xmpp.packet.Packet.getID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。