[rabbitmq-discuss] Help for RabbitMQ-Web-Stomp
truelie
youpingl at sina.com
Tue Jun 12 03:00:04 BST 2012
Hi,
I am testing for RabbitMQ-Web-Stomp,which send or receive message from browser.
I have installed RabbitMQ-Web-Stomp plugin,and can echo message from http://127.0.0.1:55670 successfully.
Now, I write a send.html to send message,and a recv.html to receive message,but not success.
Can anyone help me?
1、Send.html:
<!DOCTYPE html>
<html>
<head>
<script src="sockjs-0.3.min.js"></script>
<script src="stomp.js"></script>
<title>Send Message</title>
</head>
<body lang="en">
<h1>Send Message</h1>
<script>
// Stomp.js boilerplate
WebSocketStompMock = SockJS;
var client = Stomp.client('http://127.0.0.1:55674/stomp');
client.connect("guest","guest",function(x){
alert(x);
});
function send()
{
client.send('/topic/test', {}, document.form1.msg.val);
}
</script>
<form id="form1" method="post" name="form1" action=""">
请输入信息:<input id="msg" name="msg" type="text"/>
<input name="Submit" type="submit" onclick="send();" value="发送">
</form>
</body>
</html>
2、recv.html
<!DOCTYPE html>
<html>
<head>
<script src="sockjs-0.3.min.js"></script>
<script src="stomp.js"></script>
<title>Recv Message</title>
</head>
<body>
<h1>Recv Message</h1>
<script>
// Stomp.js boilerplate
WebSocketStompMock = SockJS;
var client = Stomp.client('http://127.0.0.1:55674/stomp');
client.connect("guest","guest",function(x){
id = client.subscribe("/topic/test", function(d) {
document.write(d.body);
});
});
</script>
</body>
</html>
truelie
2012-06-12
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120612/133ea3e2/attachment.htm>
More information about the rabbitmq-discuss
mailing list