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


Java Packet.getTo方法代码示例

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


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

示例1: deliver

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * 将数据包传递给数据包收件人
 * 
 * @param packet
 *            要被投递的数据包
 * @throws PacketException
 *             如果数据包为空,或收件人未找到
 */
public static void deliver(Packet packet) throws PacketException {
	if (packet == null) {
		throw new PacketException("数据包为null");
	}

	try {
		JID recipient = packet.getTo();
		if (recipient != null) {
			ClientSession clientSession = SessionManager.getInstance()
					.getSession(recipient);
			if (clientSession != null) {
				clientSession.deliver(packet);
			}
		}
	} catch (Exception e) {
		log.error("不能提供数据包: " + packet.toString(), e);
	}
}
 
开发者ID:lijian17,项目名称:androidpn-server,代码行数:27,代码来源:PacketDeliverer.java

示例2: process

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
@Override
public void process(Packet packet) throws UnauthorizedException, PacketException {
    boolean handled = false;
    String host = packet.getTo().getDomain();
    for (Channel<Packet> channel : transports.values()) {
        if (channel.getName().equalsIgnoreCase(host)) {
            channel.add(packet);
            handled = true;
        }
    }
    if (!handled) {
        JID recipient = packet.getTo();
        JID sender = packet.getFrom();
        packet.setError(PacketError.Condition.remote_server_timeout);
        packet.setFrom(recipient);
        packet.setTo(sender);
        try {
            deliverer.deliver(packet);
        }
        catch (PacketException e) {
            Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:25,代码来源:TransportHandler.java

示例3: processPacket

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public void processPacket(Packet packet) {
    if (!isServiceEnabled()) {
        return;
    }
    // The MUC service will receive all the packets whose domain matches the domain of the MUC
    // service. This means that, for instance, a disco request should be responded by the
    // service itself instead of relying on the server to handle the request.
    try {
        // Check if the packet is a disco request or a packet with namespace iq:register
        if (packet instanceof IQ) {
            if (process((IQ)packet)) {
                return;
            }
        }
        // The packet is a normal packet that should possibly be sent to the room
        JID receipient = packet.getTo();
        String roomName = receipient != null ? receipient.getNode() : null;
        getChatUser(packet.getFrom(), roomName).process(packet);
    }
    catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:24,代码来源:MultiUserChatServiceImpl.java

示例4: deliver

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * Delivers the packet to the packet recipient.  
 * 
 * @param packet the packet to deliver
 * @throws PacketException if the packet is null or the recipient was not found.
 */
public static void deliver(Packet packet) throws PacketException {
    if (packet == null) {
        throw new PacketException("Packet was null");
    }

    try {
        JID recipient = packet.getTo();
        if (recipient != null) {
            ClientSession clientSession = SessionManager.getInstance()
                    .getSession(recipient);
            if (clientSession != null) {
                clientSession.deliver(packet);
            }
        }
    } catch (Exception e) {
        log.error("Could not deliver packet: " + packet.toString(), e);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:25,代码来源:PacketDeliverer.java

示例5: deliver

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public static void deliver(Packet packet) throws PacketException {
    if (packet == null) {
        throw new PacketException("Packet was null");
    }

    try {
        JID recipient = packet.getTo();
        if (recipient != null) {
            ClientSession clientSession = SessionManager.getInstance()
                    .getSession(recipient);
            if (clientSession != null) {
                clientSession.deliver(packet);
            }
        }
    } catch (Exception e) {
        log.error("Could not deliver packet\n" + packet.toString(), e);
    }
}
 
开发者ID:elphinkuo,项目名称:Androidpn,代码行数:19,代码来源:PacketDeliverer.java

示例6: process

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public void process(Packet packet) throws UnauthorizedException, PacketException {
    boolean handled = false;
    String host = packet.getTo().getDomain();
    for (Channel channel : transports.values()) {
        if (channel.getName().equalsIgnoreCase(host)) {
            channel.add(packet);
            handled = true;
        }
    }
    if (!handled) {
        JID recipient = packet.getTo();
        JID sender = packet.getFrom();
        packet.setError(PacketError.Condition.remote_server_timeout);
        packet.setFrom(recipient);
        packet.setTo(sender);
        try {
            deliverer.deliver(packet);
        }
        catch (PacketException e) {
            Log.error(LocaleUtils.getLocalizedString("admin.error"), e);
        }
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:24,代码来源:TransportHandler.java

示例7: 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

示例8: 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

示例9: 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

示例10: accept

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public boolean accept(Packet packet) {
    if (packet.getTo() == null) {
        return false;
    } else {
        return packet.getTo().toFullJID().toLowerCase().indexOf(to) != -1;
    }
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:8,代码来源:ToContainsFilter.java

示例11: process

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
@Override
 public void process(Packet packet) throws UnauthorizedException, PacketException {
    try {
        JID recipient = packet.getTo();
        // Check if the target domain belongs to a remote server or a component
        if (server.matchesComponent(recipient) || server.isRemote(recipient)) {
            routingTable.routePacket(recipient, packet, false);
        }
        // The target domain belongs to the local server
        else if (recipient == null || (recipient.getNode() == null && recipient.getResource() == null)) {
            // no TO was found so send back the packet to the sender
            routingTable.routePacket(packet.getFrom(), packet, false);
        }
        else if (recipient.getResource() != null || !(packet instanceof Presence)) {
            // JID is of the form <[email protected]/resource>
            routingTable.routePacket(recipient, packet, false);
        }
        else {
            // JID is of the form <[email protected]>
            for (JID route : routingTable.getRoutes(recipient, null)) {
                routingTable.routePacket(route, packet, false);
            }
        }
    }
    catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error.deliver") + "\n" + packet.toString(), e);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:29,代码来源:SocketPacketWriteHandler.java

示例12: findMatch

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public Rule findMatch(Packet packet) {
	if (packet.getTo() == null || packet.getFrom() == null)
		return null;
	// TODO Would it be better to keep a local copy of the rules?
	for (Rule rule : ruleManager.getRules()) {
		if (!rule.isDisabled() && typeMatch(rule.getPackeType(), packet)
				&& sourceDestMatch(rule.getDestType(), rule.getDestination(), packet.getTo())
				&& sourceDestMatch(rule.getSourceType(), rule.getSource(), packet.getFrom())) {

			return rule;
		}
	}
	return null;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:15,代码来源:PacketFilter.java

示例13: interceptPacket

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public void interceptPacket(Packet packet, Session session, boolean read, boolean processed) {
    if (!processed) {
        // Ignore packets sent or received by users that are present in the ignore list
        JID from = packet.getFrom();
        JID to = packet.getTo();
        if ((from == null || !ignoreList.contains(from.getNode())) &&
                (to == null || !ignoreList.contains(to.getNode()))) {
            auditor.audit(packet, session);
        }
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:12,代码来源:AuditManagerImpl.java

示例14: process

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public void process(Packet packet) throws UnauthorizedException, PacketException {
    try {
        JID recipient = packet.getTo();
        // Check if the target domain belongs to a remote server or a component
        if (server.matchesComponent(recipient) || server.isRemote(recipient)) {
            routingTable.routePacket(recipient, packet, false);
        }
        // The target domain belongs to the local server
        else if (recipient == null || (recipient.getNode() == null && recipient.getResource() == null)) {
            // no TO was found so send back the packet to the sender
            routingTable.routePacket(packet.getFrom(), packet, false);
        }
        else if (recipient.getResource() != null || !(packet instanceof Presence)) {
            // JID is of the form <[email protected]/resource>
            routingTable.routePacket(recipient, packet, false);
        }
        else {
            // JID is of the form <[email protected]>
            for (JID route : routingTable.getRoutes(recipient, null)) {
                routingTable.routePacket(route, packet, false);
            }
        }
    }
    catch (Exception e) {
        Log.error(LocaleUtils.getLocalizedString("admin.error.deliver") + "\n" + packet.toString(), e);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:28,代码来源:SocketPacketWriteHandler.java

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