python - flask做的网站,怎么实现类似站内信的功能?
PHPz
PHPz 2017-04-17 17:28:47
0
3
478

要实现的功能大概是这样的,注册的用户可以创建一个小组,别的用户可以加入这个小组,遇到的问题是,创建小组的人发布通知的时候,怎么能做到让其他的小组成员不刷新页面的情况下收到有通知的消息,查了一些资料说是可以用flask-socketio来实现,但是我弄了几天了也没弄出来,郁闷,谁能教教我,或是有别的什么方法可以实现的,求帮忙啊。

PHPz
PHPz

学习是最好的投资!

reply all (3)
伊谢尔伦

socketIO
https://github.com/miguelgrinberg/Flask-SocketIO
There are examples inside

    大家讲道理

    The simplest way is to use ajax to continuously access the backend interface to see if there is any news. Hupu seems to be like this. The second method is to use socketio to maintain the connection between the client and the server so that they can communicate at any time. It's not clear how socketio is implemented. It doesn't matter whether you use websocket or Socket, you just need to know that it can maintain the connection. Basically these are the two methods. . .

      洪涛

      If the number of messages is not large, you can consider using long polling. HTTP connections have more resources than web sockets and can maintain more connections.
      But flask’s long polling may need to use threads? Otherwise, an http connection will block the entire web app. Link
      is recommended to use Tornado, which comes with ioloop, official chat room example

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!