本文整理汇总了Java中javax.websocket.SendResult.isOK方法的典型用法代码示例。如果您正苦于以下问题:Java SendResult.isOK方法的具体用法?Java SendResult.isOK怎么用?Java SendResult.isOK使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.websocket.SendResult
的用法示例。
在下文中一共展示了SendResult.isOK方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onResult
import javax.websocket.SendResult; //导入方法依赖的package包/类
@Override
public void onResult(SendResult result) {
if (!result.isOK()) {
// Message could not be sent. In this case, we don't
// set isSendingMessage to false because we must assume the connection
// broke (and onClose will be called), so we don't try to send
// other messages.
// As a precaution, we close the session (e.g. if a send timeout occured).
// TODO: session.close() blocks, while this handler shouldn't block.
// Ideally, there should be some abort() method that cancels the
// connection immediately...
try {
session.close();
} catch (IOException ex) {
// Ignore
}
}
}
示例2: onResult
import javax.websocket.SendResult; //导入方法依赖的package包/类
@Override
public void onResult(SendResult result) {
if (isDone) {
endpoint.stateMachine.complete(isLast);
handler.onResult(result);
} else if(!result.isOK()) {
handler.onResult(result);
} else if (closed){
SendResult sr = new SendResult(new IOException(
sm.getString("wsRemoteEndpoint.closedDuringMessage")));
handler.onResult(sr);
} else {
write();
}
}
示例3: onResult
import javax.websocket.SendResult; //导入方法依赖的package包/类
@Override
public void onResult(SendResult result) {
if (!result.isOK()) {
// Message could not be sent. In this case, we don't
// set isSendingMessage to false because we must assume the connection
// broke (and onClose will be called), so we don't try to send
// other messages.
// As a precaution, we close the session (e.g. if a send timeout occured).
// TODO: session.close() blocks, while this handler shouldn't block.
// Ideally, there should be some abort() method that cancels the
// connection immediately...
try {
session.close();
} catch (IOException ex) {
// Ignore
}
}
synchronized (messagesToSend) {
if (!messagesToSend.isEmpty()) {
AbstractWebsocketMessage msg = messagesToSend.remove();
messagesToSendLength -= calculateMessageLength(msg);
internalSendMessageAsync(msg);
} else {
isSendingMessage = false;
}
}
}
示例4: onResult
import javax.websocket.SendResult; //导入方法依赖的package包/类
@Override
public void onResult(SendResult result) {
if (isDone) {
endpoint.stateMachine.complete(isLast);
handler.onResult(result);
} else if (!result.isOK()) {
handler.onResult(result);
} else if (closed) {
SendResult sr = new SendResult(new IOException(sm.getString("wsRemoteEndpoint.closedDuringMessage")));
handler.onResult(sr);
} else {
write();
}
}
示例5: onResult
import javax.websocket.SendResult; //导入方法依赖的package包/类
@Override
public void onResult(SendResult arg0) {
// TODO Auto-generated method stub
if (mToken.isUsing())
{
mToken.setCanSend(true);
if (arg0.isOK())
{
mToken.completeSend(mLength);
}
}
}
示例6: send
import javax.websocket.SendResult; //导入方法依赖的package包/类
@Override
public boolean send(Object message,
final boolean shouldClose,
final OnComplete onComplete) throws Exception {
if (!isOpen()) {
return false;
}
SendHandler handler = new SendHandler() {
@Override
public void onResult(SendResult sendResult) {
Throwable ex = sendResult.getException();
if (sendResult.isOK()) {
if (shouldClose) {
try {
close();
} catch (IOException e) {
ex = e;
}
}
}
notifyComplete(onComplete, ex);
}
};
if (message == null) {
handler.onResult(new SendResult());
} else if (message instanceof String) {
this.session.getAsyncRemote().sendText((String)message, handler);
} else if (message instanceof byte[]) {
this.session.getAsyncRemote().sendBinary(ByteBuffer.wrap((byte[])message), handler);
} else {
throw WebsocketUtil.wrongMessageType(message.getClass());
}
return true;
}
示例7: onResult
import javax.websocket.SendResult; //导入方法依赖的package包/类
@Override
public void onResult(SendResult result) {
if (!result.isOK()) {
errorActions.fire(result.getException());
}
}
示例8: onResult
import javax.websocket.SendResult; //导入方法依赖的package包/类
@Override
public void onResult(SendResult result) {
if (!result.isOK()) {
errorActions.fire(result.getException());
}
}