<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<head>
<title>消息推送模式与内容测试</title>
<meta charset="UTF-8">
<link href="style.css" rel="stylesheet">
<meta http-equiv="Pragma" content="no-cache">
<script type="text/javascript" src="<%=basePath %>js/pushlet_js/js-pushlet-client.js"></script>
<script type="text/javascript">
var tempTrureId = '';
var stockId = '';
function onEvent(event){
document.getElementById("info").innerHTML=event.toString();
if(event.get('p_subject')=='/temperature'){
tempTrureId = event.get("p_sid");
displayTemptrueData(event.toString());
}else if(event.get('p_subject')=='/stocks/aex'){
stockId = event.get("p_sid");
displayStocksData(event.toString());
}
}
function displayTemptrueData(aString) {
document.getElementById("displayTemptrue").value=aString;
}
function displayStocksData(aString) {
document.getElementById("displayStocks").value=aString;
}
function listemTemptrue(){
p_join_listen(null, 'pull');
p_subscribe("/temperature","my-lable");
}
function unsubscribeTemptrue(){
p_unsubscribe(tempTrureId);
displayTemptrueData('');
}
function listemStock(){
p_join_listen(null, 'pull');
p_subscribe("/stocks/aex","my-lable2");
}
function unsubscribeStock(){
p_unsubscribe(stockId);
displayStocksData("");
}
function leave(){
p_unsubscribe();
p_leave();
}
</script>
</head>
<body>
<script type="text/javascript">p_embed();//此段必须要</script>
<br></body>
<article>
<header>
<h1>pushlet例子</h1>
</header>
</article>
<article>
<form>
事件显示:<textarea rows="10" cols="30" id=displayTemptrue></textarea>
天气显示:<textarea rows="10" cols="30" id=displayStocks></textarea>
<input type="button" value="监听天气" οnclick="listemTemptrue();"/>
<input type="button" value="取消监听天气" οnclick="unsubscribeTemptrue();"/>
<input type="button" value="监听股票" οnclick="listemStock();"/>
<input type="button" value="取消监听股票" οnclick="unsubscribeStock()"/>
<input type="button" value="离开" οnclick="leave()"/>
<div id=info style="width:400px;height:200px;border:1px solid"></div>
</form>
</article>
</html>
<!DOCTYPE html>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<head>
<title>消息推送模式与内容测试</title>
<meta charset="UTF-8">
<link href="style.css" rel="stylesheet">
<meta http-equiv="Pragma" content="no-cache">
<script type="text/javascript" src="<%=basePath %>js/pushlet_js/js-pushlet-client.js"></script>
<script type="text/javascript">
var tempTrureId = '';
var stockId = '';
function onEvent(event){
document.getElementById("info").innerHTML=event.toString();
if(event.get('p_subject')=='/temperature'){
tempTrureId = event.get("p_sid");
displayTemptrueData(event.toString());
}else if(event.get('p_subject')=='/stocks/aex'){
stockId = event.get("p_sid");
displayStocksData(event.toString());
}
}
function displayTemptrueData(aString) {
document.getElementById("displayTemptrue").value=aString;
}
function displayStocksData(aString) {
document.getElementById("displayStocks").value=aString;
}
function listemTemptrue(){
p_join_listen(null, 'pull');
p_subscribe("/temperature","my-lable");
}
function unsubscribeTemptrue(){
p_unsubscribe(tempTrureId);
displayTemptrueData('');
}
function listemStock(){
p_join_listen(null, 'pull');
p_subscribe("/stocks/aex","my-lable2");
}
function unsubscribeStock(){
p_unsubscribe(stockId);
displayStocksData("");
}
function leave(){
p_unsubscribe();
p_leave();
}
</script>
</head>
<body>
<script type="text/javascript">p_embed();//此段必须要</script>
<br></body>
<article>
<header>
<h1>pushlet例子</h1>
</header>
</article>
<article>
<form>
事件显示:<textarea rows="10" cols="30" id=displayTemptrue></textarea>
天气显示:<textarea rows="10" cols="30" id=displayStocks></textarea>
<input type="button" value="监听天气" οnclick="listemTemptrue();"/>
<input type="button" value="取消监听天气" οnclick="unsubscribeTemptrue();"/>
<input type="button" value="监听股票" οnclick="listemStock();"/>
<input type="button" value="取消监听股票" οnclick="unsubscribeStock()"/>
<input type="button" value="离开" οnclick="leave()"/>
<div id=info style="width:400px;height:200px;border:1px solid"></div>
</form>
</article>
</html>