swoole学习之websocket客户端代码
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>swoole学习之websocket_server服务器代码_徊忆羽菲的博客-CSDN博客</title>
</head>
<body>
<h1>websocket服务器基础类task异步任务测试</h1>
<script type="application/javascript">
var wsUrl = 'ws://20.20.24.131:9502';
var ws_server = new WebSocket(wsUrl);
ws_server.onopen = function (evt) {
ws_server.send('hello websocket!');
console.log('connect-swoole-websocket-success');
}
ws_server.onmessage = function (evt) {
console.log('connect-swoole-websocket-message', evt.data);
}
ws_server.onclose = function (evt) {
console.log('connect-swoole-websocket-close');
}
ws_server.onerror = function (evt, e) {
console.log('connect-swoole-websocket-error', e.errorCode);
}
</script>
</body>
</html>