You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
753 B
30 lines
753 B
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Title</title>
|
|
</head>
|
|
<body>
|
|
<button onclick="sendHandler('zhangsan')">给zhangsan发送消息</button>
|
|
<button onclick="sendHandler('lisi')">给lisi发送消息</button>
|
|
<script>
|
|
var ws = new WebSocket("ws://192.168.0.70:8999/ws/imserver/wangwu")
|
|
ws.open = function (msg){
|
|
console.log("open:"+msg)
|
|
}
|
|
|
|
ws.onmessage = function (msg){
|
|
console.log("message:"+msg)
|
|
}
|
|
|
|
function sendHandler(userid){
|
|
var param = {}
|
|
param.sendUserId = 'wangwu'
|
|
param.receiveUserId = userid
|
|
param.message = '来自 wangwu 消息'
|
|
param.msgType = 1
|
|
ws.send(JSON.stringify(param))
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|