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


Java Packet.setTo方法代码示例

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


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

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

示例2: presencePush

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * Just pushes a available presence, we need this for GAJIM Client as it does not push available presence after
 * registering We also wait a little so after register transport is on users roster. Really didnt wanted this here
 * but doesnt really belong anywhere else
 * 
 * @param to
 * @param from
 * @param delay MS until the job should be done
 */
private void presencePush(final JID to, final JID from, int delay) {
    TimerTask pushPresenceTask = new TimerTask() {

        @Override
        public void run() {
            PacketRouter router = server.getPacketRouter();
            Packet presence = new Presence();
            presence.setTo(to);
            presence.setFrom(from);
            router.route(presence);
        }
    };

    Timer timer = new Timer();
    timer.schedule(pushPresenceTask, delay);

}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:27,代码来源:MainInterceptor.java

示例3: 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:coodeer,项目名称:g3server,代码行数:24,代码来源:TransportHandler.java

示例4: presencePush

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * Just pushes a available presence, we need this for GAJIM Client as it does not push available presence after
 * registering We also wait a little so after register transport is on users roster. Really didnt wanted this here
 * but doesnt really belong anywhere else
 * 
 * @param to
 * @param from
 * @param delay MS until the job should be done
 */
private void presencePush(final JID to, final JID from, int delay) {
	TimerTask pushPresenceTask = new TimerTask() {

		@Override
		public void run() {
			PacketRouter router = server.getPacketRouter();
			Packet presence = new Presence();
			presence.setTo(to);
			presence.setFrom(from);
			router.route(presence);
		}
	};

	Timer timer = new Timer();
	timer.schedule(pushPresenceTask, delay);

}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:27,代码来源:MainInterceptor.java

示例5: main

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * @param args
 */
public static void main(String[] args) {
    List<Packet> list = new ArrayList<Packet>();
    Packet message = new Message();
    message.setTo("[email protected]/android");
    message.setFrom("[email protected]/iphone");
    list.add(message);
    testSerializer(message, PacketConstant.CONTENT_TYPE_BSON);

    testSerializer(message, PacketConstant.CONTENT_TYPE_JSON);

    Packet iq = new IQ();
    iq.setTo("[email protected]/android");
    iq.setFrom("[email protected]/iphone");
    list.add(iq);
    testSerializer(iq, PacketConstant.CONTENT_TYPE_BSON);

    testSerializer(iq, PacketConstant.CONTENT_TYPE_JSON);

    Packet presence = new Presence();
    presence.setTo("[email protected]/android");
    presence.setFrom("[email protected]/iphone");
    list.add(presence);
    testSerializer(presence, PacketConstant.CONTENT_TYPE_BSON);
    testSerializer(presence, PacketConstant.CONTENT_TYPE_JSON);

    testSerializerElement(presence.getElement(), PacketConstant.CONTENT_TYPE_BSON);
    testSerializerElement(presence.getElement(), PacketConstant.CONTENT_TYPE_JSON);
}
 
开发者ID:blusechen,项目名称:venus,代码行数:32,代码来源:XmppJsonSerializer.java

示例6: testPacketSendMalformedFailure

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * Test the simple case of packet send/receive by sending a malformed request.
 */
public void testPacketSendMalformedFailure() {
  Packet packet = new IQ();
  packet.setFrom(server1.jid);
  packet.setID("irrelevant");
  packet.setTo(server2.jid);

  PacketCallback callback = mock(PacketCallback.class);

  // Send an outgoing packet from server1 -> server2
  server1.manager.send(packet, callback, PACKET_TIMEOUT);
  assertEquals("First transport should have a single packet pending",
      1, server1.transport.packets.size());
  assertEquals("First transport should have unmodified outgoing packet",
      packet, server1.transport.packets.peek());

  // Confirm that server2 sent back an error
  assertEquals("Second transport should have a single packet pending",
      1, server2.transport.packets.size());
  assertNotNull("Second transport should be an error packet",
      server2.transport.packets.peek().getError());

  // Ensure the error is interpreted correctly and returned to the callback
  ArgumentCaptor<FederationError> errorCaptor = ArgumentCaptor.forClass(FederationError.class);
  verify(callback).error(errorCaptor.capture());
  verify(callback, never()).run(any(Packet.class));
  assertEquals("Invalid packet was sent, error should be BAD_REQUEST",
      FederationError.Code.BAD_REQUEST, errorCaptor.getValue().getErrorCode());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:32,代码来源:RoundTripTest.java

示例7: send

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
@Override
public void send(Packet packet) {
    if (packet == null) {
        return;
    }
    packet.setTo(user.getAddress());

    if (session != null && session.getStatus() == Session.STATUS_AUTHENTICATED) {
        // Send the packet directly to the local user session
        session.process(packet);
    }
    else {
        router.route(packet);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:16,代码来源:LocalMUCRole.java

示例8: send

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public void send(Packet packet) {
    if (packet == null) {
        return;
    }
    packet.setTo(user.getAddress());

    if (session != null && session.getStatus() == Session.STATUS_AUTHENTICATED) {
        // Send the packet directly to the local user session
        session.process(packet);
    }
    else {
        router.route(packet);
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:15,代码来源:LocalMUCRole.java

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

示例10: userBroadcast

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
/**
 * Broadcasts the given data to all connected sessions for a particular
 * user. Excellent for updating all connected resources for users such as
 * roster pushes.
 *
 * @param username the user to send the boradcast to.
 * @param packet the packet to be broadcast.
 * @throws PacketException if a packet exception occurs.
 */
public void userBroadcast(String username, Packet packet) throws PacketException {
    // TODO broadcast to ALL sessions of the user and not only available
    for (JID address : routingTable.getRoutes(new JID(username, serverName, null), null)) {
        packet.setTo(address);
        routingTable.routePacket(address, packet, true);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:SessionManager.java


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