Java 类org.jivesoftware.smack.MessageListener 实例源码

项目:LOL-Chat    文件:Friend.java   
private Chat getChat() {
    if (chat == null) {
        chat = ChatManager.getInstanceFor(con).createChat(getUserId(),
                new MessageListener() {

                    @Override
                    public void processMessage(Chat c, Message m) {
                        if (chat != null && listener != null) {
                            listener.onMessage(instance, m.getBody());
                        }

                    }
                });
    }
    return chat;
}
项目:system_updater    文件:Bot.java   
private void sendMessage(String to,String message){
    /*
     * this sends a message to someone
     * @param to the xmmp-account who receives the message, the destination
     * @param message: yeah, the text I'm sending...
     */

    ChatManager chatmanager = conn.getChatManager();
    Chat newChat = chatmanager.createChat(to, new MessageListener() {
        public void processMessage(Chat chat, Message m) {
        }
    });
    try {
        newChat.sendMessage(message);
    }
    catch (XMPPException e) {
        System.out.println("Error Delivering block" +e);
    }

}
项目:League-of-Legends-XMPP-Chat-Library    文件:Friend.java   
private Chat getChat() {
    if (chat == null) {
        chat = ChatManager.getInstanceFor(con).createChat(getUserId(),
                new MessageListener() {

                    @Override
                    public void processMessage(Chat c, Message m) {
                        if (chat != null && listener != null) {
                            listener.onMessage(instance, m.getBody());
                        }

                    }
                });
    }
    return chat;
}
项目:SmackStudy    文件:XMPPUtil.java   
/**
 * 创建聊天
 * @param xmppConnection
 * @param toUser
 * @param messageListener
 * @return
 */
public static Chat createChat(XMPPConnection xmppConnection,String toUser,MessageListener messageListener){
    // 获取当前登陆用户的聊天管理器 
    ChatManager chatManager = xmppConnection.getChatManager();
    // 为指定用户创建一个chat,MyMessageListeners用于监听对方发过来的消息  */
    Chat chat = chatManager.createChat(toUser+"@" + SERVERNAME, messageListener);
    return chat;
}
项目:SmackStudy    文件:XMPPUtil.java   
/**
 * 创建聊天
 * @param xmppConnection
 * @param toUser
 * @param messageListener
 * @return
 */
public static Chat createChat(XMPPConnection xmppConnection,String toUser,MessageListener messageListener){
    // 获取当前登陆用户的聊天管理器
    ChatManager chatManager = xmppConnection.getChatManager();
    // 为指定用户创建一个chat,MyMessageListeners用于监听对方发过来的消息  */
    Chat chat = chatManager.createChat(toUser+"@" + SERVERNAME, messageListener);
    return chat;
}
项目:Smack    文件:ChatManager.java   
void sendMessage(Chat chat, Message message) throws NotConnectedException {
    for(Map.Entry<MessageListener, StanzaFilter> interceptor : interceptors.entrySet()) {
        StanzaFilter filter = interceptor.getValue();
        if(filter != null && filter.accept(message)) {
            interceptor.getKey().processMessage(message);
        }
    }
    // Ensure that messages being sent have a proper FROM value
    if (message.getFrom() == null) {
        message.setFrom(connection().getUser());
    }
    connection().sendStanza(message);
}
项目:java-bells    文件:ChatStateManager.java   
private void fireNewChatState(Chat chat, ChatState state) {
    for (MessageListener listener : chat.getListeners()) {
        if (listener instanceof ChatStateListener) {
            ((ChatStateListener) listener).stateChanged(chat, state);
        }
    }
}
项目:sonar-xmpp-notifications    文件:XMPPAdapter.java   
public void sendMessage(XMPPMessage xmppMessage) throws XMPPException {
  ChatManager chatmanager = connection.getChatManager();
  Chat newChat = chatmanager.createChat(xmppMessage.getTo(), new MessageListener() {
    @Override
    public void processMessage(Chat chat, Message message) {
      // No need to implement
    }
  });

  LOG.debug("Sending message '" + xmppMessage.getMessage() + "' to " + newChat.getParticipant());
  newChat.sendMessage(xmppMessage.getMessage());

}
项目:sonar-xmpp-notifications    文件:XMPPAdapterTest.java   
@Test
public void shouldSendMessage() throws XMPPException {
  adapter.connect();
  XMPPMessage xmppMessage = new XMPPMessage();
  ChatManager chatmanager = mock(ChatManager.class);
  Chat chat = mock(Chat.class);
  when(connection.getChatManager()).thenReturn(chatmanager);
  when(chatmanager.createChat(eq(xmppMessage.getTo()), any(MessageListener.class))).thenReturn(chat);

  adapter.sendMessage(xmppMessage);
  verify(chat).sendMessage(xmppMessage.getMessage());
}
项目:SmackStudy    文件:XMPPConnectionWrapper.java   
@Override
public Chat createChat(String toUser, MessageListener messageListener) {
    return XMPPUtil.createChat(xmppConnection, toUser, messageListener);
}
项目:SmackStudy    文件:XMPPConnectionWrapper.java   
@Override
public Chat createChat(String toUser, MessageListener messageListener) {
    return XMPPUtil.createChat(xmppConnection, toUser, messageListener);
}
项目:Smack    文件:ChatManager.java   
public void addOutgoingMessageInterceptor(MessageListener messageInterceptor, StanzaFilter filter) {
    if (messageInterceptor == null) {
        return;
    }
    interceptors.put(messageInterceptor, filter);
}
项目:visual-programming    文件:XmppAgent.java   
protected MessageListener getMessageListener() {
    return messageListener;
}
项目:SmackStudy    文件:IXMPConnectionWrapper.java   
/**
 * 创建聊天
 * @param toUser
 * @param messageListener
 * @return
 */
Chat createChat(String toUser, MessageListener messageListener);
项目:SmackStudy    文件:IXMPConnectionWrapper.java   
/**
 * 创建聊天
 * @param toUser
 * @param messageListener
 * @return
 */
Chat createChat(String toUser, MessageListener messageListener);
项目:Smack    文件:ChatManager.java   
/**
 * Adds an interceptor which intercepts any messages sent through chats.
 *
 * @param messageInterceptor the interceptor.
 */
public void addOutgoingMessageInterceptor(MessageListener messageInterceptor) {
    addOutgoingMessageInterceptor(messageInterceptor, null);
}
项目:Smack    文件:MultiUserChat.java   
/**
 * Adds a stanza(/packet) listener that will be notified of any new messages in the
 * group chat. Only "group chat" messages addressed to this group chat will
 * be delivered to the listener. If you wish to listen for other packets
 * that may be associated with this group chat, you should register a
 * PacketListener directly with the XMPPConnection with the appropriate
 * PacketListener.
 *
 * @param listener a stanza(/packet) listener.
 * @return true if the listener was not already added.
 */
public boolean addMessageListener(MessageListener listener) {
    return messageListeners.add(listener);
}
项目:Smack    文件:MultiUserChat.java   
/**
 * Removes a stanza(/packet) listener that was being notified of any new messages in the
 * multi user chat. Only "group chat" messages addressed to this multi user chat were
 * being delivered to the listener.
 *
 * @param listener a stanza(/packet) listener.
 * @return true if the listener was removed, otherwise the listener was not added previously.
 */
public boolean removeMessageListener(MessageListener listener) {
    return messageListeners.remove(listener);
}