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


Java MessageListener類代碼示例

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


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

示例1: setMessageListener

import javax.wireless.messaging.MessageListener; //導入依賴的package包/類
public void setMessageListener(MessageListener a0)
	throws java.io.IOException
{ }
 
開發者ID:Orange-OpenSource,項目名稱:matos-profiles,代碼行數:4,代碼來源:MessageConnection.java

示例2: setMessageListener

import javax.wireless.messaging.MessageListener; //導入依賴的package包/類
/**
 * Registers a <code>MessageListener</code> object.
 * <p>
 * The platform will notify this listener object when a message has been
 * received to this <code>MessageConnection</code>.
 * </p>
 * <p>If the queue of this <code>MessageConnection</code> contains some
 * incoming messages that the application haven't read before the call
 * of this method, the newly registered listener will be notified
 * immediately exactly once for each such message in the queue.
 * </p>
 * <p>There can be at most one listener object registered for
 * a <code>MessageConnection</code> object at any given point in time.
 * Setting a new listener will implicitly de-register the possibly
 * previously set listener.
 * </p>
 * <p>Passing <code>null</code> as the parameter de-registers the currently
 * registered listener, if any.
 * </p>
 * @param listener <code>MessageListener</code> object to be registered.
 *                 If <code>null</code>,
 *                 the possibly currently registered listener will be
 *                 de-registered and will not receive notifications.
 * @exception java.lang.SecurityException if the application does not
 *         have a permission to receive messages using the given port
 *         number
 * @exception java.io.IOException if it is requested to register
 *            a listener on a client connection or if the connection
 *            has been closed
 */
public void setMessageListener(MessageListener listener)
        throws IOException {

    needStopReceiver = false;

    if (listener != null) {
        /*
         * Make sure the connection is still open.
         */
        ensureOpen();

        /*
         * Check if we have permission to recieve.
         */
        checkReceivePermission();

        /*
         * Don't let the application waste time listening on a client
         * connection, which can not be used for receive operations.
         */
        if (host != null && host.length() > 0) {
            throw new IOException("Cannot listen on client connection");
        }
    }

    synchronized (listenerLock) {
        if ((m_listener != null) && (listener == null)) {
            needStopReceiver = true;
        }
        m_listener = listener;
        /* Start a new receive thread when need */
        if ((listener != null) && (m_listenerThread == null)) {
            startReceiverThread();
        }
    }

    /* Kill listener when need */
    if (needStopReceiver) {
        /* Close thread without deregistering */
        close00(connHandle, 0);
        try {
            m_listenerThread.join();
        } catch (InterruptedException ie) {
        }  /* Ignore interrupted exception */
        m_listenerThread = null;

        /* Unblock the low level */
        unblock00(appPackage.UNUSED_APP_ID);
    }
}
 
開發者ID:mozilla,項目名稱:pluotsorbet,代碼行數:81,代碼來源:ProtocolBase.java


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