Non puoi selezionare più di 25 argomenti
Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
30 righe
753 B
30 righe
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>
|