GithubHelp home page GithubHelp logo

chalker / qmlwebsockets_threaded Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qt/qtwebsockets

1.0 3.0 1.0 1.7 MB

QML WebSockets — threaded workaround for QTBUG-63719

Home Page: https://bugreports.qt.io/browse/QTBUG-63719

License: GNU General Public License v2.0

QMake 2.11% C++ 91.64% QML 6.25%

qmlwebsockets_threaded's Introduction

A threaded wrapper for QML WebSocket interface

The problem

This aims to be a work-around for QTBUG-63719, without this QML WebSocket API blocks main event loop and user interface while receiving messages over network — that is after the server started to send the message and before the message was fully received, the UI is frozen.

That is visible on Wi-Fi networks, under heavy WebSocket usage, and especially on 4G/mobile networks.

That issue could be observed in all current Qt versions at the date, including 5.9.2 and 5.10.0-beta.

See the test-original.qml file to see the problem, and test-threaded to see this workaround in action.

The solution

This repo provides a WebSocketThreaded import, which could be used as a drop-in replacement for WebSocket, but it has some drawbacks.

This work-around works by encapsulating QWebSocket inside a QThread and passing data as events — see QWebSocketThreaded file for that.

That class could also potentially be used from C++ code, but it is not exported and does not replicate full QWebSocket API — only the subset that was needed for QML WebSocket.

The drawbacks

  • Starts a separate thread for each WebSocket instance
  • QML WebSocketServer is not implemented
  • sendTextMessage and sendBinaryMessage return -1 instead of the transferred size, but that shouldn't break anything as those are documented to return void (which is not actually true, btw).
  • errorString is empty in most cases (FIXME)

Copyright

This code is based on the original Qt WebSockets code and is licensed accordingly (LGPL3/GPL2+).

qmlwebsockets_threaded's People

Contributors

aalpert-bluescape avatar alexeylysenko avatar basyskom-meerkoetter avatar carewolf avatar chalker avatar ediosyncratic avatar gladhorn avatar iamsergio avatar jaheikk avatar jakepetroules avatar jeromepasion avatar jksh avatar jsfdez avatar kkoehne avatar kurtpattyn avatar laknoll avatar liangqi avatar lpapp avatar lultimouomo avatar marc-kdab avatar milianw avatar misery avatar mitya57 avatar morten242 avatar nsuke avatar ossilator avatar stevenceuppens avatar syntheticpp avatar thiagomacieira avatar toreinio avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.