• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java MessageInbound类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.catalina.websocket.MessageInbound的典型用法代码示例。如果您正苦于以下问题:Java MessageInbound类的具体用法?Java MessageInbound怎么用?Java MessageInbound使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MessageInbound类属于org.apache.catalina.websocket包,在下文中一共展示了MessageInbound类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: broadcastOne

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
@Override
public void broadcastOne(String user, String message) {
    Multimap<String, MessageInbound> syncMap = Multimaps.synchronizedMultimap(userPagesMap);
    Collection<MessageInbound> mis = syncMap.get(user);
    synchronized (syncMap) {
        if (mis != null) {
            Iterator<MessageInbound> it = mis.iterator();
            while (it.hasNext()) {
                MessageInbound inbound = it.next();
                try {
                    sendToPage(inbound, message);
                } catch (IOException e) {
                    // userPagesMap.remove(user, inbound);
                    logger.info("The WebSocket connection has been closed: " + inbound.toString());
                }

            }
        }
    }
}
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:21,代码来源:WebSocketServiceImpl.java


示例2: sendToAllExcept

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
@Override
public void sendToAllExcept(final List<Command> commands, final Object nonReciver) {
    final byte[] buffer;
    try {
        buffer = serializer.serialize(commands);
    } catch (final SynchronizeFXException e) {
        shutdown();
        callback.onFatalError(e);
        return;
    }
    synchronized (connections) {
        // This ensures that no client is added or removed for the connection list while iterating over it.
        // This ensures also that all clients get messages in the correct order for the case that sendToAllExcept
        // as already called a second time.
        for (final MessageInbound connection : connections) {
            if (connection != nonReciver) {
                send(buffer, connection);
            }
        }
    }
}
 
开发者ID:saxsys,项目名称:SynchronizeFX,代码行数:22,代码来源:SynchronizeFXTomcatChannel.java


示例3: shutdown

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
/**
 * Disconnects all clients and makes the servlet refuse new connections.
 */
@Override
public void shutdown() {
    synchronized (connections) {
        parent.channelCloses(this);
        for (final MessageInbound connection : connections) {
            try {
                connection.getWsOutbound().close(0, null);
            } catch (final IOException e) {
                LOG.error("Connection [" + connection.toString() + "] can't be closed.", e);
            } finally {
                final ExecutorService executorService = connectionThreads.get(connection);
                if (executorService != null) {
                    executorService.shutdown();
                }
                connectionThreads.remove(connection);
            }
        }
        connections.clear();
    }
    callback = null;
}
 
开发者ID:saxsys,项目名称:SynchronizeFX,代码行数:25,代码来源:SynchronizeFXTomcatChannel.java


示例4: createWebSocketInbound

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
@Override
protected StreamInbound createWebSocketInbound(String subProtocol, HttpServletRequest request) {
	try{
		final URI uri = new URI(request.getRequestURI());
		return new MessageInbound() {
			@Override
			protected void onBinaryMessage(ByteBuffer arg0) throws IOException {
			}

			@Override
			protected void onTextMessage(CharBuffer message) throws IOException {
				l.onTextMessage(message);
			}

			@Override
			protected void onOpen(final WsOutbound outbound) {
				l.onOpen(new Connection() {
					@Override
					public URI getRequestUri() {
						return uri;
					}
					@Override
					public void send(CharSequence text) throws IOException {
						outbound.writeTextMessage(CharBuffer.wrap(text));
					}
				});
			}

			@Override
			protected void onClose(int status) {
				l.onClose(status);
			}

			private ConnectionListener l = handler.createConnectionListener();
		};
	} catch(URISyntaxException e){
		throw new RuntimeException(e);
	}
}
 
开发者ID:nict-wisdom,项目名称:rasc,代码行数:40,代码来源:TomcatWebSocketServlet.java


示例5: send

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
/**
 * Sends send the result of {@link Serializer#serialize(List)} to a destination.
 * 
 * @param buffer the bytes to send.
 * @param destination The peer to send to.
 */
private void send(final byte[] buffer, final Object destination) {
    if (LOG.isTraceEnabled()) {
        LOG.trace("Sending from thread: id: " + Thread.currentThread().getName() + ", name: "
                + Thread.currentThread().getName());
    }

    final WsOutbound outbound = ((MessageInbound) destination).getWsOutbound();

    final ExecutorService executorService = connectionThreads.get(destination);
    // execute asynchronously to avoid slower clients from interfering with faster clients
    executorService.execute(new Runnable() {
        @Override
        public void run() {
            try {
                outbound.writeBinaryMessage(ByteBuffer.wrap(buffer));
            } catch (final IOException e) {
                LOG.warn("Sending data to a client failed. Closing connection to this client.");
                try {
                    outbound.close(1002, null);
                    // CHECKSTYLE:OFF
                } catch (final IOException e1) {
                    // Maybe the connection is already closed. This is no exceptional state but rather the
                    // default in
                    // this case. So it's safe to ignore this exception.
                }
                // CHECKSTYLE:ON
                connectionCloses((SynchronizeFXTomcatConnection) destination);
            }
        }
    });
}
 
开发者ID:saxsys,项目名称:SynchronizeFX,代码行数:38,代码来源:SynchronizeFXTomcatChannel.java


示例6: registerClient

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
@Override
public void registerClient(String user, MessageInbound inbound) {
    logger.info("New page registered at" + new Date().toString());
    userPagesMap.put(user, inbound);
    logger.info("Size of " + user + ":" + userPagesMap.get(user).size());
}
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:7,代码来源:WebSocketServiceImpl.java


示例7: unregisterClient

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
@Override
public void unregisterClient(String user, MessageInbound inbound) {
    logger.info("A page unregistered at " + new Date().toString());
    userPagesMap.remove(user, inbound);
    logger.info("Size of " + user + ":" + userPagesMap.get(user).size());
}
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:7,代码来源:WebSocketServiceImpl.java


示例8: sendToPage

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
@Override
public void sendToPage(MessageInbound inbound, String message) throws IOException {
    inbound.getWsOutbound().writeTextMessage(CharBuffer.wrap(message));
    logger.info("message sent to client:" + message);
}
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:6,代码来源:WebSocketServiceImpl.java


示例9: MessageInboundConnection

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
public MessageInboundConnection(MessageInbound messageInbound) {
  this.messageInbound = messageInbound;
  this.isConnected = true;
}
 
开发者ID:phxql,项目名称:gamedev-server,代码行数:5,代码来源:MessageInboundConnection.java


示例10: registerClient

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
/**
* 注册一个用户页面的WebSocket客户端
* @param user 用户对象
* @param inbound
*/
  public void registerClient(String user, MessageInbound inbound);
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:7,代码来源:WebSocketService.java


示例11: unregisterClient

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
/**
 * 注销一个用户页面的WebSocket客户端
 * @param user 用户端想
 * @param inbound
 */
public void unregisterClient(String user, MessageInbound inbound);
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:7,代码来源:WebSocketService.java


示例12: sendToPage

import org.apache.catalina.websocket.MessageInbound; //导入依赖的package包/类
/**
 * 将文本信息发送给某个特定页面
 * @param inbound 页面信息
 * @param message 需要发送的文本信息
 * @throws IOException
 */
public void sendToPage(MessageInbound inbound, String message) throws IOException;
 
开发者ID:sercxtyf,项目名称:onboard,代码行数:8,代码来源:WebSocketService.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java HistoryContext类代码示例发布时间:2022-05-22
下一篇:
Java CodeBase类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap