本文整理汇总了Java中io.undertow.websockets.core.WebSocketChannel.resumeReceives方法的典型用法代码示例。如果您正苦于以下问题:Java WebSocketChannel.resumeReceives方法的具体用法?Java WebSocketChannel.resumeReceives怎么用?Java WebSocketChannel.resumeReceives使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.undertow.websockets.core.WebSocketChannel
的用法示例。
在下文中一共展示了WebSocketChannel.resumeReceives方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onConnect
import io.undertow.websockets.core.WebSocketChannel; //导入方法依赖的package包/类
@Override
public void onConnect(WebSocketHttpExchange exchange, WebSocketChannel channel) {
if (this.hasAuthentication) {
String header = null;
if (exchange.getRequestHeader(Header.COOKIE.toString()) != null) {
header = exchange.getRequestHeader(Header.COOKIE.toString());
}
if (this.requestHelper.hasValidAuthentication(header)) {
channel.getReceiveSetter().set((ChannelListener<? super WebSocketChannel>) Application.getInstance(this.controllerClass));
channel.resumeReceives();
channel.addCloseTask(Application.getInstance(WebSocketCloseListener.class));
Application.getInstance(WebSocketService.class).addChannel(channel);
} else {
IOUtils.closeQuietly(channel);
}
} else {
channel.getReceiveSetter().set((ChannelListener<? super WebSocketChannel>) Application.getInstance(this.controllerClass));
channel.resumeReceives();
channel.addCloseTask(Application.getInstance(WebSocketCloseListener.class));
Application.getInstance(WebSocketService.class).addChannel(channel);
}
}
示例2: run
import io.undertow.websockets.core.WebSocketChannel; //导入方法依赖的package包/类
void run() throws Exception {
CountDownLatch closelatch = new CountDownLatch(2);
server(app.websocket("/ws").onClose(
(c, buf) -> closelatch.countDown()));
stopper = app.listen(port);
CountDownLatch latch = new CountDownLatch(1);
WebSocketChannel channel = WebSocketClient
.connectionBuilder(
worker,
buffer,
new URI(String.format("http://localhost:%d/ws",
port))).connect().get();
channel.addCloseTask(c -> closelatch.countDown());
channel.getReceiveSetter().set(listener(latch));
channel.resumeReceives();
try {
assertion(channel, latch);
} finally {
if (channel.isOpen()) {
channel.sendClose();
closelatch.await(1, TimeUnit.SECONDS);
}
}
}
示例3: onConnect
import io.undertow.websockets.core.WebSocketChannel; //导入方法依赖的package包/类
@Override
public void onConnect(final WebSocketHttpExchange exchange, final WebSocketChannel channel) {
channel.getReceiveSetter().set(new UaiWebSocketListener());
UaiWebSocketContext.addClient(channel);
channel.resumeReceives();
}
示例4: WebSocketTtyConnection
import io.undertow.websockets.core.WebSocketChannel; //导入方法依赖的package包/类
public WebSocketTtyConnection(WebSocketChannel webSocketChannel, ScheduledExecutorService executor) {
this.webSocketChannel = webSocketChannel;
this.executor = executor;
registerWebSocketChannelListener(webSocketChannel);
webSocketChannel.resumeReceives();
}
示例5: WebSocketTtyConnection
import io.undertow.websockets.core.WebSocketChannel; //导入方法依赖的package包/类
public WebSocketTtyConnection(WebSocketChannel webSocketChannel, ScheduledExecutorService executor) {
this.webSocketChannel = webSocketChannel;
this.executor = executor;
registerWebSocketChannelListener(webSocketChannel);
webSocketChannel.resumeReceives();
}
示例6: onConnect
import io.undertow.websockets.core.WebSocketChannel; //导入方法依赖的package包/类
@Override
public void onConnect(WebSocketHttpExchange exchange, WebSocketChannel channel) {
LOGGER.info("Connecting: " + this + " to " + channel);
WebSocketSession wss = new WebSocketSession(channel, ev3ActionProcessor);
sessions.add(wss);
if (sessions.size() > 5) {
// Potential issue on CPU and bandwidth (seems limited to 128Kb/s with Wifi)
LOGGER.warning("Important number (" + sessions.size() + ") of session opened at the same time: Potential performance issues");
}
channel.resumeReceives(); // /!\ channel don't receive nothing if not called
}
示例7: onConnect
import io.undertow.websockets.core.WebSocketChannel; //导入方法依赖的package包/类
@Override
public void onConnect(WebSocketHttpExchange exchange, WebSocketChannel channel) {
channel.getReceiveSetter().set(this);
channel.resumeReceives();
connection = new UndertowWebSocketConnection(exchange, channel);
connections.add(connection);
context = new WebSocketContext(connections, connection, pathParameters);
handler.onOpen(context);
}