当前位置: 首页>>代码示例>>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;未经允许,请勿转载。