first commit
This commit is contained in:
41
socketEnd/index.html
Normal file
41
socketEnd/index.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>websocket</title>
|
||||
</head>
|
||||
<body>
|
||||
<button>点我唤醒手机</button>
|
||||
|
||||
</body>
|
||||
<script type="text/javascript">
|
||||
// 浏览器提供 WebSocket 对象
|
||||
var ws = new WebSocket("ws://120.27.144.174:8080/html");
|
||||
|
||||
// 发送
|
||||
ws.onopen = function () {
|
||||
console.log("Connection open ...");
|
||||
};
|
||||
|
||||
ws.onmessage = function (evt) {
|
||||
console.log("Received Message: " + evt.data);
|
||||
};
|
||||
|
||||
document.querySelector("button").onclick = function () {
|
||||
ws.send(
|
||||
JSON.stringify({
|
||||
type: 1,
|
||||
data: {
|
||||
|
||||
// 大地中学 东北门
|
||||
// Longitude: 117.325131,
|
||||
// Latitude: 31.793141,
|
||||
|
||||
// 信旺华府俊苑14栋
|
||||
// Longitude: 117.237326,
|
||||
// Latitude: 31.830978,
|
||||
},
|
||||
})
|
||||
);
|
||||
};
|
||||
</script>
|
||||
</html>
|
||||
Reference in New Issue
Block a user