3 Star 1 Fork 0

LaChineli/swoole-websocket

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
index.html 1.68 KB
Copy Edit Raw Blame History
LaChineli authored 2018-11-08 10:40 . first commit
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="//cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
</head>
<body>
<input class="input">
<button class="send">send</button>
</body>
<script>
$(function () {
var ws = new WebSocket('ws://192.168.8.120:9902');
// var ws = new WebSocket('ws://192.168.3.250:9902');
ws.onopen = function()
{
console.log('websocket 连接上');
// alert("数据发送中...");
};
ws.onmessage = function (evt)
{
var received_msg = JSON.parse(evt.data) ;
console.log(received_msg);
// alert("数据已接收...");
};
ws.onclose = function()
{
// 关闭 websocket
console.log("连接已关闭...");
};
$('.send').click(function () {
var input = $('.input').val().trim();
if (input==null || input ==''){
alert('输入不能为空');
}
var data = {};
var value = {};
value['uuid'] = '123456';
value['command'] = input;
data['path'] = 'index/screen';
data['params'] = value;
console.log(data);
var mid= JSON.stringify(data);
console.log(mid);
// Web Socket 已连接上,使用 send() 方法发送数据
ws.send(mid);
})
})
</script>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/stargazes/swoole-websocket.git
git@gitee.com:stargazes/swoole-websocket.git
stargazes
swoole-websocket
swoole-websocket
master

Search