当前位置: 首页 > 工具软件 > 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>
    <!--<script src="sc_demo.js"></script>-->
    <script>
        $(function () {
            test();
        });
        var socket = socketCluster.connect( {
            port: 8088,
            hostname: "127.0.0.1",
            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("zdr-m32");
                console.log(data);
            });
            var sub2 = socket.subscribe('zdr-domain');
            sub2.watch(function (data) {
                console.log("zdr-domain");
                console.log(data);
            });
        }

    </script>
</head>

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

</html>

 

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

 类似资料: