当前位置: 首页>>代码示例>>Java>>正文


Java SendResult.isOK方法代码示例

本文整理汇总了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
        }
    }
}
 
开发者ID:newskysecurity,项目名称:vswss,代码行数:19,代码来源:SpeedServer.java

示例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();
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:16,代码来源:WsRemoteEndpointImplBase.java

示例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;
        }

    }
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:32,代码来源:Client.java

示例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();
	}
}
 
开发者ID:how2j,项目名称:lazycat,代码行数:15,代码来源:WsRemoteEndpointImplBase.java

示例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);
		}
	}
	
}
 
开发者ID:AlkaidFang,项目名称:PearlHarbor,代码行数:14,代码来源:WebSocketConnectionManager.java

示例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;
}
 
开发者ID:projectodd,项目名称:wunderboss,代码行数:39,代码来源:JavaxWebsocketChannel.java

示例7: onResult

import javax.websocket.SendResult; //导入方法依赖的package包/类
@Override
public void onResult(SendResult result) {
  if (!result.isOK()) {
    errorActions.fire(result.getException());
  }
}
 
开发者ID:cettia,项目名称:asity,代码行数:7,代码来源:JwaServerWebSocket.java

示例8: onResult

import javax.websocket.SendResult; //导入方法依赖的package包/类
@Override
public void onResult(SendResult result) {
    if (!result.isOK()) {
        errorActions.fire(result.getException());
    }
}
 
开发者ID:vibe-project,项目名称:vibe-java-platform,代码行数:7,代码来源:JwaServerWebSocket.java


注:本文中的javax.websocket.SendResult.isOK方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。