本文整理汇总了Java中org.eclipse.jetty.websocket.WebSocket.Connection.close方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.close方法的具体用法?Java Connection.close怎么用?Java Connection.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jetty.websocket.WebSocket.Connection
的用法示例。
在下文中一共展示了Connection.close方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.jetty.websocket.WebSocket.Connection; //导入方法依赖的package包/类
@Override
public void execute(String rawArgs, CallbackContext ctx) {
try {
JSONArray args = new JSONArray(rawArgs);
int id = Integer.parseInt(args.getString(0), 16);
int code = args.getInt(1);
String reason = args.getString(2);
Connection conn = _map.get(id);
if (conn != null) {
if (code > 0) {
conn.close(code, reason);
} else {
conn.close();
}
}
} catch (Exception e) {
if (!ctx.isFinished()) {
PluginResult result = new PluginResult(Status.ERROR);
result.setKeepCallback(true);
ctx.sendPluginResult(result);
}
}
}
示例2: execute
import org.eclipse.jetty.websocket.WebSocket.Connection; //导入方法依赖的package包/类
@Override
public void execute(JSONArray args, CallbackContext ctx) {
try {
int id = args.getInt(0);
int code = args.getInt(1);
String reason = args.getString(2);
Connection conn = _map.get(id);
if (conn != null) {
if (code > 0) {
conn.close(code, reason);
} else {
conn.close();
}
}
} catch (Exception e) {
ctx.error("close");
}
}
示例3: closeConnection
import org.eclipse.jetty.websocket.WebSocket.Connection; //导入方法依赖的package包/类
/**
* Sends the given status on the given WebSocket connection and closes the
* connection.
*
* @param connection The WebSocket connection to close.
* @param guac_status The status to send.
*/
public static void closeConnection(Connection connection,
GuacamoleStatus guac_status) {
connection.close(guac_status.getWebSocketCode(),
Integer.toString(guac_status.getGuacamoleStatusCode()));
}