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


Java Message.setThread方法代码示例

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


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

示例1: notifyQueueStatus

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void notifyQueueStatus(JID sender, JID receiver, UserRequest request, boolean isPolling) {
    // Get the chatbot session of the user
    ChatbotSession session = getSession(receiver, false);
    if (session != null) {
        Message packet = new Message();
        packet.setTo(receiver);
        packet.setFrom(sender);
        packet.setThread(session.getMessageThread());
        if (session.getMessageThread() != null) {
            packet.setType(Message.Type.chat);
        }
        String body = getPositionMessage().replace("${position}",
                String.valueOf(request.getPosition()  +  1));
        body = body.replace("${waitTime}", String.valueOf(request.getTimeStatus()));
        packet.setBody(body);
        send(packet);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:19,代码来源:Chatbot.java

示例2: notifyQueueDepartued

import org.xmpp.packet.Message; //导入方法依赖的package包/类
public void notifyQueueDepartued(JID sender, JID receiver, UserRequest request,
        Request.CancelType type) {
    // Get the chatbot session of the user
    ChatbotSession session = getSession(receiver, false);
    if (session != null) {
        Message packet = new Message();
        packet.setTo(receiver);
        packet.setFrom(sender);
        packet.setThread(session.getMessageThread());
        if (session.getMessageThread() != null) {
            packet.setType(Message.Type.chat);
        }
        packet.setBody(getDepartureConfirmedMessage());
        send(packet);
        // Remove the session of this user
        removeSession(receiver);
    }
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:19,代码来源:Chatbot.java

示例3: shouldNotStoreEmptyChatMessagesWithOnlyChatStatesAndThread

import org.xmpp.packet.Message; //导入方法依赖的package包/类
@Test
public void shouldNotStoreEmptyChatMessagesWithOnlyChatStatesAndThread() {
    Message message = new Message();
    message.setType(Message.Type.chat);
    message.setThread("1234");
    PacketExtension chatState = new PacketExtension("composing", "http://jabber.org/protocol/chatstates");
    message.addExtension(chatState);
    assertFalse(OfflineMessageStore.shouldStoreMessage(message));
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:10,代码来源:OfflineMessageStoreTest.java

示例4: sendReply

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void sendReply(Message message, String reply) {
    Message packet = new Message();
    packet.setTo(message.getFrom());
    packet.setFrom(message.getTo());
    packet.setThread(message.getThread());
    packet.setType(message.getType());
    packet.setBody(reply);
    send(packet);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:10,代码来源:Chatbot.java

示例5: sendMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
private void sendMessage(JID receiver, String thread, String body) {
    Message packet = new Message();
    packet.setTo(receiver);
    packet.setFrom(workgroup.getJID());
    packet.setThread(thread);
    if (thread != null) {
        packet.setType(Message.Type.chat);
    }
    packet.setBody(body);
    send(packet);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:12,代码来源:Chatbot.java

示例6: deliver

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Delivers a message directly to this chat, which will add the message to
 * the collector and deliver it to all listeners registered with the Chat.
 * This is used by the Connection class to deliver messages without a thread
 * ID.
 * 
 * @param message
 *            the message.
 */
void deliver(Message message) {
    // Because the collector and listeners are expecting a thread ID with
    // a specific value, set the thread ID on the message even though it
    // probably never had one.
    message.setThread(threadID);

    for (MessageListener listener : listeners) {
        listener.processMessage(this, message);
    }
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:20,代码来源:Chat.java

示例7: processPacket

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Handle the receied packet and answer the weather information of the requested station id.
 * The request must be made using Message packets where the body of the message should be the
 * station id.<p>
 *
 * Note: I don't know the list of valid station ids so if you find the list please send it to me
 * so I can add it to this example.
 *
 * @param packet the Message requesting information about a certain station id.
 */
public void processPacket(Packet packet) {
    System.out.println("Received package:"+packet.toXML());
    // Only process Message packets
    if (packet instanceof Message) {
        // Get the requested station to obtain it's weather information
        Message message = (Message) packet;
        String station = message.getBody();
        // Send the request and get the weather information
        Metar metar = Weather.getMetar(station, 5000);

        // Build the answer
        Message reply = new Message();
        reply.setTo(message.getFrom());
        reply.setFrom(message.getTo());
        reply.setType(message.getType());
        reply.setThread(message.getThread());

        // Append the discovered information if something was found
        if (metar != null) {
            StringBuilder sb = new StringBuilder();
            sb.append("station id : " + metar.getStationID());
            sb.append("\rwind dir   : " + metar.getWindDirection() + " degrees");
            sb.append("\rwind speed : " + metar.getWindSpeedInMPH() + " mph, " +
                                                 metar.getWindSpeedInKnots() + " knots");
            if (!metar.getVisibilityLessThan()) {
                sb.append("\rvisibility : " + metar.getVisibility() + " mile(s)");
            } else {
                sb.append("\rvisibility : < " + metar.getVisibility() + " mile(s)");
            }

            sb.append("\rpressure   : " + metar.getPressure() + " in Hg");
            sb.append("\rtemperaturePrecise: " +
                               metar.getTemperaturePreciseInCelsius() + " C, " +
                               metar.getTemperaturePreciseInFahrenheit() + " F");
            sb.append("\rtemperature: " +
                               metar.getTemperatureInCelsius() + " C, " +
                               metar.getTemperatureInFahrenheit() + " F");
            sb.append("\rtemperatureMostPrecise: " +
                               metar.getTemperatureMostPreciseInCelsius() + " C, " +
                               metar.getTemperatureMostPreciseInFahrenheit() + " F");
            reply.setBody(sb.toString());
        }
        else {
            // Answer that the requested station id does not exist
            reply.setBody("Unknown station ID");
        }

        // Send the response to the sender of the request
        try {
            ComponentManagerFactory.getComponentManager().sendPacket(this, reply);
        } catch (ComponentException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:igniterealtime,项目名称:Whack,代码行数:66,代码来源:WeatherComponent.java

示例8: handleMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Handle a receied message and answer the weather information of the requested station id.
 * The request must be made using Message packets where the body of the message should be the
 * station id.<p>
 *
 * Note: I don't know the list of valid station ids so if you find the list please send it to me
 * so I can add it to this example.
 *
 * @param message the Message requesting information about a certain station id.
 */
@Override
protected void handleMessage(Message message) {
    System.out.println("Received message:"+message.toXML());
    // Get the requested station to obtain it's weather information
    String station = message.getBody();
    // Send the request and get the weather information
    Metar metar = Weather.getMetar(station, 5000);

    // Build the answer
    Message reply = new Message();
    reply.setTo(message.getFrom());
    reply.setFrom(message.getTo());
    reply.setType(message.getType());
    reply.setThread(message.getThread());

    // Append the discovered information if something was found
    if (metar != null) {
        StringBuilder sb = new StringBuilder();
        sb.append("station id : " + metar.getStationID());
        sb.append("\rwind dir   : " + metar.getWindDirection() + " degrees");
        sb.append("\rwind speed : " + metar.getWindSpeedInMPH() + " mph, " +
                                             metar.getWindSpeedInKnots() + " knots");
        if (!metar.getVisibilityLessThan()) {
            sb.append("\rvisibility : " + metar.getVisibility() + " mile(s)");
        }
        else {
            sb.append("\rvisibility : < " + metar.getVisibility() + " mile(s)");
        }

        sb.append("\rpressure   : " + metar.getPressure() + " in Hg");
        sb.append("\rtemperaturePrecise: " +
                           metar.getTemperaturePreciseInCelsius() + " C, " +
                           metar.getTemperaturePreciseInFahrenheit() + " F");
        sb.append("\rtemperature: " +
                           metar.getTemperatureInCelsius() + " C, " +
                           metar.getTemperatureInFahrenheit() + " F");
        sb.append("\rtemperatureMostPrecise: " +
                           metar.getTemperatureMostPreciseInCelsius() + " C, " +
                           metar.getTemperatureMostPreciseInFahrenheit() + " F");
        reply.setBody(sb.toString());
    }
    else {
        // Answer that the requested station id does not exist
        reply.setBody("Unknown station ID");
    }

    // Send the response to the sender of the request
    send(reply);
}
 
开发者ID:igniterealtime,项目名称:Whack,代码行数:60,代码来源:WeatherComponent.java

示例9: sendMessage

import org.xmpp.packet.Message; //导入方法依赖的package包/类
/**
 * Sends the specified text as a message to the other chat participant. This
 * is a convenience method for:
 * 
 * <pre>
 * Message message = chat.createMessage();
 * message.setBody(messageText);
 * chat.sendMessage(message);
 * </pre>
 * 
 * @param text
 *            the text to send.
 * @throws XMPPException
 *             if sending the message fails.
 */
public void sendMessage(String text) throws XMPPException {
    Message message = new Message();
    message.setTo(participant);
    message.setType(Type.chat);
    message.setThread(threadID);
    message.setBody(text);
    chatManager.sendMessage(this, message);
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:24,代码来源:Chat.java


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