/**
* Try sending the {@link RoutedMessage} using
* {@link Session#getBasicRemote()}, {@link Basic#sendObject(Object)}.
*
* @param session
* Session to send the message on
* @param message
* {@link RoutedMessage} to send
* @return true if send was successful, or false if it failed
*/
public static boolean sendMessage(Session session, RoutedMessage message) {
if (session.isOpen()) {
try {
session.getBasicRemote().sendObject(message);
return true;
} catch (EncodeException e) {
Log.log(Level.FINEST, session, "Unexpected condition writing message", e);
// Something was wrong encoding this message, but the connection
// is likely just fine.
} catch (IOException ioe) {
// An IOException, on the other hand, suggests the connection is
// in a bad state.
Log.log(Level.FINEST, session, "Unexpected condition writing message", ioe);
tryToClose(session, new CloseReason(CloseCodes.UNEXPECTED_CONDITION, trimReason(ioe.toString())));
}
}
return false;
}
WSUtils.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:gameon-mediator
作者:
评论列表
文章目录