當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageListener類代碼示例

本文整理匯總了Java中org.jivesoftware.smack.MessageListener的典型用法代碼示例。如果您正苦於以下問題:Java MessageListener類的具體用法?Java MessageListener怎麽用?Java MessageListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MessageListener類屬於org.jivesoftware.smack包,在下文中一共展示了MessageListener類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getChat

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
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;
}
 
開發者ID:tesfaye,項目名稱:LOL-Chat,代碼行數:17,代碼來源:Friend.java

示例2: sendMessage

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
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);
	}

}
 
開發者ID:ControlAltDieliet,項目名稱:system_updater,代碼行數:21,代碼來源:Bot.java

示例3: createChat

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
/**
 * 創建聊天
 * @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;
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:15,代碼來源:XMPPUtil.java

示例4: createChat

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
/**
 * 創建聊天
 * @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;
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:15,代碼來源:XMPPUtil.java

示例5: sendMessage

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
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);
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:14,代碼來源:ChatManager.java

示例6: fireNewChatState

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
private void fireNewChatState(Chat chat, ChatState state) {
    for (MessageListener listener : chat.getListeners()) {
        if (listener instanceof ChatStateListener) {
            ((ChatStateListener) listener).stateChanged(chat, state);
        }
    }
}
 
開發者ID:bejayoharen,項目名稱:java-bells,代碼行數:8,代碼來源:ChatStateManager.java

示例7: sendMessage

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
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());

}
 
開發者ID:ppapapetrou76,項目名稱:sonar-xmpp-notifications,代碼行數:14,代碼來源:XMPPAdapter.java

示例8: shouldSendMessage

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
@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());
}
 
開發者ID:ppapapetrou76,項目名稱:sonar-xmpp-notifications,代碼行數:13,代碼來源:XMPPAdapterTest.java

示例9: createChat

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
@Override
public Chat createChat(String toUser, MessageListener messageListener) {
	return XMPPUtil.createChat(xmppConnection, toUser, messageListener);
}
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:5,代碼來源:XMPPConnectionWrapper.java

示例10: addOutgoingMessageInterceptor

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
public void addOutgoingMessageInterceptor(MessageListener messageInterceptor, StanzaFilter filter) {
    if (messageInterceptor == null) {
        return;
    }
    interceptors.put(messageInterceptor, filter);
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:7,代碼來源:ChatManager.java

示例11: getMessageListener

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
protected MessageListener getMessageListener() {
	return messageListener;
}
 
開發者ID:jackhatedance,項目名稱:visual-programming,代碼行數:4,代碼來源:XmppAgent.java

示例12: createChat

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
/**
 * 創建聊天
 * @param toUser
 * @param messageListener
 * @return
 */
Chat createChat(String toUser, MessageListener messageListener);
 
開發者ID:FanHuaRan,項目名稱:SmackStudy,代碼行數:8,代碼來源:IXMPConnectionWrapper.java

示例13: addMessageListener

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:15,代碼來源:MultiUserChat.java

示例14: removeMessageListener

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:TTalkIM,項目名稱:Smack,代碼行數:12,代碼來源:MultiUserChat.java

示例15: createPrivateChat

import org.jivesoftware.smack.MessageListener; //導入依賴的package包/類
/**
 * Returns a new Chat for sending private messages to a given room occupant.
 * The Chat's occupant address is the room's JID (i.e. [email protected]/nick). The server
 * service will change the 'from' address to the sender's room JID and delivering the message
 * to the intended recipient's full JID.
 *
 * @param occupant occupant unique room JID (e.g. '[email protected]/Paul').
 * @param listener the listener is a message listener that will handle messages for the newly
 * created chat.
 * @return new Chat for sending private messages to a given room occupant.
 */
public Chat createPrivateChat(String occupant, MessageListener listener) {
    return connection.getChatManager().createChat(occupant, listener);
}
 
開發者ID:ice-coffee,項目名稱:EIM,代碼行數:15,代碼來源:MultiUserChat.java


注:本文中的org.jivesoftware.smack.MessageListener類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。