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


Java Packet.setFrom方法代码示例

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


在下文中一共展示了Packet.setFrom方法的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: sendPrivatePacket

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public void sendPrivatePacket(Packet packet, MUCRole senderRole) throws NotFoundException {
    String resource = packet.getTo().getResource();
    MUCRole occupant = occupants.get(resource.toLowerCase());
    if (occupant != null) {
        packet.setFrom(senderRole.getRoleAddress());
        occupant.send(packet);
        if(packet instanceof Message) {
           Message message = (Message) packet;
             MUCEventDispatcher.privateMessageRecieved(occupant.getUserAddress(), senderRole.getUserAddress(),
                     message);
        }
    }
    else {
        throw new NotFoundException();
    }
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:17,代码来源:LocalMUCRoom.java

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

示例5: sendPrivatePacket

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public void sendPrivatePacket(Packet packet, MUCRole senderRole) throws NotFoundException {
    String resource = packet.getTo().getResource();
    List<MUCRole> occupants = occupantsByNickname.get(resource.toLowerCase());
    if (occupants == null || occupants.size() == 0) {
        throw new NotFoundException();
    }
    for (MUCRole occupant : occupants) {
        packet.setFrom(senderRole.getRoleAddress());
        occupant.send(packet);
        if(packet instanceof Message) {
           Message message = (Message) packet;
             MUCEventDispatcher.privateMessageRecieved(occupant.getUserAddress(), senderRole.getUserAddress(),
                     message);
        }
    }
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:17,代码来源:LocalMUCRoom.java

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

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

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

示例9: sendPrivatePacket

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
@Override
public void sendPrivatePacket(Packet packet, MUCRole senderRole) throws NotFoundException, ForbiddenException {
    switch (senderRole.getRole()) { // intended fall-through
        case none:
            throw new ForbiddenException();
        default:
        case visitor:
            if (canSendPrivateMessage().equals( "participants" )) throw new ForbiddenException();
        case participant:
            if (canSendPrivateMessage().equals( "moderators" )) throw new ForbiddenException();
        case moderator:
            if (canSendPrivateMessage().equals( "none" )) throw new ForbiddenException();
    }
    String resource = packet.getTo().getResource();
    List<MUCRole> occupants = occupantsByNickname.get(resource.toLowerCase());
    if (occupants == null || occupants.size() == 0) {
        throw new NotFoundException();
    }
    for (MUCRole occupant : occupants) {
        packet.setFrom(senderRole.getRoleAddress());
        occupant.send(packet);
        if(packet instanceof Message) {
           Message message = (Message) packet;
             MUCEventDispatcher.privateMessageRecieved(occupant.getUserAddress(), senderRole.getUserAddress(),
                     message);
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:29,代码来源:LocalMUCRoom.java

示例10: AuditPacket

import org.xmpp.packet.Packet; //导入方法依赖的package包/类
public AuditPacket(Packet packet, Session session) {
    element = docFactory.createElement("packet", "http://www.jivesoftware.org");
    creationDate = new Date();
    if (session != null && session.getStreamID() != null) {
        element.addAttribute("streamID", session.getStreamID().toString());
    }
    switch (session == null ? 0 : session.getStatus()) {
        case Session.STATUS_AUTHENTICATED:
            element.addAttribute("status", "auth");
            break;
        case Session.STATUS_CLOSED:
            element.addAttribute("status", "closed");
            break;
        case Session.STATUS_CONNECTED:
            element.addAttribute("status", "connected");
            // This is a workaround. Since we don't want to have an incorrect FROM attribute
            // value we need to clean up the FROM attribute. The FROM attribute will contain
            // an incorrect value since we are setting a fake JID until the user actually
            // authenticates with the server.
            packet.setFrom((String) null);
            break;
        default:
            element.addAttribute("status", "unknown");
            break;
    }
    element.addAttribute("timestamp", auditFormat.format(creationDate));
    element.add(packet.getElement());
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:29,代码来源:AuditorImpl.java


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