pushlet(QQ提示框)
Pushlet 实现服务端往客服端推送消息
系统页面弹出消息框,类似QQ提示框
1. java代码
package com.test.jbpm.common; import java.io.Serializable;
import java.util.List;
import com.test.jbpm.web.action.BaseAction;
import nl.justobjects.pushlet.core.Dispatcher;
import nl.justobjects.pushlet.core.Event;
import nl.justobjects.pushlet.core.Session;
import nl.justobjects.pushlet.core.SessionManager;
public class NoticePushlet extends BaseAction implements Serializable{ // 指定用户id
public void myUnicast(String user,String message) {
//必须注册ID PL.userid="hao";
if (SessionManager.getInstance().hasSession(user)) {
SessionManager.getInstance().getSessions();
Event event = Event.createDataEvent("/flowctrl/main");
event.setField("noticeKey", message);//内容不能使用中文
Dispatcher.getInstance().unicast(event, user);
} else {
//Event event = Event.createDataEvent("/jbpm_first/hao");
//event.setField("noticeKey", "The user:("+user+") not live!");
//Dispatcher.getInstance().unicast(event, this.getSession().getAttribute("code").toString());
//sDispatcher.getInstance().broadcast(event);
// Session[] sessions = SessionManager.getInstance().getSessions();
// for (Session session : sessions) {
// }
}
}
public void pushletInterface(List<String> prplflNoticeList) { Session[] sessions = SessionManager.getInstance().getSessions();
if (sessions != null && sessions.length > 0) {
for (Session session : sessions) {
String sessionId = session.getId();
String comcode = sessionId.split("->")[0];
int listLength = 0;
// for (PrplflNotice pn : prplflNoticeList) {
// if (comcode.equals(pn.getComcode())) {
// listLength = listLength + 1;
// }
// } if (listLength > 0) {
String msg = "��" + comcode + "���� " + listLength + " ��4S���뼰ʱ���������Ϣ";
Event event = Event.createDataEvent("/flowctrl/main");
event.setField("noticeKey", msg);
Dispatcher.getInstance().unicast(event, sessionId);
}
}
}
} public void myBroadcast() {
Event event = Event.createDataEvent("/flowctrl/main"); �
event.setField("noticeKey", "Broadcast msg");
Dispatcher.getInstance().broadcast(event);
}
}
<script type="text/javascript">
// 消息提醒用js,注册监听
var usercode = '<%=session.getAttribute("code")%>';
var timestamp=new Date().getTime();
PL.userid=usercode;
//PL.userid=usercode+"->"+timestamp;
PL.webRoot="${pageContext.request.contextPath}/";
PL._init();
PL.joinListen('/flowctrl/main');
function onData(event) {
var info=event.get("noticeKey");
openDia(info);
} function openDia(info) {
document.getElementById('messageInfo').innerHTML = info +'<BR><BR><a href="javascript:void(0);" onclick="deal()" target="page">点击处理(未处理完毕仍可点击以继续)</a>';
showDiv();
}
//消息提示使用
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,i = 0;
function showDiv(){
try{
divTop = parseInt(document.getElementById("dialog").style.top,10);
divLeft = parseInt(document.getElementById("dialog").style.left,10);
divHeight = parseInt(document.getElementById("dialog").offsetHeight,10);
divWidth = parseInt(document.getElementById("dialog").offsetWidth,10);
docWidth = document.body.clientWidth;
docHeight = document.body.clientHeight;
document.getElementById("dialog").style.top = parseInt(document.body.scrollTop,10) + docHeight - divHeight;
document.getElementById("dialog").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth;
document.getElementById("dialog").style.visibility="visible";
}
catch(e){}
}
function closeDiv()
{
document.getElementById('dialog').style.visibility='hidden';
}
</script>
pushlet(QQ提示框)的更多相关文章
- qt之透明提示框(模拟qq) (非常漂亮)
Qt实现类似QQ的登录失败的提示框,主要涉及窗口透明并添加关闭按钮,以及图标和信息的显示等. 直接上代码: #include "error_widget.h" ErrorWidge ...
- wpf实现仿qq消息提示框
原文:wpf实现仿qq消息提示框 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/huangli321456/article/details/5052 ...
- android标题栏上面弹出提示框(二) PopupWindow实现,带动画效果
需求:上次用TextView写了一个从标题栏下面弹出的提示框.android标题栏下面弹出提示框(一) TextView实现,带动画效果, 总在找事情做的产品经理又提出了奇葩的需求.之前在通知栏显示 ...
- android标题栏下面弹出提示框(一) TextView实现,带动画效果
产品经理用的是ios手机,于是android就走上了模仿的道路.做这个东西也走了一些弯路,写一篇博客放在这里,以后自己也可用参考,也方便别人学习. 弯路: 1.刚开始本来用PopupWindow去实现 ...
- html+css创建提示框
看到下面的效果了吗? 本来我们站点是用下面的图片做的背景, 但是后期当更改完框中的提示内容,并且更新内容较多的时候,发现内容溢出了,如下图: 但是背景图片不能自动拉伸,还得重新做一张背景图,这样就导致 ...
- 【转】IOS学习笔记29—提示框第三方库之MBProgressHUD
原文网址:http://blog.csdn.net/ryantang03/article/details/7877120 MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单 ...
- 利用 css 制作简单的提示框
在网页开发中,为了提高用户体验,经常会用到一些提示框来引导用户,这里分享下一些简单的提示框的制作 1.首先类似一个长方形右上角一个关闭按钮 这里用到的主要是一些定位的知识,运用relative和abs ...
- 关于.NET前后台提示框的那点事
前言 关于提示框,或多或少都用到过,提示框常见方式两种:js原生alert() 和 div模拟弹层:下面以一个常见的需求业务场景来展现提示框的那点事: 正文内容 客户:需求方: 小白:实现方(全权负责 ...
- Qt之等待提示框三(QLabel进行多图片切换)
之前分享过的等待提示框有用QMovie播放gif图片实现的,也有纯代码实现的,今天再次分享另一种实现方式,如题目所示:QLabel进行图片的切换! 进行用户登录的时候,往往都需要后台线程进行用 ...
随机推荐
- Windows无法启动MySQL服务,错误1067
问题:mysql服务启动异常 找出原因 检查D:\mysql-5.6.20-winx64\data目录下client-02.err文件的错误信息(以err为后缀名的文件是mysql的日志文件) 修改配 ...
- 关于meta标签中的http-equiv属性使用介绍
关于meta标签中的http-equiv属性使用介绍 meta是html语言head区的一个辅助性标签.也许你认为这些代码可有可无.其实如果你能够用好meta标签,会给你带来意想不到的效果,meta标 ...
- centos-7.2 node.js免编译安装
cd /usr/local/ wget https://npm.taobao.org/mirrors/node/v8.9.3/node-v8.9.3-linux-x64.tar.gz tar -zxv ...
- asp: AJAX Database
<% @LANGUAGE="VBSCRIPT" CODEPAGE="65001" %> <!DOCTYPE html PUBLIC " ...
- 【数据库】5.0 MySQL入门学习(五)——MySQL源码了解及MySQL初始化设置
1.0 MySQL源码目录主要包括:客户端代码.服务端代码.测试工具.其他库文件.当然,看懂源代码得有一定的C语言基础. BUILD:各种平台的编译脚本,可以用来制作各平台的二进制版本 client: ...
- js数组的sort排序的原理和应用
1.js sort()方法的应用: 首先:如果调用该方法时没有使用参数,将按字母顺序对数组中的元素进行排序,说得更精确点,是按照字符编码的顺序进行排序.要实现这一点,首先应把数组的元素都转换成字符串( ...
- Android 使用RecyclerView优雅实现悬浮标题通讯录
项目地址:https://github.com/hgDendi/ContactsList 界面概览: ContactsListDemo ContactsListDemo2 概要 如图,主要简单划分为两 ...
- supervisor运行virtualenv环境下的nagios-api
supervisord-example.conf [unix_http_server] file=/tmp/supervisor.sock ; path to your socket file [su ...
- spring boot拦截器配置
1.在spring boot配置文件application.properties中添加要拦截的链接 com.url.interceptor=/user/test 2.编写拦截器代码 ,创建UrlInt ...
- HDU-3092 Least common multiple---数论+分组背包
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=3092 题目大意: 有一个数字n,现在要把它分解成几个数字相加!然后这几个数字有最小公倍数,题目目的是 ...