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


Java WsOutbound.flush方法代码示例

本文整理汇总了Java中org.apache.catalina.websocket.WsOutbound.flush方法的典型用法代码示例。如果您正苦于以下问题:Java WsOutbound.flush方法的具体用法?Java WsOutbound.flush怎么用?Java WsOutbound.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.catalina.websocket.WsOutbound的用法示例。


在下文中一共展示了WsOutbound.flush方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onOpen

import org.apache.catalina.websocket.WsOutbound; //导入方法依赖的package包/类
@Override
protected void onOpen(WsOutbound outbound) {
	if(uid == -1){		//过期用户直接下线
		Map<String, Object> outMap = new HashMap<String, Object>();
		outMap.put("response", "notlogin");
          	String jsonString = JSONObject.fromObject(outMap).toString();
  			CharBuffer buffer = CharBuffer.wrap(jsonString);
  			try {
  				outbound.writeTextMessage(buffer);
  				outbound.flush();
  			} catch (IOException e) {
  				e.printStackTrace();
  			}
	}else{
		userMap.put(uid, outbound);
		System.out.println("[上线]==>uid:"+uid+"在线用户==>"+userMap.size());
		sendUnread(outbound);		//登录即检查有没有未读消息
	}
	super.onOpen(outbound);
}
 
开发者ID:HsingPeng,项目名称:ALLGO,代码行数:21,代码来源:PushServlet.java

示例2: sendUnread

import org.apache.catalina.websocket.WsOutbound; //导入方法依赖的package包/类
private void sendUnread(WsOutbound outbound){
	Map<String, Object> outMap = new HashMap<String, Object>();
	outMap.put("response", "remind_unread");
	UnreadDAO dao = new UnreadDAOimpl();
	List<UnreadVo> list = dao.getUnread(uid);
	if(list != null){
		outMap.put("remind_unread", list);
		String jsonString = JSONObject.fromObject(outMap).toString();
		CharBuffer buffer = CharBuffer.wrap(jsonString);
		try {
			outbound.writeTextMessage(buffer);
			outbound.flush();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:HsingPeng,项目名称:ALLGO,代码行数:18,代码来源:PushServlet.java

示例3: sendUnread

import org.apache.catalina.websocket.WsOutbound; //导入方法依赖的package包/类
private void sendUnread(UnreadVo unread, WsOutbound outbound) {
	Map<String, Object> outMap = new HashMap<String, Object>();
	outMap.put("response", "remind_unread");
	List<UnreadVo> list = new ArrayList<UnreadVo>();
	list.add(unread);
	outMap.put("remind_unread", list);
	String jsonString = JSONObject.fromObject(outMap).toString();
	CharBuffer buffer = CharBuffer.wrap(jsonString);
	try {
		outbound.writeTextMessage(buffer);
		outbound.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
	
}
 
开发者ID:HsingPeng,项目名称:ALLGO,代码行数:17,代码来源:ActionListener.java

示例4: onBinaryData

import org.apache.catalina.websocket.WsOutbound; //导入方法依赖的package包/类
@Override
protected void onBinaryData(InputStream is) throws IOException {
    // Simply echo the data to back to the client.
    WsOutbound outbound = getWsOutbound();

    int i = is.read();
    while (i != -1) {
        outbound.writeBinaryData(i);
        i = is.read();
    }

    outbound.flush();
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:14,代码来源:EchoStream.java

示例5: onTextData

import org.apache.catalina.websocket.WsOutbound; //导入方法依赖的package包/类
@Override
protected void onTextData(Reader r) throws IOException {
    // Simply echo the data to back to the client.
    WsOutbound outbound = getWsOutbound();

    int c = r.read();
    while (c != -1) {
        outbound.writeTextData((char) c);
        c = r.read();
    }

    outbound.flush();
}
 
开发者ID:sunmingshuai,项目名称:apache-tomcat-7.0.73-with-comment,代码行数:14,代码来源:EchoStream.java


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