简体   繁体   中英

Primus-websocket client side

Im trying to make a client side for websocket using Primus framework.

here my client side code

    <script src="primus/primus.js"></script>
<script>
    // connect to current URL
    var primus = Primus.connect()

    primus.on("open", function () {
        console.log("Connected!")
    })

    primus.on("data", function (data) {
        console.log("data =", data)
    })
</script>

the error is that Primus.connect is not a function

Thank you.

您需要指定一个连接。

var primus = Primus.connect('ws://localhost:8000');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM