yusijie
2023-02-02 04ee1e66aa1e13d786bc6b89e866b659f235d8f1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>signalr</title>
    <script src="https://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
    <script src="https://cdn.bootcss.com/signalr.js/2.4.0-preview1-20180920-03/jquery.signalR.min.js"></script>
    <script src="./signalr/hubs"></script>
    <script>
        $(function () {
            $.connection.hub.url = "./signalr";
            var hub=$.connection.RepairHub;
            //此处的showMessage就是api端hub里定义的showMessage方法
            hub.client.showMessage = function (msg) {
                console.log(msg)
            }
            //日志输出
            $.connection.hub.logging= true;
            $.connection.hub.start();
        });
    </script>
</head>
 
<body>
    <div>signalr</div>
</body>
 
</html>