当前位置: 首页 > 工具软件 > SocketCluster > 使用案例 >

socketcluster 客户端请求

景育
2023-12-01
<html>
<head>
    <title>test</title>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/socketcluster-client/7.0.1/socketcluster.min.js"></script>
    
        $(function () {
            test();
        });
        var socket = socketCluster.connect( {
            port: 端口,
            hostname: "服务器地址(193.168.18.xxxx)",
            path: '/feed/78FF0A0F-34CF-4AA2-9DC2-BD308D3657D2',
           
            secure: false
        });
        function test(){
            console.log('connected');

            var sub = socket.subscribe('zdr-m32');
            sub.watch(function (data) {
                console.log(data);
            });
            var sub2 = socket.subscribe('zdr-domain');
            sub2.watch(function (data) {
                console.log(data);
            });
        }

    </script>
</head>

<body>
<button type="button" οnclick="test()">点击这里</button>
</body>

</html>

  

转载于:https://www.cnblogs.com/guozhe/p/7716942.html

 类似资料: