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


Java MessageHandler.Partial方法代碼示例

本文整理匯總了Java中javax.websocket.MessageHandler.Partial方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageHandler.Partial方法的具體用法?Java MessageHandler.Partial怎麽用?Java MessageHandler.Partial使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.websocket.MessageHandler的用法示例。


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

示例1: sendMessageBinary

import javax.websocket.MessageHandler; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void sendMessageBinary(ByteBuffer msg, boolean last)
        throws WsIOException {
    if (binaryMsgHandler instanceof WrappedMessageHandler) {
        long maxMessageSize =
                ((WrappedMessageHandler) binaryMsgHandler).getMaxMessageSize();
        if (maxMessageSize > -1 && msg.remaining() > maxMessageSize) {
            throw new WsIOException(new CloseReason(CloseCodes.TOO_BIG,
                    sm.getString("wsFrame.messageTooBig",
                            Long.valueOf(msg.remaining()),
                            Long.valueOf(maxMessageSize))));
        }
    }
    try {
        if (binaryMsgHandler instanceof MessageHandler.Partial<?>) {
            ((MessageHandler.Partial<ByteBuffer>) binaryMsgHandler).onMessage(msg, last);
        } else {
            // Caller ensures last == true if this branch is used
            ((MessageHandler.Whole<ByteBuffer>) binaryMsgHandler).onMessage(msg);
        }
    } catch(Throwable t) {
        handleThrowableOnSend(t);
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:25,代碼來源:WsFrameBase.java

示例2: sendMessageText

import javax.websocket.MessageHandler; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void sendMessageText(boolean last) throws WsIOException {
	if (textMsgHandler instanceof WrappedMessageHandler) {
		long maxMessageSize = ((WrappedMessageHandler) textMsgHandler).getMaxMessageSize();
		if (maxMessageSize > -1 && messageBufferText.remaining() > maxMessageSize) {
			throw new WsIOException(new CloseReason(CloseCodes.TOO_BIG, sm.getString("wsFrame.messageTooBig",
					Long.valueOf(messageBufferText.remaining()), Long.valueOf(maxMessageSize))));
		}
	}

	try {
		if (textMsgHandler instanceof MessageHandler.Partial<?>) {
			((MessageHandler.Partial<String>) textMsgHandler).onMessage(messageBufferText.toString(), last);
		} else {
			// Caller ensures last == true if this branch is used
			((MessageHandler.Whole<String>) textMsgHandler).onMessage(messageBufferText.toString());
		}
	} catch (Throwable t) {
		handleThrowableOnSend(t);
	} finally {
		messageBufferText.clear();
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:24,代碼來源:WsFrameBase.java

示例3: sendMessageBinary

import javax.websocket.MessageHandler; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void sendMessageBinary(ByteBuffer msg, boolean last) throws WsIOException {
	if (binaryMsgHandler instanceof WrappedMessageHandler) {
		long maxMessageSize = ((WrappedMessageHandler) binaryMsgHandler).getMaxMessageSize();
		if (maxMessageSize > -1 && msg.remaining() > maxMessageSize) {
			throw new WsIOException(new CloseReason(CloseCodes.TOO_BIG, sm.getString("wsFrame.messageTooBig",
					Long.valueOf(msg.remaining()), Long.valueOf(maxMessageSize))));
		}
	}
	try {
		if (binaryMsgHandler instanceof MessageHandler.Partial<?>) {
			((MessageHandler.Partial<ByteBuffer>) binaryMsgHandler).onMessage(msg, last);
		} else {
			// Caller ensures last == true if this branch is used
			((MessageHandler.Whole<ByteBuffer>) binaryMsgHandler).onMessage(msg);
		}
	} catch (Throwable t) {
		handleThrowableOnSend(t);
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:21,代碼來源:WsFrameBase.java

示例4: sendMessageText

import javax.websocket.MessageHandler; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void sendMessageText(boolean last) throws WsIOException {
    if (textMsgHandler instanceof WrappedMessageHandler) {
        long maxMessageSize =
                ((WrappedMessageHandler) textMsgHandler).getMaxMessageSize();
        if (maxMessageSize > -1 &&
                messageBufferText.remaining() > maxMessageSize) {
            throw new WsIOException(new CloseReason(CloseCodes.TOO_BIG,
                    sm.getString("wsFrame.messageTooBig",
                            Long.valueOf(messageBufferText.remaining()),
                            Long.valueOf(maxMessageSize))));
        }
    }

    try {
        if (textMsgHandler instanceof MessageHandler.Partial<?>) {
            ((MessageHandler.Partial<String>) textMsgHandler).onMessage(
                    messageBufferText.toString(), last);
        } else {
            // Caller ensures last == true if this branch is used
            ((MessageHandler.Whole<String>) textMsgHandler).onMessage(
                    messageBufferText.toString());
        }
    } catch (Throwable t) {
        handleThrowableOnSend(t);
    } finally {
        messageBufferText.clear();
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:30,代碼來源:WsFrameBase.java

示例5: usePartial

import javax.websocket.MessageHandler; //導入方法依賴的package包/類
private boolean usePartial() {
    if (Util.isControl(opCode)) {
        return false;
    } else if (textMessage) {
        return textMsgHandler instanceof MessageHandler.Partial<?>;
    } else {
        // Must be binary
        return binaryMsgHandler instanceof MessageHandler.Partial<?>;
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:11,代碼來源:WsFrameBase.java

示例6: usePartial

import javax.websocket.MessageHandler; //導入方法依賴的package包/類
private boolean usePartial() {
	if (Util.isControl(opCode)) {
		return false;
	} else if (textMessage) {
		return textMsgHandler instanceof MessageHandler.Partial<?>;
	} else {
		// Must be binary
		return binaryMsgHandler instanceof MessageHandler.Partial<?>;
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:11,代碼來源:WsFrameBase.java

示例7: addMessageHandler

import javax.websocket.MessageHandler; //導入方法依賴的package包/類
@Override
public <T> void addMessageHandler(Class<T> clazz, MessageHandler.Partial<T> handler) {
    throw new UnsupportedOperationException("Method is not supported");
}
 
開發者ID:wso2,項目名稱:carbon-transports,代碼行數:5,代碼來源:WebSocketSessionAdapter.java


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