├── utils ├── ca │ ├── ca.srl │ ├── README.md │ ├── client-key.pem │ ├── server-key.pem │ ├── ca.key │ ├── client.csr │ ├── server.csr │ ├── client-crt.pem │ ├── server-crt.pem │ └── ca.pem └── QtWebsocket_qtcreator_codestyle.xml ├── AutobahnTestSuite ├── .gitignore ├── autobahntest.sh ├── autobahntest.sh.txt ├── main.cpp ├── fuzzingclient.json ├── fuzzingclient.json.txt ├── README.md ├── TestServer.h ├── AutobahnTestSuite.pro ├── TestServer.cpp ├── AutobahnTestSuite.vcxproj.filters └── AutobahnTestSuite.vcxproj ├── Example ├── Server │ ├── Server.cpp │ ├── Server.pro │ ├── main.cpp │ ├── Server.h │ ├── Server.vcxproj.filters │ └── Server.vcxproj ├── Client │ ├── main.cpp │ ├── Client.pro │ ├── Client.h │ ├── Client.ui │ ├── Client.vcxproj.filters │ ├── Client.cpp │ └── Client.vcxproj ├── ServerThreaded │ ├── ServerThreaded.pro │ ├── main.cpp │ ├── ServerThreaded.h │ ├── SocketThread.h │ ├── ServerThreaded.cpp │ ├── SocketThread.cpp │ ├── ServerThreaded.vcxproj.filters │ └── ServerThreaded.vcxproj └── ClientJS │ └── clientExample.html ├── QtWebsocket.pro ├── QtWebsocket ├── QtWebsocket.pro ├── functions.h ├── QTlsServer.h ├── QWsFrame.h ├── QWsHandshake.h ├── QWsFrame.cpp ├── WsEnums.h ├── functions.cpp ├── QTlsServer.cpp ├── QWsServer.h ├── QtWebsocket.vcxproj.filters ├── QWsSocket.h ├── QWsHandshake.cpp ├── QWsServer.cpp └── QtWebsocket.vcxproj ├── .gitignore ├── README.md ├── QtWebsocket.sln └── lgpl-3.0.txt /utils/ca/ca.srl: -------------------------------------------------------------------------------- 1 | CDA0BC5350F20D77 2 | -------------------------------------------------------------------------------- /AutobahnTestSuite/.gitignore: -------------------------------------------------------------------------------- 1 | GeneratedFiles/ 2 | reports/ 3 | -------------------------------------------------------------------------------- /Example/Server/Server.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/antlafarge/QtWebsocket/HEAD/Example/Server/Server.cpp -------------------------------------------------------------------------------- /AutobahnTestSuite/autobahntest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | trap 'kill $(jobs -p)' EXIT 4 | ./TestServer 2>/dev/null 1>/dev/null & 5 | wstest -m fuzzingclient -s fuzzingclient.json 6 | 7 | -------------------------------------------------------------------------------- /AutobahnTestSuite/autobahntest.sh.txt: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | trap 'kill $(jobs -p)' EXIT 4 | ./TestServer 2>/dev/null 1>/dev/null & 5 | wstest -m fuzzingclient -s fuzzingclient.json 6 | 7 | -------------------------------------------------------------------------------- /AutobahnTestSuite/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "TestServer.h" 4 | 5 | int main(int argc, char *argv[]) 6 | { 7 | QCoreApplication app(argc, argv); 8 | 9 | TestServer server(80); 10 | 11 | return app.exec(); 12 | } 13 | -------------------------------------------------------------------------------- /utils/ca/README.md: -------------------------------------------------------------------------------- 1 | key ca passphrase: 2 | qtwebsocket 3 | 4 | ======== 5 | 6 | key client passphrase: 7 | qtwebsocket-client-key 8 | 9 | client cert challenge password: 10 | client-challenge 11 | 12 | ======== 13 | 14 | key server passphrase: 15 | qtwebsocket-server-key 16 | 17 | server cert challenge password: 18 | server-challenge 19 | -------------------------------------------------------------------------------- /AutobahnTestSuite/fuzzingclient.json: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "options": {"failByDrop": false}, 4 | "outdir": "./reports/servers", 5 | 6 | "servers": [{"agent": "QtWebSocket", "url": "ws://localhost:1337", "options": {"version": 18}}], 7 | 8 | "cases": ["*"], 9 | "exclude-cases": ["6.*", "9.*", "10.*"], 10 | "exclude-agent-cases": {} 11 | } 12 | -------------------------------------------------------------------------------- /QtWebsocket.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS += \ 4 | QtWebsocket \ 5 | Example/Client \ 6 | Example/Server \ 7 | Example/ServerThreaded \ 8 | AutobahnTestSuite 9 | 10 | Client.depends = QtWebsocket 11 | Server.depends = QtWebsocket 12 | ServerThreaded.depends = QtWebsocket 13 | AutobahnTestSuite.depends = QtWebsocket 14 | -------------------------------------------------------------------------------- /AutobahnTestSuite/fuzzingclient.json.txt: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "options": {"failByDrop": false}, 4 | "outdir": "./reports/servers", 5 | 6 | "servers": [{"agent": "QtWebSocket", "url": "ws://localhost:1337", "options": {"version": 18}}], 7 | 8 | "cases": ["*"], 9 | "exclude-cases": ["6.*", "9.*", "10.*"], 10 | "exclude-agent-cases": {} 11 | } 12 | -------------------------------------------------------------------------------- /utils/ca/client-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,11EB276A685D3159 4 | 5 | I6szanrbr6GPJWTQliYFR36cg3tOmkVpnm/AeDVTuIad7R6X0S2Qty4yWCe/wQ3Q 6 | RL7OFNR+yZjkIc05ryXopsxgCayJG2cwilQB48HvVwfKzA3VIIVh5GaECGrm+p/S 7 | cq59xT+9qJ8TR+piNDS8LHc/8G/jbExd4Bd8bXmZ1XHhZLS3p0l7wRAlFrgLHsJ1 8 | d2kgi9nbXyjOHQ+Af0RmZ19yyWfVcA5xJrqSX5qu6kqHRp6GbmcCp1p69cGM/74v 9 | yf6hAJP0sB98obdei5RczEFqmwveKa+KFbIdd7jevdJgI0C4W/tJY0daNtPcAg4J 10 | ret+Wq456bKr8CpvtvPmOTPWV34R5MzhUFFmgrNm33i4LJVJxyPupO7d6HD0bz8D 11 | dRT4qvcKWGVlIQyIlQiF9BfGYjj7xL+FD1nv3PpXt9U= 12 | -----END RSA PRIVATE KEY----- 13 | -------------------------------------------------------------------------------- /utils/ca/server-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,8BD43CA32F6CF72E 4 | 5 | bZb9lNyvm0xuRPmjtH9+XZtoIbOGE7h3iXxm2msxZoWy43Q/pCE/4ValRqkp5Cku 6 | 31shA9VtZ/rMG4E/KtfMaeKsX5JagCnX6/VT7O/QypvCln4ywXZc7j+3IjgToNk/ 7 | C5hWBw05G8KY2eeHHNadBdF7+D0SS/tRmtExN5LMbkewY1nOde9AZVFWpeHDeMZ6 8 | di2QxxVG0AM8W4v842NdJK/FLKMi44Sl1pgVe4+Qdlf3VYU/vnkSVkJBrcqptl1h 9 | 2HzMYtofwUuxLoMkx8SeC4f5WxHGJqzywLGtbuXNYz/+HcxAToENFne1TKiMSGYT 10 | /bjU4AtRaFmddKdVHkXu8ulInPsQVhdT9yUAaD48U3WHuRGv6rwRmQYiX6X22yg5 11 | XlIRDmmUBoOxbCa5ixpL/m09dAVLQoFoEzWra7kiz/M= 12 | -----END RSA PRIVATE KEY----- 13 | -------------------------------------------------------------------------------- /utils/ca/ca.key: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,B2035665FCC3CB6E 4 | 5 | 5F3H4Jj3BPUHbq2KnoyxWcvnyrXWZkmfMI1NQawaOc/JBB7nVWkZoamx9actYvmq 6 | W4AN87hW26+cIxc7dMKMu0IiCsxpxQnrQEVShvkXj9jnDdf4J7ecxgw4h2yLS5/V 7 | x0PaWxcuGVqTy7kat3yeKvdSNuIehzyM3myo9vrOgfNxvY9AQjRRUqCcAmLfV2Nm 8 | HXCYm/qwsr5t8l3O3qguUezbeRpfJqSMR0MaenmIUSpoL1KVHAsIvNOZoTi404K0 9 | 1GGmIodNAAlqI67AnZEph3fLIu7ZMdElqocsniVATdF8mI0iNxnzafCryDeFw1NT 10 | KWu6a4o4Hk6eWqKXeZ65JnFfbHmTmrpkM+w/58IBl+oK+KG3xHlZyt3H2NDGHAQ1 11 | qpH8ALGKXrbIqynEnFRJJdNjHC7Je4HbSHl/6RN6RRdsHDrEFIkUyg== 12 | -----END RSA PRIVATE KEY----- 13 | -------------------------------------------------------------------------------- /AutobahnTestSuite/README.md: -------------------------------------------------------------------------------- 1 | Prerequisites 2 | ============= 3 | 4 | AutobahnTestSuite (see http://autobahn.ws/testsuite/installation) 5 | 6 | Running Tests 7 | ============= 8 | 9 | `cd AutobahnTestSuite && make test` 10 | This compiles the test server and runs `autobahntest.sh`. 11 | Check `reports/server/index.html` for the test suite report. 12 | 13 | Configuring Test Suite 14 | ====================== 15 | 16 | The test suite can be configured be editing `fuzzingclient.json`. By default the 17 | UTF-8 and performance tests are skipped. All other tests should pass. 18 | For more on the configuration options refer to AutobahnTestSuite documentation. 19 | -------------------------------------------------------------------------------- /utils/ca/client.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIBgTCCASsCAQAwgYgxCzAJBgNVBAYTAkZSMRMwEQYDVQQIDApTb21lLVN0YXRl 3 | MRQwEgYDVQQKDAtRdFdlYnNvY2tldDEUMBIGA1UECwwLUXRXZWJzb2NrZXQxEjAQ 4 | BgNVBAMMCWxvY2FsaG9zdDEkMCIGCSqGSIb3DQEJARYVcXR3ZWJzb2NrZXRAZ21h 5 | aWwuY29tMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAK9L+Au6+Wb5Osnpmr2y1cDm 6 | 1W7A+DaIaNuLZxf8JCRa1GpvbvM+joAT4uEIHY1OmpX45a99PRGYiKpAps/U+qsC 7 | AwEAAaA9MBoGCSqGSIb3DQEJAjENDAtRdFdlYnNvY2tldDAfBgkqhkiG9w0BCQcx 8 | EgwQY2xpZW50LWNoYWxsZW5nZTANBgkqhkiG9w0BAQUFAANBAB4Es3HuQv8xiYqz 9 | 4+2W4rVyltUkzb7FuJlVTvRFYGoIJWHL5mk3D34Y5rCeWZoDrjNKe1MjAsyPWlZA 10 | avzOAWE= 11 | -----END CERTIFICATE REQUEST----- 12 | -------------------------------------------------------------------------------- /utils/ca/server.csr: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIBgTCCASsCAQAwgYgxCzAJBgNVBAYTAkZSMRMwEQYDVQQIDApTb21lLVN0YXRl 3 | MRQwEgYDVQQKDAtRdFdlYnNvY2tldDEUMBIGA1UECwwLUXRXZWJzb2NrZXQxEjAQ 4 | BgNVBAMMCWxvY2FsaG9zdDEkMCIGCSqGSIb3DQEJARYVcXR3ZWJzb2NrZXRAZ21h 5 | aWwuY29tMFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAM9L7mUhNcsAob/5iw9xm4Cq 6 | JwPO3JUcriKkBWWItlZns5Lxom/ZhGXkN/4x5BXU9x2qfKU2rsrR0oHA1PalSdEC 7 | AwEAAaA9MBoGCSqGSIb3DQEJAjENDAtRdFdlYnNvY2tldDAfBgkqhkiG9w0BCQcx 8 | EgwQc2VydmVyLWNoYWxsZW5nZTANBgkqhkiG9w0BAQUFAANBADPbFwQyNkFsabiN 9 | bCEEHPgTCO3n5Zmit4uPDrxtv7QgjuTPk1wE8xRR5W15g+oudlAJCNVBaIWbEn6v 10 | zyhD8u0= 11 | -----END CERTIFICATE REQUEST----- 12 | -------------------------------------------------------------------------------- /QtWebsocket/QtWebsocket.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2012-03-05T10:38:43 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += network 8 | 9 | QT -= gui 10 | 11 | TARGET = QtWebsocket 12 | TEMPLATE = lib 13 | CONFIG += staticlib 14 | 15 | SOURCES += \ 16 | QWsServer.cpp \ 17 | QWsSocket.cpp \ 18 | QWsHandshake.cpp \ 19 | QWsFrame.cpp \ 20 | QTlsServer.cpp \ 21 | functions.cpp 22 | 23 | HEADERS += \ 24 | QWsServer.h \ 25 | QWsSocket.h \ 26 | QWsHandshake.h \ 27 | QWsFrame.h \ 28 | QTlsServer.h \ 29 | functions.h \ 30 | WsEnums.h 31 | -------------------------------------------------------------------------------- /AutobahnTestSuite/TestServer.h: -------------------------------------------------------------------------------- 1 | #ifndef TESTSERVER_H 2 | #define TESTSERVER_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #include "QWsServer.h" 9 | #include "QWsSocket.h" 10 | 11 | class TestServer : public QObject 12 | { 13 | Q_OBJECT 14 | 15 | public: 16 | TestServer(int port = 80); 17 | ~TestServer(); 18 | 19 | public slots: 20 | void onClientConnection(); 21 | void onDataReceived(QString data); 22 | void onDataReceived(const QByteArray & data); 23 | void onPong(quint64 elapsedTime); 24 | void onClientDisconnection(); 25 | 26 | private: 27 | QtWebsocket::QWsServer* server; 28 | QList clients; 29 | int _port; 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /utils/ca/client-crt.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICBDCCAa4CCQDNoLxTUPINdjANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC 3 | RlIxEzARBgNVBAgMClNvbWUtU3RhdGUxFDASBgNVBAoMC1F0V2Vic29ja2V0MRQw 4 | EgYDVQQLDAtRdFdlYnNvY2tldDESMBAGA1UEAwwJbG9jYWxob3N0MSQwIgYJKoZI 5 | hvcNAQkBFhVxdHdlYnNvY2tldEBnbWFpbC5jb20wHhcNMTMwODIzMTQ1MDU3WhcN 6 | MTMwOTIyMTQ1MDU3WjCBiDELMAkGA1UEBhMCRlIxEzARBgNVBAgMClNvbWUtU3Rh 7 | dGUxFDASBgNVBAoMC1F0V2Vic29ja2V0MRQwEgYDVQQLDAtRdFdlYnNvY2tldDES 8 | MBAGA1UEAwwJbG9jYWxob3N0MSQwIgYJKoZIhvcNAQkBFhVxdHdlYnNvY2tldEBn 9 | bWFpbC5jb20wXDANBgkqhkiG9w0BAQEFAANLADBIAkEAr0v4C7r5Zvk6yemavbLV 10 | wObVbsD4Noho24tnF/wkJFrUam9u8z6OgBPi4QgdjU6alfjlr309EZiIqkCmz9T6 11 | qwIDAQABMA0GCSqGSIb3DQEBBQUAA0EAN+wAapg69K8gY0/jX7uKoik5gV/QPO+I 12 | VJRBVODBwTvoYaFBcbQZf+dIczI5xbVnaJ+dAdP9Z0gAxFQAKlaHsg== 13 | -----END CERTIFICATE----- 14 | -------------------------------------------------------------------------------- /utils/ca/server-crt.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICBDCCAa4CCQDNoLxTUPINdzANBgkqhkiG9w0BAQUFADCBiDELMAkGA1UEBhMC 3 | RlIxEzARBgNVBAgMClNvbWUtU3RhdGUxFDASBgNVBAoMC1F0V2Vic29ja2V0MRQw 4 | EgYDVQQLDAtRdFdlYnNvY2tldDESMBAGA1UEAwwJbG9jYWxob3N0MSQwIgYJKoZI 5 | hvcNAQkBFhVxdHdlYnNvY2tldEBnbWFpbC5jb20wHhcNMTMwODIzMTQ1NTMwWhcN 6 | MTMwOTIyMTQ1NTMwWjCBiDELMAkGA1UEBhMCRlIxEzARBgNVBAgMClNvbWUtU3Rh 7 | dGUxFDASBgNVBAoMC1F0V2Vic29ja2V0MRQwEgYDVQQLDAtRdFdlYnNvY2tldDES 8 | MBAGA1UEAwwJbG9jYWxob3N0MSQwIgYJKoZIhvcNAQkBFhVxdHdlYnNvY2tldEBn 9 | bWFpbC5jb20wXDANBgkqhkiG9w0BAQEFAANLADBIAkEAz0vuZSE1ywChv/mLD3Gb 10 | gKonA87clRyuIqQFZYi2VmezkvGib9mEZeQ3/jHkFdT3Hap8pTauytHSgcDU9qVJ 11 | 0QIDAQABMA0GCSqGSIb3DQEBBQUAA0EA60npulwJ7HRiEnxnhe8Oq3CXsJeXIdN7 12 | HN8dU9SEmisqWo2Rb/tfK0y9yUJyOUcZcjC81zKBFaOR9HgDR7vrcQ== 13 | -----END CERTIFICATE----- 14 | -------------------------------------------------------------------------------- /utils/ca/ca.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIICWzCCAgWgAwIBAgIJAI3nmh+q5HLMMA0GCSqGSIb3DQEBBQUAMIGIMQswCQYD 3 | VQQGEwJGUjETMBEGA1UECAwKU29tZS1TdGF0ZTEUMBIGA1UECgwLUXRXZWJzb2Nr 4 | ZXQxFDASBgNVBAsMC1F0V2Vic29ja2V0MRIwEAYDVQQDDAlsb2NhbGhvc3QxJDAi 5 | BgkqhkiG9w0BCQEWFXF0d2Vic29ja2V0QGdtYWlsLmNvbTAeFw0xMzA4MjMxNDQ1 6 | MTRaFw0xMzA5MjIxNDQ1MTRaMIGIMQswCQYDVQQGEwJGUjETMBEGA1UECAwKU29t 7 | ZS1TdGF0ZTEUMBIGA1UECgwLUXRXZWJzb2NrZXQxFDASBgNVBAsMC1F0V2Vic29j 8 | a2V0MRIwEAYDVQQDDAlsb2NhbGhvc3QxJDAiBgkqhkiG9w0BCQEWFXF0d2Vic29j 9 | a2V0QGdtYWlsLmNvbTBcMA0GCSqGSIb3DQEBAQUAA0sAMEgCQQDz5LYY6ZONbWK+ 10 | GEZgw5D7nj5UiTOZSvnd1md9/WM9UGsQMSuE6DZLDkzbTvSFjATr6EB1WynDxWCE 11 | MHNMgkWRAgMBAAGjUDBOMB0GA1UdDgQWBBSr36nR7edNBrd/JveXNDZulomD8zAf 12 | BgNVHSMEGDAWgBSr36nR7edNBrd/JveXNDZulomD8zAMBgNVHRMEBTADAQH/MA0G 13 | CSqGSIb3DQEBBQUAA0EAQLnPrpTePQWOi+od6+SD6YkEL3muuf8yoQ8YlyjQL5ZS 14 | IjRqfrQUDPWVj3Zp6KCx3GX4YNDCgdxBneeQWpUUsA== 15 | -----END CERTIFICATE----- 16 | -------------------------------------------------------------------------------- /AutobahnTestSuite/AutobahnTestSuite.pro: -------------------------------------------------------------------------------- 1 | QT += core network 2 | 3 | TARGET = TestServer 4 | CONFIG += console 5 | TEMPLATE = app 6 | 7 | DEPENDPATH += "../QtWebsocket" 8 | SOURCES += \ 9 | main.cpp \ 10 | TestServer.cpp 11 | 12 | INCLUDEPATH += "../QtWebsocket" 13 | HEADERS += \ 14 | QWsServer.h \ 15 | QWsSocket.h \ 16 | TestServer.h 17 | 18 | win32:CONFIG(release, debug|release): LIBS += -L../QtWebsocket/release/ -lQtWebsocket 19 | else:win32:CONFIG(debug, debug|release): LIBS += -L../QtWebsocket/debug/ -lQtWebsocket 20 | else:unix:!symbian: LIBS += -L../QtWebsocket/ -lQtWebsocket 21 | 22 | win32:CONFIG(release, debug|release): PRE_TARGETDEPS += ../QtWebsocket/release/libQtWebsocket.a 23 | else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += ../QtWebsocket/debug/libQtWebsocket.a 24 | else:unix:!symbian: PRE_TARGETDEPS += ../QtWebsocket/libQtWebsocket.a 25 | 26 | test.commands = ./autobahntest.sh 27 | test.target = test 28 | test.depends = TestServer 29 | 30 | QMAKE_EXTRA_TARGETS += test 31 | -------------------------------------------------------------------------------- /Example/Server/Server.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2013-02-23T07:57:09 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core network 8 | 9 | TARGET = Server 10 | CONFIG += console 11 | TEMPLATE = app 12 | 13 | DEPENDPATH += "../../QtWebsocket" 14 | SOURCES += \ 15 | main.cpp \ 16 | Server.cpp 17 | 18 | INCLUDEPATH += "../../QtWebsocket" 19 | HEADERS += \ 20 | QWsServer.h \ 21 | QWsSocket.h \ 22 | Server.h 23 | 24 | win32:CONFIG(release, debug|release): LIBS += -L../../QtWebsocket/release/ -lQtWebsocket 25 | else:win32:CONFIG(debug, debug|release): LIBS += -L../../QtWebsocket/debug/ -lQtWebsocket 26 | else:unix:!symbian: LIBS += -L../../QtWebsocket/ -lQtWebsocket 27 | 28 | win32:CONFIG(release, debug|release): PRE_TARGETDEPS += ../../QtWebsocket/release/libQtWebsocket.a 29 | else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += ../../QtWebsocket/debug/libQtWebsocket.a 30 | else:unix:!symbian: PRE_TARGETDEPS += ../../QtWebsocket/libQtWebsocket.a 31 | -------------------------------------------------------------------------------- /Example/Client/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include "Client.h" 21 | #include 22 | 23 | int main(int argc, char *argv[]) 24 | { 25 | QApplication app(argc, argv); 26 | 27 | qsrand(QDateTime::currentMSecsSinceEpoch()); 28 | 29 | Client client; 30 | client.show(); 31 | 32 | return app.exec(); 33 | } 34 | -------------------------------------------------------------------------------- /Example/Client/Client.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2013-02-23T08:54:24 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui network 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = Client 12 | TEMPLATE = app 13 | 14 | INCLUDEPATH += ../../QtWebsocket 15 | DEPENDPATH += ../../QtWebsocket 16 | 17 | SOURCES += \ 18 | main.cpp \ 19 | Client.cpp 20 | 21 | HEADERS += \ 22 | QWsSocket.h \ 23 | Client.h 24 | 25 | FORMS += Client.ui 26 | 27 | win32:CONFIG(release, debug|release): LIBS += -L../../QtWebsocket/release/ -lQtWebsocket 28 | else:win32:CONFIG(debug, debug|release): LIBS += -L../../QtWebsocket/debug/ -lQtWebsocket 29 | else:unix:!symbian: LIBS += -L../../QtWebsocket/ -lQtWebsocket 30 | 31 | win32:CONFIG(release, debug|release): PRE_TARGETDEPS += ../../QtWebsocket/release/libQtWebsocket.a 32 | else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += ../../QtWebsocket/debug/libQtWebsocket.a 33 | else:unix:!symbian: PRE_TARGETDEPS += ../../QtWebsocket/libQtWebsocket.a 34 | -------------------------------------------------------------------------------- /Example/Server/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include "Server.h" 21 | #include 22 | #include 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | QCoreApplication app(argc, argv); 27 | 28 | qsrand(QDateTime::currentMSecsSinceEpoch()); 29 | 30 | Server myServer(80, QtWebsocket::Tcp); 31 | 32 | return app.exec(); 33 | } 34 | -------------------------------------------------------------------------------- /Example/ServerThreaded/ServerThreaded.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2013-02-23T08:36:29 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core network 8 | 9 | TARGET = ServerThreaded 10 | CONFIG += console 11 | TEMPLATE = app 12 | 13 | INCLUDEPATH += ../../QtWebsocket 14 | DEPENDPATH += ../../QtWebsocket 15 | 16 | SOURCES += \ 17 | main.cpp \ 18 | ServerThreaded.cpp \ 19 | SocketThread.cpp 20 | 21 | HEADERS += \ 22 | QWsServer.h \ 23 | QWsSocket.h \ 24 | ServerThreaded.h \ 25 | SocketThread.h 26 | 27 | win32:CONFIG(release, debug|release): LIBS += -L../../QtWebsocket/release/ -lQtWebsocket 28 | else:win32:CONFIG(debug, debug|release): LIBS += -L../../QtWebsocket/debug/ -lQtWebsocket 29 | else:unix:!symbian: LIBS += -L../../QtWebsocket/ -lQtWebsocket 30 | 31 | win32:CONFIG(release, debug|release): PRE_TARGETDEPS += ../../QtWebsocket/release/libQtWebsocket.a 32 | else:win32:CONFIG(debug, debug|release): PRE_TARGETDEPS += ../../QtWebsocket/debug/libQtWebsocket.a 33 | else:unix:!symbian: PRE_TARGETDEPS += ../../QtWebsocket/libQtWebsocket.a 34 | -------------------------------------------------------------------------------- /Example/ServerThreaded/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include "ServerThreaded.h" 21 | #include 22 | #include 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | QCoreApplication app(argc, argv); 27 | 28 | std::cout << QObject::tr("main thread : 0x%1").arg(QString::number((unsigned int)QThread::currentThreadId(), 16)).toStdString() << std::endl; 29 | 30 | ServerThreaded myThreadedServer; 31 | 32 | return app.exec(); 33 | } 34 | -------------------------------------------------------------------------------- /QtWebsocket/functions.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef QTWS_FUNCTIONS_H 21 | #define QTWS_FUNCTIONS_H 22 | 23 | #include 24 | 25 | namespace QtWebsocket 26 | { 27 | 28 | bool rand2(); 29 | quint8 rand8(quint8 low = 0, quint8 high = 0); 30 | quint16 rand16(quint16 low = 0, quint16 high = 0); 31 | quint32 rand32(quint32 low = 0, quint32 high = 0); 32 | quint64 rand64(quint64 low = 0, quint64 high = 0); 33 | 34 | } // namespace QtWebsocket 35 | 36 | #endif // QTWS_FUNCTIONS_H 37 | -------------------------------------------------------------------------------- /Example/ServerThreaded/ServerThreaded.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef SERVERTHREADED_H 21 | #define SERVERTHREADED_H 22 | 23 | #include 24 | #include 25 | 26 | #include "QWsServer.h" 27 | #include "QWsSocket.h" 28 | #include "SocketThread.h" 29 | 30 | class ServerThreaded : public QObject 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | ServerThreaded(); 36 | ~ServerThreaded(); 37 | 38 | public slots: 39 | void processNewConnection(); 40 | 41 | signals: 42 | void broadcastMessage(QString message); 43 | 44 | private: 45 | QtWebsocket::QWsServer* server; 46 | }; 47 | 48 | #endif // SERVERTHREADED_H 49 | -------------------------------------------------------------------------------- /Example/Server/Server.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef SERVER_H 21 | #define SERVER_H 22 | 23 | #include 24 | #include 25 | 26 | #include "QWsServer.h" 27 | #include "QWsSocket.h" 28 | 29 | class Server : public QObject 30 | { 31 | Q_OBJECT 32 | 33 | public: 34 | Server(int port = 80, QtWebsocket::Protocol protocol = QtWebsocket::Tcp); 35 | ~Server(); 36 | 37 | public slots: 38 | void processNewConnection(); 39 | void processMessage(QString message); 40 | void processPong(quint64 elapsedTime); 41 | void socketDisconnected(); 42 | 43 | private: 44 | QtWebsocket::QWsServer* server; 45 | QList clients; 46 | }; 47 | 48 | #endif // SERVER_H 49 | -------------------------------------------------------------------------------- /Example/ServerThreaded/SocketThread.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef SOCKETTHREAD_H 21 | #define SOCKETTHREAD_H 22 | 23 | #include 24 | 25 | #include "QWsSocket.h" 26 | 27 | class SocketThread : public QThread 28 | { 29 | Q_OBJECT 30 | 31 | public: 32 | SocketThread(QtWebsocket::QWsSocket* wsSocket); 33 | ~SocketThread(); 34 | 35 | QtWebsocket::QWsSocket* socket; 36 | void run(); 37 | 38 | private slots: 39 | void processMessage(QString message); 40 | void sendMessage(QString message); 41 | void processPong(quint64 elapsedTime); 42 | void socketDisconnected(); 43 | void finished(); 44 | 45 | signals: 46 | void messageReceived(QString frame); 47 | 48 | private: 49 | 50 | }; 51 | 52 | #endif // SOCKETTHREAD_H 53 | -------------------------------------------------------------------------------- /Example/Client/Client.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef CLIENT_H 21 | #define CLIENT_H 22 | 23 | #include 24 | #include "QWsSocket.h" 25 | 26 | namespace Ui { 27 | class Client; 28 | } 29 | 30 | class Client : public QWidget 31 | { 32 | Q_OBJECT 33 | 34 | public: 35 | explicit Client(QWidget* parent = 0); 36 | ~Client(); 37 | 38 | protected slots: 39 | void socketConnected(); 40 | void socketDisconnected(); 41 | void sendMessage(); 42 | void connectSocket(); 43 | void disconnectSocket(); 44 | void displayMessage(QString message); 45 | void socketStateChanged(QAbstractSocket::SocketState socketState); 46 | void displaySslErrors(const QList& errors); 47 | 48 | protected: 49 | QtWebsocket::QWsSocket* wsSocket; 50 | QString defaultPseudo; 51 | 52 | private: 53 | Ui::Client* ui; 54 | }; 55 | 56 | #endif // CLIENT_H 57 | -------------------------------------------------------------------------------- /utils/QtWebsocket_qtcreator_codestyle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | CodeStyleData 7 | 8 | true 9 | false 10 | true 11 | false 12 | true 13 | false 14 | false 15 | false 16 | true 17 | true 18 | false 19 | true 20 | false 21 | false 22 | false 23 | 4 24 | true 25 | true 26 | 2 27 | false 28 | 4 29 | 30 | 31 | 32 | DisplayName 33 | QtWebsocket 34 | 35 | 36 | -------------------------------------------------------------------------------- /QtWebsocket/QTlsServer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef QTLSSERVER_H 21 | #define QTLSSERVER_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "QWsSocket.h" 37 | 38 | #include 39 | 40 | namespace QtWebsocket 41 | { 42 | 43 | // This class manage basic and secured (TLS/SSL) TCP connections 44 | class QTlsServer : public QTcpServer 45 | { 46 | Q_OBJECT 47 | 48 | public: 49 | QTlsServer(QObject* parent = NULL, Protocol allowedProtocols = Tcp); 50 | virtual ~QTlsServer(); 51 | 52 | Protocol allowedProtocols(); 53 | 54 | public slots: 55 | void displayTlsErrors(const QList& errors); 56 | void tlsSocketEncrypted(); 57 | void test(); 58 | 59 | signals: 60 | void newTlsConnection(QSslSocket* serverSocket); 61 | 62 | protected: 63 | virtual void incomingConnection(qintptr socketDescriptor); 64 | const Protocol _allowedProtocols; 65 | }; 66 | 67 | } // namespace QtWebsocket 68 | 69 | #endif // QTLSSERVER_H 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | 8 | # VS projects 9 | #*.sln 10 | #*.vcproj 11 | 12 | # Is built by qmake 13 | Makefile 14 | 15 | # Build results 16 | [Dd]ebug*/ 17 | [Rr]elease*/ 18 | [Bb]in/ 19 | [Bb]uild/ 20 | [Oo]bj/ 21 | [Gg]enerated[Ff]iles/ 22 | [Rr]esources/ 23 | *.exe 24 | *.dll 25 | *_i.c 26 | *_p.c 27 | *.ilk 28 | *.log 29 | *.lib 30 | *.meta 31 | *.[Oo]bj 32 | *.pch 33 | *.pdb 34 | *.pgc 35 | *.pgd 36 | *.rsp 37 | *.sbr 38 | *.tlb 39 | *.tli 40 | *.tlh 41 | *.bak 42 | *.tmp 43 | *.vspscc 44 | *.vssscc 45 | *.o 46 | *.a 47 | .builds 48 | Ankh.NoLoad 49 | *.sln.cache 50 | 51 | # Qt build 52 | ui_*.h 53 | moc_* 54 | 55 | # Executables 56 | Example/Client/Client 57 | Example/Server/Server 58 | Example/ServerThreaded/ServerThreaded 59 | AutobahnTestSuite/TestServer 60 | 61 | # Test results 62 | Test/reports/ 63 | 64 | # Visual C++ cache files 65 | ipch/ 66 | obj/ 67 | *.aps 68 | *.ncb 69 | *.opensdf 70 | *.sdf 71 | 72 | # Visual Studio profiler 73 | *.psess 74 | *.vsp 75 | 76 | # Others 77 | sql 78 | TestResults 79 | *.[Cc]ache 80 | ClientBin 81 | stylecop.* 82 | ~$* 83 | *.dbmdl 84 | 85 | # Backup and report files from converting an old project file to a newer 86 | # Visual Studio version. Backup files are not needed, because we have git ;-) 87 | _UpgradeReport_Files/ 88 | Backup/ 89 | UpgradeLog.XML 90 | 91 | # OS generated files 92 | *.DS_Store 93 | ehthumbs.db 94 | Icon? 95 | [Tt]humbs.db 96 | 97 | #Subversion files 98 | .svn 99 | 100 | # Office Temp Files 101 | ~$* 102 | 103 | # Some specific files 104 | Log.txt 105 | 106 | # git patch files 107 | *.patch 108 | 109 | # QtCreator specific 110 | *.pro.user 111 | 112 | 113 | # Vim backup and swap files: 114 | *~ 115 | *.swp 116 | 117 | # Generated documentation 118 | doc/ 119 | -------------------------------------------------------------------------------- /QtWebsocket/QWsFrame.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef QWSFRAME_H 21 | #define QWSFRAME_H 22 | 23 | #include "WsEnums.h" 24 | 25 | #include 26 | 27 | namespace QtWebsocket 28 | { 29 | 30 | /*! 31 | * Represents a frame sent over the the WebSocket connection. 32 | * 33 | * See also [RFC 6455, Section 5](http://tools.ietf.org/html/rfc6455#section-5). 34 | */ 35 | class QWsFrame 36 | { 37 | public: 38 | QWsFrame(); 39 | 40 | 41 | /*! 42 | * Clears the payload 43 | */ 44 | void clear(); 45 | 46 | 47 | /*! 48 | * Performs various checks on the integrity of the frame as required by 49 | * RFC 6455 50 | */ 51 | bool valid() const; 52 | 53 | /*! 54 | * Returns the unmaksed payload 55 | */ 56 | QByteArray data() const; 57 | 58 | 59 | /*! 60 | * Returns true if the opcode is a control code 61 | */ 62 | bool controlFrame() const; 63 | 64 | 65 | /*! 66 | * Tells us how many of the data fields have already been initialized 67 | */ 68 | ReadingState readingState; 69 | 70 | bool final; 71 | quint8 rsv; 72 | bool hasMask; 73 | Opcode opcode; 74 | qint64 payloadLength; 75 | char maskingKey[4]; 76 | QByteArray payload; 77 | }; 78 | 79 | } // namespace QtWebsocket 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /QtWebsocket/QWsHandshake.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef QWSHANDSHAKE_H 21 | #define QWSHANDSHAKE_H 22 | 23 | #include 24 | 25 | #include "WsEnums.h" 26 | 27 | namespace QtWebsocket 28 | { 29 | 30 | enum EWebsocketVersion 31 | { 32 | WS_VUnknow = -1, 33 | WS_V0 = 0, 34 | WS_V4 = 4, 35 | WS_V5 = 5, 36 | WS_V6 = 6, 37 | WS_V7 = 7, 38 | WS_V8 = 8, 39 | WS_V13 = 13 40 | }; 41 | 42 | class QWsHandshake 43 | { 44 | public: 45 | QWsHandshake(WsMode wsMode = WsClientMode); 46 | ~QWsHandshake(); 47 | 48 | bool read(QTcpSocket* tcpSocket); 49 | bool isValid(); 50 | bool isValidCommonPart(); 51 | bool isValidServerPart(); 52 | bool isValidClientPart(); 53 | 54 | WsMode _wsMode; 55 | 56 | bool readStarted; 57 | bool complete; 58 | 59 | QHash fields; 60 | 61 | QString rawHandshake; 62 | 63 | QString httpRequestVersion; 64 | bool httpRequestValid; 65 | QString errorString; 66 | 67 | QString resourceName; 68 | 69 | QString host; 70 | QString hostAddress; 71 | QString hostPort; 72 | 73 | EWebsocketVersion version; 74 | QByteArray key; 75 | QByteArray key1; 76 | QByteArray key2; 77 | QByteArray key3; 78 | 79 | QByteArray accept; 80 | 81 | QString origin; 82 | QString protocol; 83 | QString extensions; 84 | }; 85 | 86 | } // namespace QtWebsocket 87 | 88 | #endif // QWSHANDSHAKE_H 89 | -------------------------------------------------------------------------------- /QtWebsocket/QWsFrame.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include "QWsFrame.h" 21 | #include "QWsSocket.h" 22 | 23 | namespace QtWebsocket 24 | { 25 | 26 | QWsFrame::QWsFrame() : 27 | readingState(HeaderPending), 28 | final(false), 29 | rsv(0), 30 | hasMask(false), 31 | payloadLength(0) 32 | {} 33 | 34 | 35 | void QWsFrame::clear() 36 | { 37 | payload.clear(); 38 | readingState = HeaderPending; 39 | } 40 | 41 | 42 | QByteArray QWsFrame::data() const 43 | { 44 | QByteArray result; 45 | result.reserve(payload.size()); 46 | if (hasMask) { 47 | for (int i=0 ; i= 0x8; 58 | } 59 | 60 | // TODO implement, finished flag; 61 | bool QWsFrame::valid() const 62 | { 63 | if (payloadLength >> 63) // Most significant bit must be 0 64 | return false; 65 | if (rsv & 0x70) 66 | return false; 67 | if (opcode >= 0x3 && opcode <= 0x7) // Reserved opcode 68 | return false; 69 | if (opcode >= 0xB && opcode <= 0xF) // Reserved control opcode 70 | return false; 71 | if (controlFrame() && !final) // Control frames must not be fragmented 72 | return false; 73 | if (controlFrame() && payloadLength > 125) // Control frames must have small payload 74 | return false; 75 | 76 | return true; 77 | } 78 | 79 | } // namespace QtWebsocket 80 | -------------------------------------------------------------------------------- /Example/ServerThreaded/ServerThreaded.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include "ServerThreaded.h" 21 | #include 22 | 23 | ServerThreaded::ServerThreaded() 24 | { 25 | int port = 80; 26 | server = new QtWebsocket::QWsServer(this); 27 | if (! server->listen(QHostAddress::Any, port)) 28 | { 29 | std::cout << QObject::tr("Error: Can't launch server").toStdString() << std::endl; 30 | std::cout << QObject::tr("QWsServer error : %1").arg(server->errorString()).toStdString() << std::endl; 31 | } 32 | else 33 | { 34 | std::cout << QObject::tr("Server is listening port %1").arg(port).toStdString() << std::endl; 35 | } 36 | QObject::connect(server, SIGNAL(newConnection()), this, SLOT(processNewConnection())); 37 | } 38 | 39 | ServerThreaded::~ServerThreaded() 40 | { 41 | } 42 | 43 | void ServerThreaded::processNewConnection() 44 | { 45 | std::cout << QObject::tr("Client connected").toStdString() << std::endl; 46 | 47 | // Get the connecting socket 48 | QtWebsocket::QWsSocket* socket = server->nextPendingConnection(); 49 | 50 | // Create a new thread and giving to him the socket 51 | SocketThread* thread = new SocketThread(socket); 52 | 53 | // connect for message broadcast 54 | QObject::connect(socket, SIGNAL(frameReceived(QString)), this, SIGNAL(broadcastMessage(QString))); 55 | QObject::connect(this, SIGNAL(broadcastMessage(QString)), thread, SLOT(sendMessage(QString))); 56 | 57 | // Starting the thread 58 | thread->start(); 59 | } 60 | -------------------------------------------------------------------------------- /QtWebsocket/WsEnums.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef WSENUMS_H 21 | #define WSENUMS_H 22 | 23 | namespace QtWebsocket 24 | { 25 | 26 | enum Protocol 27 | { 28 | None = 0x0, 29 | Tcp = 0x1, 30 | Tls = 0x2 31 | //TcpTls= 0x3 // soon 32 | }; 33 | 34 | enum WsMode 35 | { 36 | WsClientMode = 1, 37 | WsServerMode = 2 38 | }; 39 | 40 | enum Opcode 41 | { 42 | OpContinue = 0x0, 43 | OpText = 0x1, 44 | OpBinary = 0x2, 45 | OpReserved3 = 0x3, 46 | OpReserved4 = 0x4, 47 | OpReserved5 = 0x5, 48 | OpReserved6 = 0x6, 49 | OpReserved7 = 0x7, 50 | OpClose = 0x8, 51 | OpPing = 0x9, 52 | OpPong = 0xA, 53 | OpReservedB = 0xB, 54 | OpReservedV = 0xC, 55 | OpReservedD = 0xD, 56 | OpReservedE = 0xE, 57 | OpReservedF = 0xF 58 | }; 59 | 60 | enum CloseStatusCode 61 | { 62 | NoCloseStatusCode = 0, 63 | CloseNormal = 1000, 64 | CloseGoingAway = 1001, 65 | CloseProtocolError = 1002, 66 | CloseDataTypeNotSupported = 1003, 67 | CloseReserved1004 = 1004, 68 | CloseMissingStatusCode = 1005, 69 | CloseAbnormalDisconnection = 1006, 70 | CloseWrongDataType = 1007, 71 | ClosePolicyViolated = 1008, 72 | CloseTooMuchData = 1009, 73 | CloseMissingExtension = 1010, 74 | CloseBadOperation = 1011, 75 | CloseTLSHandshakeFailed = 1015 76 | }; 77 | 78 | enum ReadingState 79 | { 80 | HeaderPending, 81 | PayloadLengthPending, 82 | BigPayloadLenghPending, 83 | MaskPending, 84 | PayloadBodyPending, 85 | CloseDataPending 86 | }; 87 | 88 | } // namespace QtWebsocket 89 | 90 | #endif // WSENUMS_H 91 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # QtWebsocket 2 | 3 | A Qt Websocket server and client implementation. 4 | The project is now deprecated because Qt provides an implementation of the websocket client and server protocol. 5 | More informations here: http://doc.qt.io/qt-5/qtwebsockets-index.html 6 | 7 | ## Licence 8 | 9 | Copyright 2013 Antoine Lafarge 10 | 11 | This file is part of QtWebsocket. 12 | 13 | QtWebsocket is free software: you can redistribute it and/or modify 14 | it under the terms of the GNU Lesser General Public License as published by 15 | the Free Software Foundation, either version 3 of the License, or 16 | any later version. 17 | 18 | QtWebsocket is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | GNU Lesser General Public License for more details. 22 | 23 | You should have received a copy of the GNU Lesser General Public License 24 | along with QtWebsocket. If not, see . 25 | 26 | ## Compatibility 27 | 28 | - Google Chrome 16 29 | - Mozilla Firefox 9 30 | - Safari 5.1 31 | - Opera 12.5 32 | 33 | ## Installation 34 | 35 | You have two possibilities described below. 36 | Don't hesitate to look at the examples projects. 37 | 38 | **Clean modular method - Static lib** 39 | - Open the main project with QtCreator _(QtWebsocket.pro)_ or Visual Studio _(QtWebsocket.sln)_. 40 | - Compile the project, this will result in a static lib _(*.lib or *.a file)_. 41 | - Add the _header_ files _(.h)_ from the _QtWebsocket_ directory in your project. 42 | - Link the generated static lib to your project. 43 | - Compile your project ! 44 | 45 | **Easy dirty method - Add the sources to your project** 46 | - Copy the _QtWebsocket_ directory in your project. 47 | - Add the _header_ and _cpp_ files in your project. 48 | - Compile your project ! 49 | 50 | ## Documentation 51 | 52 | No doc, you can look at the examples. 53 | 54 | ## Development 55 | 56 | **Implemented functionalities** 57 | - Text and binary data 58 | - Multi-thread support 59 | - Server and client implementation 60 | - WSS protocol (HTTPS/SSL/TLS) 61 | 62 | **Todo** 63 | - Websocket extensions 64 | -------------------------------------------------------------------------------- /AutobahnTestSuite/TestServer.cpp: -------------------------------------------------------------------------------- 1 | #include "TestServer.h" 2 | 3 | TestServer::TestServer(int port) : 4 | server(new QtWebsocket::QWsServer(this)), 5 | _port(port) 6 | { 7 | if (!server->listen(QHostAddress::LocalHost, _port)) 8 | { 9 | qDebug("Error: Can't launch server"); 10 | qDebug("QWsServer error: %s", server->errorString().toUtf8().constData()); 11 | } 12 | else 13 | { 14 | qDebug("Server is listening port %d", port); 15 | } 16 | connect(server, SIGNAL(newConnection()), this, SLOT(onClientConnection())); 17 | } 18 | 19 | TestServer::~TestServer() 20 | { 21 | } 22 | 23 | void TestServer::onClientConnection() 24 | { 25 | QtWebsocket::QWsSocket * clientSocket = server->nextPendingConnection(); 26 | 27 | connect(clientSocket, SIGNAL(frameReceived(QString)), this, SLOT(onDataReceived(QString))); 28 | connect(clientSocket, SIGNAL(frameReceived(QByteArray)), this, SLOT(onDataReceived(QByteArray))); 29 | connect(clientSocket, SIGNAL(disconnected()), this, SLOT(onClientDisconnection())); 30 | connect(clientSocket, SIGNAL(pong(quint64)), this, SLOT(onPong(quint64))); 31 | 32 | clients << clientSocket; 33 | 34 | qDebug("Client connected"); 35 | } 36 | 37 | void TestServer::onDataReceived(QString data) 38 | { 39 | QtWebsocket::QWsSocket* socket = qobject_cast(sender()); 40 | if (socket == 0) 41 | { 42 | return; 43 | } 44 | 45 | QtWebsocket::QWsSocket* client; 46 | foreach (client, clients) 47 | { 48 | client->write(data); 49 | } 50 | } 51 | 52 | void TestServer::onDataReceived(const QByteArray & data) 53 | { 54 | QtWebsocket::QWsSocket* socket = qobject_cast(sender()); 55 | if (socket == 0) 56 | { 57 | return; 58 | } 59 | 60 | QtWebsocket::QWsSocket* client; 61 | foreach (client, clients) 62 | { 63 | client->write(data); 64 | } 65 | } 66 | 67 | void TestServer::onPong(quint64 elapsedTime) 68 | { 69 | qDebug("ping: %s ms", QString::number(elapsedTime).toUtf8().constData()); 70 | } 71 | 72 | void TestServer::onClientDisconnection() 73 | { 74 | QtWebsocket::QWsSocket* socket = qobject_cast(sender()); 75 | if (socket == 0) 76 | { 77 | return; 78 | } 79 | 80 | clients.removeOne(socket); 81 | 82 | socket->deleteLater(); 83 | 84 | qDebug("Client disconnected"); 85 | } 86 | -------------------------------------------------------------------------------- /QtWebsocket/functions.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include 21 | #include 22 | 23 | namespace QtWebsocket 24 | { 25 | 26 | bool rand2() 27 | { 28 | return (qrand() & 0x1) == 0x1; 29 | } 30 | 31 | quint8 rand8(quint8 low, quint8 high) 32 | { 33 | if (low == 0 && high == 0) 34 | { 35 | high = UCHAR_MAX; 36 | } 37 | else if (low > high) 38 | { 39 | qSwap(low, high); 40 | } 41 | return low + (qrand() % (high - low + 1)); 42 | } 43 | 44 | quint16 rand16(quint16 low, quint16 high) 45 | { 46 | if (low == 0 && high == 0) 47 | { 48 | high = USHRT_MAX; 49 | } 50 | else if (low > high) 51 | { 52 | qSwap(low, high); 53 | } 54 | quint16 range = high - low; 55 | if (range < RAND_MAX) 56 | { 57 | return low + (qrand() % (range + 1)); 58 | } 59 | else 60 | { 61 | quint16 myRand = qrand(); 62 | myRand += (((quint16)qrand()) << 15); 63 | return low + (myRand % (high - low + 1)); 64 | } 65 | } 66 | 67 | quint32 rand32(quint32 low, quint32 high) 68 | { 69 | if (low == 0 && high == 0) 70 | { 71 | high = ULONG_MAX; 72 | } 73 | else if (low > high) 74 | { 75 | qSwap(low, high); 76 | } 77 | quint32 myRand = qrand(); 78 | myRand += (((quint32)qrand()) << 15); 79 | myRand += (((quint32)qrand()) << 30); 80 | return low + (myRand % (high - low + 1)); 81 | } 82 | 83 | quint64 rand64(quint64 low, quint64 high) 84 | { 85 | if (low == 0 && high == 0) 86 | { 87 | high = ULLONG_MAX; 88 | } 89 | else if (low > high) 90 | { 91 | qSwap(low, high); 92 | } 93 | quint64 myRand = qrand(); 94 | myRand += (((quint64)qrand()) << 15); 95 | myRand += (((quint64)qrand()) << 30); 96 | myRand += (((quint64)qrand()) << 45); 97 | myRand += (((quint64)qrand()) << 60); 98 | return low + (myRand % (high - low + 1)); 99 | } 100 | 101 | } // namespace QtWebsocket 102 | -------------------------------------------------------------------------------- /QtWebsocket.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QtWebsocket", "QtWebsocket\QtWebsocket.vcxproj", "{7E3A920C-4257-41A1-B9B9-BFA138C1C8A2}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Client", "Example\Client\Client.vcxproj", "{B12702AD-ABFB-343A-A199-8E24837244A3}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Server", "Example\Server\Server.vcxproj", "{5C7FFE1F-B387-4A78-AEDF-41F84E9FAB45}" 9 | ProjectSection(ProjectDependencies) = postProject 10 | {7E3A920C-4257-41A1-B9B9-BFA138C1C8A2} = {7E3A920C-4257-41A1-B9B9-BFA138C1C8A2} 11 | EndProjectSection 12 | EndProject 13 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ServerThreaded", "Example\ServerThreaded\ServerThreaded.vcxproj", "{5B11012D-3641-4AD8-9B65-11EA72C458DD}" 14 | ProjectSection(ProjectDependencies) = postProject 15 | {7E3A920C-4257-41A1-B9B9-BFA138C1C8A2} = {7E3A920C-4257-41A1-B9B9-BFA138C1C8A2} 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Win32 = Debug|Win32 21 | Release|Win32 = Release|Win32 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {7E3A920C-4257-41A1-B9B9-BFA138C1C8A2}.Debug|Win32.ActiveCfg = Debug|Win32 25 | {7E3A920C-4257-41A1-B9B9-BFA138C1C8A2}.Debug|Win32.Build.0 = Debug|Win32 26 | {7E3A920C-4257-41A1-B9B9-BFA138C1C8A2}.Release|Win32.ActiveCfg = Release|Win32 27 | {7E3A920C-4257-41A1-B9B9-BFA138C1C8A2}.Release|Win32.Build.0 = Release|Win32 28 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.ActiveCfg = Debug|Win32 29 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Debug|Win32.Build.0 = Debug|Win32 30 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.ActiveCfg = Release|Win32 31 | {B12702AD-ABFB-343A-A199-8E24837244A3}.Release|Win32.Build.0 = Release|Win32 32 | {5C7FFE1F-B387-4A78-AEDF-41F84E9FAB45}.Debug|Win32.ActiveCfg = Debug|Win32 33 | {5C7FFE1F-B387-4A78-AEDF-41F84E9FAB45}.Debug|Win32.Build.0 = Debug|Win32 34 | {5C7FFE1F-B387-4A78-AEDF-41F84E9FAB45}.Release|Win32.ActiveCfg = Release|Win32 35 | {5C7FFE1F-B387-4A78-AEDF-41F84E9FAB45}.Release|Win32.Build.0 = Release|Win32 36 | {5B11012D-3641-4AD8-9B65-11EA72C458DD}.Debug|Win32.ActiveCfg = Debug|Win32 37 | {5B11012D-3641-4AD8-9B65-11EA72C458DD}.Debug|Win32.Build.0 = Debug|Win32 38 | {5B11012D-3641-4AD8-9B65-11EA72C458DD}.Release|Win32.ActiveCfg = Release|Win32 39 | {5B11012D-3641-4AD8-9B65-11EA72C458DD}.Release|Win32.Build.0 = Release|Win32 40 | EndGlobalSection 41 | GlobalSection(SolutionProperties) = preSolution 42 | HideSolutionNode = FALSE 43 | EndGlobalSection 44 | EndGlobal 45 | -------------------------------------------------------------------------------- /Example/Server/Server.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;cxx;c;def 7 | true 8 | 9 | 10 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 11 | h 12 | true 13 | 14 | 15 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 16 | moc;h;cpp 17 | true 18 | 19 | 20 | {51697a4e-0da5-4b52-8ccb-d44437f374ea} 21 | cpp;moc 22 | False 23 | 24 | 25 | {7c02802c-28c2-497b-9f75-9423e4d9cfd0} 26 | cpp;moc 27 | False 28 | 29 | 30 | 31 | 32 | Source Files 33 | 34 | 35 | Source Files 36 | 37 | 38 | Generated Files\Debug 39 | 40 | 41 | Generated Files\Release 42 | 43 | 44 | Generated Files\Debug 45 | 46 | 47 | Generated Files\Release 48 | 49 | 50 | Generated Files\Debug 51 | 52 | 53 | Generated Files\Release 54 | 55 | 56 | 57 | 58 | Header Files 59 | 60 | 61 | Header Files 62 | 63 | 64 | Header Files 65 | 66 | 67 | -------------------------------------------------------------------------------- /AutobahnTestSuite/AutobahnTestSuite.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;cxx;c;def 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h 11 | 12 | 13 | {D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E} 14 | qrc;* 15 | false 16 | 17 | 18 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 19 | moc;h;cpp 20 | False 21 | 22 | 23 | {c888f328-7590-400a-9ff4-26dc6a6305df} 24 | cpp;moc 25 | False 26 | 27 | 28 | {40dcc3e4-2971-4072-9606-bc977d8825f9} 29 | cpp;moc 30 | False 31 | 32 | 33 | 34 | 35 | Source Files 36 | 37 | 38 | Source Files 39 | 40 | 41 | Generated Files\Release 42 | 43 | 44 | Generated Files\Release 45 | 46 | 47 | Generated Files\Release 48 | 49 | 50 | Generated Files\Debug 51 | 52 | 53 | Generated Files\Debug 54 | 55 | 56 | Generated Files\Debug 57 | 58 | 59 | 60 | 61 | Header Files 62 | 63 | 64 | Header Files 65 | 66 | 67 | Header Files 68 | 69 | 70 | -------------------------------------------------------------------------------- /Example/ServerThreaded/SocketThread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include "SocketThread.h" 21 | #include 22 | #include 23 | 24 | SocketThread::SocketThread(QtWebsocket::QWsSocket* wsSocket) : 25 | socket(wsSocket) 26 | { 27 | // Set this thread as parent of the socket 28 | // This will push the socket in the good thread when using moveToThread on the parent 29 | if (socket) 30 | { 31 | socket->setParent(this); 32 | } 33 | 34 | // Move this thread object in the thread himsleft 35 | // Thats necessary to exec the event loop in this thread 36 | moveToThread(this); 37 | } 38 | 39 | SocketThread::~SocketThread() 40 | { 41 | } 42 | 43 | void SocketThread::run() 44 | { 45 | std::cout << tr("connect done in thread : 0x%1").arg(QString::number((unsigned int)QThread::currentThreadId(), 16)).toStdString() << std::endl; 46 | 47 | // Connecting the socket signals here to exec the slots in the new thread 48 | QObject::connect(socket, SIGNAL(frameReceived(QString)), this, SLOT(processMessage(QString))); 49 | QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); 50 | QObject::connect(socket, SIGNAL(pong(quint64)), this, SLOT(processPong(quint64))); 51 | QObject::connect(this, SIGNAL(finished()), this, SLOT(finished()), Qt::DirectConnection); 52 | 53 | // Launch the event loop to exec the slots 54 | exec(); 55 | } 56 | 57 | void SocketThread::finished() 58 | { 59 | this->moveToThread(QCoreApplication::instance()->thread()); 60 | this->deleteLater(); 61 | } 62 | 63 | void SocketThread::processMessage(QString message) 64 | { 65 | // ANY PROCESS HERE IS DONE IN THE SOCKET THREAD ! 66 | 67 | std::cout << tr("thread 0x%1 | %2").arg(QString::number((unsigned int)QThread::currentThreadId(), 16)).arg(message).toStdString() << std::endl; 68 | } 69 | 70 | void SocketThread::sendMessage(QString message) 71 | { 72 | socket->write(message); 73 | } 74 | 75 | void SocketThread::processPong(quint64 elapsedTime) 76 | { 77 | std::cout << tr("ping: %1 ms").arg(elapsedTime).toStdString() << std::endl; 78 | } 79 | 80 | void SocketThread::socketDisconnected() 81 | { 82 | std::cout << tr("Client disconnected, thread finished").toStdString() << std::endl; 83 | 84 | // Prepare the socket to be deleted after last events processed 85 | socket->deleteLater(); 86 | 87 | // finish the thread execution (that quit the event loop launched by exec) 88 | quit(); 89 | } 90 | -------------------------------------------------------------------------------- /QtWebsocket/QTlsServer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include "QTlsServer.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace QtWebsocket 28 | { 29 | 30 | QTlsServer::QTlsServer(QObject* parent, Protocol allowedProtocols) : 31 | QTcpServer(parent), 32 | _allowedProtocols(allowedProtocols) 33 | { 34 | QObject::connect(this, SIGNAL(newConnection()), this, SLOT(test())); 35 | } 36 | 37 | QTlsServer::~QTlsServer() 38 | { 39 | } 40 | 41 | Protocol QTlsServer::allowedProtocols() 42 | { 43 | return _allowedProtocols; 44 | } 45 | 46 | void QTlsServer::test() 47 | { 48 | std::cout << "tcp socket connected, waiting for TLS handshake" << std::endl; 49 | } 50 | 51 | void QTlsServer::displayTlsErrors(const QList& errors) 52 | { 53 | for (int i=0, sz=errors.size(); i(sender()); 63 | emit newTlsConnection(serverSocket); 64 | } 65 | void QTlsServer::incomingConnection(qintptr socketDescriptor) 66 | { 67 | QSslSocket* serverSocket = new QSslSocket; 68 | QObject::connect(serverSocket, SIGNAL(sslErrors(const QList&)), this, SLOT(displayTlsErrors(const QList&))); 69 | 70 | if (serverSocket->setSocketDescriptor(socketDescriptor)) 71 | { 72 | QFile file("server-key.pem"); 73 | if (!file.open(QIODevice::ReadOnly)) 74 | { 75 | std::cout << "can't open key" << "server-key.pem"; 76 | return; 77 | } 78 | QSslKey key(&file, QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey, QByteArray("qtwebsocket-server-key")); 79 | file.close(); 80 | serverSocket->setPrivateKey(key); 81 | 82 | if (!serverSocket->addCaCertificates("ca.pem")) 83 | { 84 | std::cout << "open certificate ca error" << "ca.pem"; 85 | return; 86 | } 87 | 88 | serverSocket->setLocalCertificate("server-crt.pem"); 89 | serverSocket->setPeerVerifyMode(QSslSocket::VerifyNone); 90 | //serverSocket->ignoreSslErrors(); 91 | 92 | QObject::connect(serverSocket, SIGNAL(encrypted()), this, SLOT(tlsSocketEncrypted())); 93 | serverSocket->startServerEncryption(); 94 | } 95 | else 96 | { 97 | serverSocket->deleteLater(); 98 | } 99 | } 100 | 101 | } // namespace QtWebsocket 102 | -------------------------------------------------------------------------------- /Example/ServerThreaded/ServerThreaded.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;cxx;c;def 7 | true 8 | 9 | 10 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 11 | h 12 | true 13 | 14 | 15 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 16 | moc;h;cpp 17 | true 18 | 19 | 20 | {4a37a7fd-b5c6-463f-8524-c5270e35cb4f} 21 | cpp;moc 22 | False 23 | 24 | 25 | {2211e4f7-87f1-425e-bce2-058bfb26e4cc} 26 | cpp;moc 27 | False 28 | 29 | 30 | 31 | 32 | Source Files 33 | 34 | 35 | Source Files 36 | 37 | 38 | Generated Files\Debug 39 | 40 | 41 | Generated Files\Release 42 | 43 | 44 | Source Files 45 | 46 | 47 | Generated Files\Debug 48 | 49 | 50 | Generated Files\Release 51 | 52 | 53 | Generated Files\Debug 54 | 55 | 56 | Generated Files\Release 57 | 58 | 59 | Generated Files\Debug 60 | 61 | 62 | Generated Files\Release 63 | 64 | 65 | 66 | 67 | Header Files 68 | 69 | 70 | Header Files 71 | 72 | 73 | Header Files 74 | 75 | 76 | Header Files 77 | 78 | 79 | -------------------------------------------------------------------------------- /QtWebsocket/QWsServer.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef QWSSERVER_H 21 | #define QWSSERVER_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "QWsSocket.h" 37 | #include "QTlsServer.h" 38 | 39 | #include 40 | 41 | namespace QtWebsocket 42 | { 43 | 44 | class QWsServer : public QObject 45 | { 46 | Q_OBJECT 47 | 48 | public: 49 | // ctor 50 | QWsServer(QObject* parent = 0, Protocol allowedProtocols = Tcp); 51 | // dtor 52 | virtual ~QWsServer(); 53 | 54 | // public functions 55 | void close(); 56 | QString errorString(); 57 | bool hasPendingConnections(); 58 | bool isListening(); 59 | bool listen(const QHostAddress & address = QHostAddress::Any, quint16 port = 0); 60 | int maxPendingConnections(); 61 | virtual QWsSocket* nextPendingConnection(); 62 | QNetworkProxy proxy(); 63 | QHostAddress serverAddress(); 64 | QAbstractSocket::SocketError serverError(); 65 | quint16 serverPort(); 66 | void setMaxPendingConnections(int numConnections); 67 | void setProxy(const QNetworkProxy & networkProxy); 68 | bool setSocketDescriptor(int socketDescriptor); 69 | int socketDescriptor(); 70 | bool waitForNewConnection(int msec = 0, bool* timedOut = 0); 71 | Protocol allowedProtocols(); 72 | 73 | signals: 74 | void newConnection(); 75 | 76 | protected: 77 | // protected functions 78 | void addPendingConnection(QWsSocket* socket); 79 | virtual void incomingConnection(int socketDescriptor); 80 | 81 | private slots: 82 | // private slots 83 | void newTcpConnection(); 84 | void newTlsConnection(QSslSocket* serverSocket); 85 | void closeTcpConnection(); 86 | void dataReceived(); 87 | void tcpSocketDisconnected(); 88 | 89 | private: 90 | // private attributes 91 | QTcpServer* tcpServer; 92 | QTlsServer tlsServer; 93 | QQueue pendingConnections; 94 | QHash handshakeBuffer; 95 | 96 | bool useSsl; 97 | QSslKey sslKey; 98 | QSslCertificate sslCertificate; 99 | 100 | public: 101 | // public static functions 102 | static QString composeOpeningHandshakeResponseV0(QByteArray accept, QString origin, QString hostAddress, QString hostPort, QString resourceName, QString protocol = ""); 103 | static QString composeOpeningHandshakeResponseV4(QByteArray accept, QByteArray nonce, QString protocol = "", QString extensions = ""); 104 | static QString composeOpeningHandshakeResponseV6(QByteArray accept, QString protocol = "", QString extensions = ""); 105 | static QString composeBadRequestResponse(QList versions = QList()); 106 | }; 107 | 108 | } // namespace QtWebsocket 109 | 110 | #endif // QWSSERVER_H 111 | -------------------------------------------------------------------------------- /Example/Client/Client.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | Client 4 | 5 | 6 | 7 | 0 8 | 0 9 | 480 10 | 480 11 | 12 | 13 | 14 | 15 | 0 16 | 0 17 | 18 | 19 | 20 | 21 | 480 22 | 480 23 | 24 | 25 | 26 | 27 | 480 28 | 480 29 | 30 | 31 | 32 | QtWebsocket Client Example 33 | 34 | 35 | 36 | 37 | 120 38 | 440 39 | 271 40 | 27 41 | 42 | 43 | 44 | 45 | 46 | 47 | message 48 | 49 | 50 | 51 | 52 | 53 | 400 54 | 440 55 | 71 56 | 27 57 | 58 | 59 | 60 | Send 61 | 62 | 63 | 64 | 65 | 66 | 10 67 | 50 68 | 461 69 | 381 70 | 71 | 72 | 73 | 74 | 75 | 76 | 10 77 | 440 78 | 101 79 | 27 80 | 81 | 82 | 83 | 84 | 85 | 86 | pseudo 87 | 88 | 89 | 90 | 91 | 92 | 380 93 | 10 94 | 91 95 | 31 96 | 97 | 98 | 99 | Unknow 100 | 101 | 102 | 103 | 104 | 105 | 10 106 | 10 107 | 91 108 | 31 109 | 110 | 111 | 112 | Connect 113 | 114 | 115 | 116 | 117 | 118 | 290 119 | 10 120 | 91 121 | 31 122 | 123 | 124 | 125 | Socket state: 126 | 127 | 128 | 129 | 130 | 131 | 110 132 | 10 133 | 91 134 | 31 135 | 136 | 137 | 138 | Disconnect 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /Example/Client/Client.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;cxx;c;def 7 | true 8 | 9 | 10 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 11 | h 12 | true 13 | 14 | 15 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 16 | moc;h;cpp 17 | true 18 | 19 | 20 | {32533c6a-415e-42dc-b999-edddd7099c8b} 21 | cpp;moc 22 | False 23 | 24 | 25 | {d2f2f93b-1a36-4865-9240-f5417989b190} 26 | cpp;moc 27 | False 28 | 29 | 30 | {10f93dc1-3ba0-4185-a42b-8595fa3f43ae} 31 | cpp;moc 32 | False 33 | 34 | 35 | {99349809-55BA-4b9d-BF79-8FDBB0286EB3} 36 | ui 37 | true 38 | 39 | 40 | 41 | 42 | Source Files 43 | 44 | 45 | Generated Files\Debug 46 | 47 | 48 | Generated Files\Release 49 | 50 | 51 | Generated Files\Template 52 | 53 | 54 | Source Files 55 | 56 | 57 | Generated Files\Debug 58 | 59 | 60 | Generated Files\Release 61 | 62 | 63 | Generated Files\Template 64 | 65 | 66 | Generated Files\Debug 67 | 68 | 69 | Generated Files\Release 70 | 71 | 72 | Generated Files\Template 73 | 74 | 75 | 76 | 77 | Header Files 78 | 79 | 80 | Header Files 81 | 82 | 83 | Header Files 84 | 85 | 86 | Form Files 87 | 88 | 89 | 90 | 91 | Generated Files 92 | 93 | 94 | -------------------------------------------------------------------------------- /QtWebsocket/QtWebsocket.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;cxx;c;def 7 | true 8 | 9 | 10 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 11 | h 12 | true 13 | 14 | 15 | {71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11} 16 | moc;h;cpp 17 | true 18 | 19 | 20 | {d5fba284-38bf-4f0f-bc51-e99b26003c7f} 21 | cpp;moc 22 | False 23 | 24 | 25 | {74aad3d0-89fc-4bbb-ab82-8b3d0b6b9d52} 26 | cpp;moc 27 | False 28 | 29 | 30 | {77607f95-99fe-467f-8658-42c201b984af} 31 | cpp;moc 32 | False 33 | 34 | 35 | 36 | 37 | Source Files 38 | 39 | 40 | Generated Files\Debug 41 | 42 | 43 | Generated Files\Release 44 | 45 | 46 | Generated Files\Template 47 | 48 | 49 | Source Files 50 | 51 | 52 | Generated Files\Debug 53 | 54 | 55 | Generated Files\Release 56 | 57 | 58 | Generated Files\Template 59 | 60 | 61 | Source Files 62 | 63 | 64 | Source Files 65 | 66 | 67 | Generated Files\Debug 68 | 69 | 70 | Generated Files\Release 71 | 72 | 73 | Generated Files\Template 74 | 75 | 76 | Source Files 77 | 78 | 79 | Source Files 80 | 81 | 82 | 83 | 84 | Header Files 85 | 86 | 87 | Header Files 88 | 89 | 90 | Header Files 91 | 92 | 93 | Header Files 94 | 95 | 96 | 97 | 98 | Header Files 99 | 100 | 101 | Header Files 102 | 103 | 104 | Header Files 105 | 106 | 107 | -------------------------------------------------------------------------------- /Example/Client/Client.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include "Client.h" 21 | #include "ui_Client.h" 22 | #include 23 | 24 | Client::Client(QWidget *parent) : 25 | QWidget(parent), 26 | ui(new Ui::Client) 27 | { 28 | ui->setupUi(this); 29 | 30 | defaultPseudo = QString("user%1").arg(qrand() % 9000 + 1000); 31 | ui->pseudoLineEdit->setPlaceholderText(defaultPseudo); 32 | 33 | wsSocket = new QtWebsocket::QWsSocket(this, NULL, QtWebsocket::WS_V13); 34 | 35 | socketStateChanged(wsSocket->state()); 36 | 37 | QObject::connect(ui->sendButton, SIGNAL(pressed()), this, SLOT(sendMessage())); 38 | QObject::connect(ui->textLineEdit, SIGNAL(returnPressed()), this, SLOT(sendMessage())); 39 | QObject::connect(ui->connectButton, SIGNAL(pressed()), this, SLOT(connectSocket())); 40 | QObject::connect(ui->disconnectButton, SIGNAL(pressed()), this, SLOT(disconnectSocket())); 41 | QObject::connect(wsSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); 42 | QObject::connect(wsSocket, SIGNAL(frameReceived(QString)), this, SLOT(displayMessage(QString))); 43 | QObject::connect(wsSocket, SIGNAL(connected()), this, SLOT(socketConnected())); 44 | QObject::connect(wsSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); 45 | QObject::connect(wsSocket, SIGNAL(sslErrors(const QList&)), this, SLOT(displaySslErrors(const QList&))); 46 | } 47 | 48 | Client::~Client() 49 | { 50 | delete ui; 51 | } 52 | 53 | void Client::sendMessage() 54 | { 55 | QString pseudo = ui->pseudoLineEdit->text(); 56 | pseudo = (pseudo.isEmpty() ? defaultPseudo : pseudo); 57 | 58 | QString message = ui->textLineEdit->text(); 59 | message = (message.isEmpty() ? QLatin1String("echo") : message); 60 | 61 | ui->textLineEdit->clear(); 62 | 63 | wsSocket->write(QString("%1: %2").arg(pseudo).arg(message)); 64 | } 65 | 66 | void Client::displayMessage(QString message) 67 | { 68 | ui->chatTextEdit->append(message); 69 | } 70 | 71 | void Client::displaySslErrors(const QList& errors) 72 | { 73 | for (int i=0, sz=errors.size(); iconnectToHost(ip.toUtf8(), port); 101 | } 102 | } 103 | 104 | void Client::disconnectSocket() 105 | { 106 | wsSocket->disconnectFromHost(); 107 | } 108 | 109 | void Client::socketConnected() 110 | { 111 | displayMessage(tr("CONNECTED")); 112 | } 113 | 114 | void Client::socketDisconnected() 115 | { 116 | displayMessage(tr("DISCONNECTED")); 117 | } 118 | 119 | void Client::socketStateChanged(QAbstractSocket::SocketState socketState) 120 | { 121 | switch (socketState) 122 | { 123 | case QAbstractSocket::UnconnectedState: 124 | ui->socketStateLabel->setText(tr("Unconnected")); 125 | break; 126 | case QAbstractSocket::HostLookupState: 127 | ui->socketStateLabel->setText(tr("HostLookup")); 128 | break; 129 | case QAbstractSocket::ConnectingState: 130 | ui->socketStateLabel->setText(tr("Connecting")); 131 | break; 132 | case QAbstractSocket::ConnectedState: 133 | ui->socketStateLabel->setText("Connected"); 134 | break; 135 | case QAbstractSocket::BoundState: 136 | ui->socketStateLabel->setText(tr("Bound")); 137 | break; 138 | case QAbstractSocket::ClosingState: 139 | ui->socketStateLabel->setText(tr("Closing")); 140 | break; 141 | case QAbstractSocket::ListeningState: 142 | ui->socketStateLabel->setText(tr("Listening")); 143 | break; 144 | default: 145 | ui->socketStateLabel->setText(tr("Unknown")); 146 | break; 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /QtWebsocket/QWsSocket.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #ifndef QWSSOCKET_H 21 | #define QWSSOCKET_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include "WsEnums.h" 33 | #include "QWsHandshake.h" 34 | #include "QWsFrame.h" 35 | 36 | namespace QtWebsocket 37 | { 38 | 39 | class QWsSocket : public QAbstractSocket 40 | { 41 | Q_OBJECT 42 | 43 | friend class QWsServer; 44 | 45 | public: 46 | // ctor 47 | QWsSocket(QObject* parent = NULL, QTcpSocket* socket = NULL, EWebsocketVersion ws_v = WS_V13); 48 | // dtor 49 | virtual ~QWsSocket(); 50 | 51 | // Public methods 52 | EWebsocketVersion version(); 53 | QString resourceName(); 54 | QString host(); 55 | QHostAddress hostAddress(); 56 | int hostPort(); 57 | QString origin(); 58 | QString protocol(); 59 | QString extensions(); 60 | 61 | void setResourceName(QString rn); 62 | void setHost(QString h); 63 | void setHostAddress(QString ha); 64 | void setHostPort(int hp); 65 | void setOrigin(QString o); 66 | void setProtocol(QString p); 67 | void setExtensions(QString e); 68 | 69 | qint64 write(const QString& string); // write data as text 70 | qint64 write(const QByteArray & byteArray); // write data as binary 71 | 72 | public slots: 73 | void connectToHost(const QString & hostName, quint16 port = 80, OpenMode mode = ReadWrite); 74 | void connectToHost(const QHostAddress & address, quint16 port = 80, OpenMode mode = ReadWrite); 75 | void disconnectFromHost(); 76 | void abort(QString reason = QString()); 77 | void ping(); 78 | 79 | signals: 80 | void frameReceived(QString frame); 81 | void frameReceived(QByteArray frame); 82 | void pong(quint64 elapsedTime); 83 | void encrypted(); 84 | void sslErrors(const QList& errors); 85 | 86 | protected: 87 | qint64 writeFrames (const QList& framesList); 88 | qint64 writeFrame (const QByteArray& byteArray); 89 | inline qint64 internalWrite(const QByteArray& string, bool asBinary); 90 | void initTcpSocket(); 91 | 92 | protected slots: 93 | virtual void close(CloseStatusCode closeStatusCode = NoCloseStatusCode, QString reason = QString()); 94 | void processDataV0(); 95 | void processDataV4(); 96 | void processHandshake(); 97 | void processTcpStateChanged(QAbstractSocket::SocketState socketState); 98 | void processTcpError(QAbstractSocket::SocketError err); 99 | void startHandshake(); 100 | void onEncrypted(); 101 | 102 | private: 103 | 104 | // private vars 105 | QTcpSocket* tcpSocket; 106 | QByteArray currentFrame; 107 | QTime pingTimer; 108 | 109 | WsMode _wsMode; 110 | 111 | QWsFrame* _currentFrame; 112 | QByteArray currentData; 113 | Opcode currentDataOpcode; 114 | 115 | /*! 116 | * True if we are waiting for a final data fragment. 117 | */ 118 | bool continuation; 119 | 120 | EWebsocketVersion _version; 121 | QString _resourceName; 122 | QString _hostName; 123 | QString _host; 124 | QHostAddress _hostAddress; 125 | quint16 _hostPort; 126 | QString _origin; 127 | QString _protocol; 128 | QString _extensions; 129 | 130 | bool closingHandshakeSent; 131 | bool closingHandshakeReceived; 132 | 133 | Opcode currentOpcode; 134 | CloseStatusCode closeStatusCode; 135 | 136 | static const QString regExpAcceptStr; 137 | static const QString regExpUpgradeStr; 138 | static const QString regExpConnectionStr; 139 | static const QString connectionRefusedStr; 140 | QString handshakeResponse; 141 | QByteArray key; 142 | QByteArray key1; 143 | QByteArray key2; 144 | QByteArray key3; 145 | QByteArray accept; 146 | 147 | bool _secured; 148 | 149 | /*! 150 | * Sends pong response with `applicationData` appended. 151 | */ 152 | void handlePing(QByteArray applicationData = QByteArray()); 153 | 154 | /*! 155 | * Processes the joined payload of the previous frames. 156 | * 157 | * Called if the final and valid non-control frame has been received. 158 | */ 159 | void handleData(); 160 | 161 | /*! 162 | * Processes the current control frame. 163 | * 164 | * Responds to ping and pong or closes connection according to 165 | * `currentOpcode`. Called if a complete and valid control frame has been 166 | * received. 167 | */ 168 | void handleControlFrame(); 169 | 170 | public: 171 | // Static functions 172 | static QByteArray generateNonce(); 173 | static QByteArray generateKey1or2(); 174 | static QByteArray generateKey3(); 175 | static QByteArray generateMaskingKey(); 176 | static QByteArray generateMaskingKeyV4(QByteArray key, QByteArray nonce); 177 | static QByteArray computeAcceptV0(QByteArray key1, QByteArray key2, QByteArray thirdPart); 178 | static QByteArray computeAcceptV4(QByteArray key); 179 | static QByteArray mask(const QByteArray& data, QByteArray& maskingKey); 180 | static QList composeFrames(QByteArray data, Opcode opcode = OpText, QByteArray maskingKey = QByteArray(), int maxFrameBytes = 0); 181 | static QByteArray composeHeader(bool end, Opcode opcode, quint64 payloadLength, QByteArray maskingKey = QByteArray()); 182 | static QString composeOpeningHandShakeV0(QString resourceName, QString host, QByteArray key1, QByteArray key2, QByteArray key3, QString origin = "", QString protocol = "", QString extensions = ""); 183 | static QString composeOpeningHandShakeV13(QString resourceName, QString host, QByteArray key, QString origin = "", QString protocol = "", QString extensions = ""); 184 | 185 | /*! 186 | * Encapsulates `applicationData` in a single Frame. 187 | * 188 | * The frame size is deduced from `applicationData.size()` and there are no 189 | * checks performed on it. 190 | */ 191 | static QByteArray composeFrame(QByteArray applicationData, Opcode opcode, bool final = true); 192 | 193 | // static vars 194 | static const int maxBytesPerFrame = 1400; 195 | static const QLatin1String emptyLine; 196 | static QRegExp regExpIPv4; 197 | static QRegExp regExpHttpRequest; 198 | static QRegExp regExpHttpResponse; 199 | static QRegExp regExpHttpField; 200 | }; 201 | 202 | } // namespace QtWebsocket 203 | 204 | #endif // QWSSOCKET_H 205 | -------------------------------------------------------------------------------- /QtWebsocket/QWsHandshake.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include "QWsHandshake.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "QWsSocket.h" 28 | 29 | namespace QtWebsocket 30 | { 31 | 32 | QWsHandshake::QWsHandshake(WsMode wsMode) : 33 | _wsMode(wsMode), 34 | readStarted(false), 35 | complete(false), 36 | httpRequestValid(false) 37 | { 38 | } 39 | 40 | QWsHandshake::~QWsHandshake() 41 | { 42 | } 43 | 44 | // Read the handshake 45 | // return true if the header is completely readed 46 | // return false if some lines are missing 47 | bool QWsHandshake::read(QTcpSocket* tcpSocket) 48 | { 49 | QWsSocket::regExpHttpField.setMinimal(true); 50 | 51 | while (tcpSocket->canReadLine()) 52 | { 53 | // read a line 54 | QString line = QString::fromUtf8(tcpSocket->readLine()); 55 | rawHandshake += line; 56 | // check length of line 57 | if (line.length() > 1000) // incase of garbage input 58 | { 59 | return false; 60 | } 61 | // start of handshake 62 | if (!readStarted) 63 | { 64 | readStarted = true; 65 | httpRequestValid = true; 66 | if (_wsMode == WsClientMode) 67 | { 68 | // CHECK HTTP GET REQUEST 69 | QWsSocket::regExpHttpRequest.setMinimal(true); 70 | if (QWsSocket::regExpHttpRequest.indexIn(line) == -1) 71 | { 72 | httpRequestValid = false; 73 | return false; 74 | } 75 | // Check HTTP GET REQUEST version 76 | httpRequestVersion = QWsSocket::regExpHttpRequest.cap(2); 77 | if (httpRequestVersion.toFloat() < 1.1) 78 | { 79 | httpRequestValid = false; 80 | return false; 81 | } 82 | // get Resource name 83 | resourceName = QWsSocket::regExpHttpRequest.cap(1); 84 | continue; 85 | } 86 | else // serverSide 87 | { 88 | // check HTTP code 89 | QWsSocket::regExpHttpResponse.setMinimal(true); 90 | if (QWsSocket::regExpHttpResponse.indexIn(line) == -1) 91 | { 92 | httpRequestValid = false; 93 | return false; 94 | } 95 | quint16 httpCode = QWsSocket::regExpHttpResponse.cap(1).toUShort(); 96 | QString httpMessage = QWsSocket::regExpHttpResponse.cap(2); 97 | if (httpCode != 101) 98 | { 99 | errorString = line; 100 | httpRequestValid = false; 101 | return false; 102 | } 103 | continue; 104 | } 105 | } 106 | // end of handshake 107 | if (line == QWsSocket::emptyLine) 108 | { 109 | complete = true; 110 | break; 111 | } 112 | // check field 113 | if (QWsSocket::regExpHttpField.indexIn(line) == -1) 114 | { 115 | // Bad http field 116 | continue; 117 | } 118 | // Extract field 119 | fields.insert(QWsSocket::regExpHttpField.cap(1), QWsSocket::regExpHttpField.cap(2)); 120 | } 121 | if ((!complete) && (fields.size() > 1000)) // incase of garbage input 122 | { 123 | return false; 124 | } 125 | // read key3 if existing (for first websocket version) 126 | if (_wsMode == WsClientMode && tcpSocket->bytesAvailable() == 8 && fields.contains(QLatin1String("Sec-WebSocket-Key1")) && fields.contains(QLatin1String("Sec-WebSocket-Key2"))) 127 | { 128 | key3 = tcpSocket->read(8); 129 | rawHandshake += QString::fromUtf8(key3); 130 | } 131 | else if (_wsMode == WsServerMode && tcpSocket->bytesAvailable() == 16) 132 | { 133 | accept = tcpSocket->read(16); 134 | rawHandshake += QString::fromUtf8(accept); 135 | } 136 | 137 | return true; 138 | } 139 | 140 | bool QWsHandshake::isValid() 141 | { 142 | // commonPart 143 | if (!isValidCommonPart()) 144 | { 145 | return false; 146 | } 147 | 148 | // clientSide 149 | if (_wsMode == WsClientMode) 150 | { 151 | return isValidClientPart(); 152 | } 153 | else // serverSide 154 | { 155 | return isValidServerPart(); 156 | } 157 | } 158 | 159 | bool QWsHandshake::isValidCommonPart() 160 | { 161 | if (!httpRequestValid) 162 | { 163 | return false; 164 | } 165 | 166 | //MANDATORY 167 | // Upgrade 168 | if ((!fields.contains(QLatin1String("Upgrade"))) || (fields.value(QLatin1String("Upgrade")).compare(QLatin1String("websocket"), Qt::CaseInsensitive))) 169 | { 170 | return false; 171 | } 172 | 173 | // Connection 174 | if ((!fields.contains(QLatin1String("Connection"))) || (!fields.value(QLatin1String("Connection")).split(QRegExp("\\s?,\\s?")).contains(QLatin1String("Upgrade"), Qt::CaseInsensitive))) 175 | { 176 | return false; 177 | } 178 | 179 | // OPTIONAL 180 | // Protocol 181 | if (fields.contains(QLatin1String("Sec-WebSocket-Protocol"))) 182 | { 183 | protocol = fields.value(QLatin1String("Sec-WebSocket-Protocol")); 184 | } 185 | 186 | // Extensions 187 | if (fields.contains(QLatin1String("Sec-WebSocket-Extensions"))) 188 | { 189 | extensions = fields.value(QLatin1String("Sec-WebSocket-Extensions")); 190 | } 191 | 192 | return true; 193 | } 194 | 195 | bool QWsHandshake::isValidClientPart() 196 | { 197 | // MANDATORY 198 | // Host (address & port) 199 | if (fields.contains(QLatin1String("Host"))) 200 | { 201 | host = fields.value(QLatin1String("Host")); 202 | if (host.count(QLatin1Char(':')) <= 1) 203 | { 204 | QStringList splitted = host.split(QLatin1Char(':')); 205 | hostAddress = splitted.first(); 206 | if (splitted.size() == 2) 207 | { 208 | hostPort = splitted.last(); 209 | } 210 | } 211 | else 212 | { 213 | return false; 214 | } 215 | } 216 | else 217 | { 218 | return false; 219 | } 220 | 221 | // Version and keys 222 | if (fields.contains(QLatin1String("Sec-WebSocket-Version"))) 223 | { 224 | if (fields.contains(QLatin1String("Sec-WebSocket-Key"))) 225 | { 226 | version = ((EWebsocketVersion)(fields.value(QLatin1String("Sec-WebSocket-Version")).toUInt())); 227 | key = fields.value(QLatin1String("Sec-WebSocket-Key")).toUtf8(); 228 | } 229 | else 230 | { 231 | return false; 232 | } 233 | } 234 | else if (fields.contains(QLatin1String("Sec-WebSocket-Key1")) && fields.contains(QLatin1String("Sec-WebSocket-Key2")) && !key3.isEmpty()) 235 | { 236 | version = WS_V0; 237 | key1 = fields.value(QLatin1String("Sec-WebSocket-Key1")).toUtf8(); 238 | key2 = fields.value(QLatin1String("Sec-WebSocket-Key2")).toUtf8(); 239 | } 240 | else 241 | { 242 | version = WS_VUnknow; 243 | return false; 244 | } 245 | 246 | // OPTIONAL 247 | // Origin 248 | if (fields.contains(QLatin1String("Origin"))) 249 | { 250 | origin = fields.value(QLatin1String("Origin")); 251 | } 252 | else if (fields.contains(QLatin1String("Sec-WebSocket-Origin"))) 253 | { 254 | origin = fields.value(QLatin1String("Sec-WebSocket-Origin")); 255 | } 256 | 257 | return true; 258 | } 259 | 260 | bool QWsHandshake::isValidServerPart() 261 | { 262 | // accept 263 | if (fields.contains(QLatin1String("Sec-WebSocket-Accept"))) 264 | { 265 | accept = fields.value(QLatin1String("Sec-WebSocket-Accept")).toUtf8(); 266 | } 267 | else if (accept.size() == 0) // for protocol version 0, accept 268 | { 269 | return false; 270 | } 271 | 272 | return true; 273 | } 274 | 275 | } // namespace QtWebsocket 276 | -------------------------------------------------------------------------------- /Example/ClientJS/clientExample.html: -------------------------------------------------------------------------------- 1 | 19 | 20 | 21 | 22 | 23 | Websocket client test 24 | 25 | 26 | 27 |

28 |
29 | TLS secured connection
30 | 31 | 32 |

websocket state: null

33 |

34 |

35 | 36 |

37 |

38 | 39 | 40 | 41 |

42 | 43 | 261 | 262 | 263 | -------------------------------------------------------------------------------- /lgpl-3.0.txt: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /QtWebsocket/QWsServer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2013 Antoine Lafarge qtwebsocket@gmail.com 3 | 4 | This file is part of QtWebsocket. 5 | 6 | QtWebsocket is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU Lesser General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | any later version. 10 | 11 | QtWebsocket is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | You should have received a copy of the GNU Lesser General Public License 17 | along with QtWebsocket. If not, see . 18 | */ 19 | 20 | #include "QWsServer.h" 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | namespace QtWebsocket 28 | { 29 | 30 | QWsServer::QWsServer(QObject* parent, Protocol allowedProtocols) 31 | : QObject(parent), 32 | tcpServer(new QTcpServer(this)), 33 | tlsServer(this, allowedProtocols) 34 | { 35 | if (allowedProtocols & Tls) 36 | { 37 | tcpServer = &tlsServer; 38 | QObject::connect(tcpServer, SIGNAL(newTlsConnection(QSslSocket*)), this, SLOT(newTlsConnection(QSslSocket*))); 39 | } 40 | else 41 | { 42 | QObject::connect(tcpServer, SIGNAL(newConnection()), this, SLOT(newTcpConnection())); 43 | } 44 | } 45 | 46 | QWsServer::~QWsServer() 47 | { 48 | tcpServer->deleteLater(); 49 | } 50 | 51 | bool QWsServer::listen(const QHostAddress & address, quint16 port) 52 | { 53 | return tcpServer->listen(address, port); 54 | } 55 | 56 | void QWsServer::close() 57 | { 58 | tcpServer->close(); 59 | } 60 | 61 | Protocol QWsServer::allowedProtocols() 62 | { 63 | return tlsServer.allowedProtocols(); 64 | } 65 | 66 | QAbstractSocket::SocketError QWsServer::serverError() 67 | { 68 | return tcpServer->serverError(); 69 | } 70 | 71 | QString QWsServer::errorString() 72 | { 73 | return tcpServer->errorString(); 74 | } 75 | 76 | void QWsServer::newTcpConnection() 77 | { 78 | QTcpSocket* tcpSocket = tcpServer->nextPendingConnection(); 79 | if (tcpSocket == NULL) 80 | { 81 | return; 82 | } 83 | QObject::connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(dataReceived())); 84 | QObject::connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(tcpSocketDisconnected())); 85 | handshakeBuffer.insert(tcpSocket, new QWsHandshake(WsClientMode)); 86 | } 87 | 88 | void QWsServer::newTlsConnection(QSslSocket* serverSocket) 89 | { 90 | if (serverSocket == NULL) 91 | { 92 | return; 93 | } 94 | QObject::connect(serverSocket, SIGNAL(readyRead()), this, SLOT(dataReceived())); 95 | QObject::connect(serverSocket, SIGNAL(disconnected()), this, SLOT(tcpSocketDisconnected())); 96 | handshakeBuffer.insert(serverSocket, new QWsHandshake(WsClientMode)); 97 | } 98 | 99 | void QWsServer::tcpSocketDisconnected() 100 | { 101 | QTcpSocket* tcpSocket = qobject_cast(sender()); 102 | if (tcpSocket == NULL) 103 | { 104 | return; 105 | } 106 | 107 | QWsHandshake* handshake = handshakeBuffer.take(tcpSocket); 108 | delete handshake; 109 | tcpSocket->deleteLater(); 110 | } 111 | 112 | void QWsServer::closeTcpConnection() 113 | { 114 | QTcpSocket* tcpSocket = qobject_cast(sender()); 115 | if (tcpSocket == NULL) 116 | { 117 | return; 118 | } 119 | 120 | tcpSocket->close(); 121 | } 122 | 123 | static void showErrorAndClose(QTcpSocket* tcpSocket) 124 | { 125 | // Send bad request response 126 | QString response = QWsServer::composeBadRequestResponse(QList() << WS_V6 << WS_V7 << WS_V8 << WS_V13); 127 | tcpSocket->write(response.toUtf8()); 128 | tcpSocket->flush(); 129 | tcpSocket->close(); 130 | } 131 | 132 | void QWsServer::dataReceived() 133 | { 134 | QTcpSocket* tcpSocket = qobject_cast(sender()); 135 | if (tcpSocket == NULL) 136 | { 137 | return; 138 | } 139 | 140 | QWsHandshake& handshake = *(handshakeBuffer.value(tcpSocket)); 141 | 142 | if (handshake.read(tcpSocket) == false) 143 | { 144 | showErrorAndClose(tcpSocket); 145 | return; 146 | } 147 | 148 | // handshake complete 149 | if (!handshake.readStarted || !handshake.complete) 150 | { 151 | if (handshake.readStarted && !handshake.httpRequestValid) 152 | { 153 | showErrorAndClose(tcpSocket); 154 | } 155 | return; 156 | } 157 | 158 | // If the mandatory fields are not specified, we abord the connection to the Websocket server 159 | // hansake valid 160 | if (!handshake.isValid()) 161 | { 162 | showErrorAndClose(tcpSocket); 163 | return; 164 | } 165 | 166 | // Handshake fully parsed 167 | QObject::disconnect(tcpSocket, SIGNAL(readyRead()), this, SLOT(dataReceived())); 168 | QObject::disconnect(tcpSocket, SIGNAL(disconnected()), this, SLOT(tcpSocketDisconnected())); 169 | 170 | // Compose opening handshake response 171 | QByteArray handshakeResponse; 172 | 173 | if (handshake.version >= WS_V6) 174 | { 175 | QByteArray accept = QWsSocket::computeAcceptV4(handshake.key); 176 | handshakeResponse = QWsServer::composeOpeningHandshakeResponseV6(accept, handshake.protocol).toUtf8(); 177 | } 178 | else if (handshake.version >= WS_V4) 179 | { 180 | QByteArray accept = QWsSocket::computeAcceptV4(handshake.key); 181 | QByteArray nonce = QWsSocket::generateNonce(); 182 | handshakeResponse = QWsServer::composeOpeningHandshakeResponseV4(accept, nonce, handshake.protocol).toUtf8(); 183 | } 184 | else // version WS_V0 185 | { 186 | QByteArray accept = QWsSocket::computeAcceptV0(handshake.key1, handshake.key2, handshake.key3); 187 | // safari 5.1.7 don't accept the utf8 charset here... 188 | handshakeResponse = QWsServer::composeOpeningHandshakeResponseV0(accept, handshake.origin, handshake.hostAddress, handshake.hostPort, handshake.resourceName , handshake.protocol).toLatin1(); 189 | } 190 | 191 | // Send opening handshake response 192 | tcpSocket->write(handshakeResponse); 193 | tcpSocket->flush(); 194 | 195 | QWsSocket* wsSocket = new QWsSocket(this, tcpSocket, handshake.version); 196 | wsSocket->setResourceName(handshake.resourceName); 197 | wsSocket->setHost(handshake.host); 198 | wsSocket->setHostAddress(handshake.hostAddress); 199 | wsSocket->setHostPort(handshake.hostPort.toUInt()); 200 | wsSocket->setOrigin(handshake.origin); 201 | wsSocket->setProtocol(handshake.protocol); 202 | wsSocket->setExtensions(handshake.extensions); 203 | wsSocket->_wsMode = WsServerMode; 204 | 205 | QWsHandshake* hsTmp = handshakeBuffer.take(tcpSocket); 206 | delete hsTmp; 207 | 208 | // CAN'T DO THAT WITHOUT DISCONNECTING THE QTcpSocket 209 | //int socketDescriptor = tcpSocket->socketDescriptor(); 210 | //incomingConnection(socketDescriptor); 211 | // USE THIS INSTEAD 212 | addPendingConnection(wsSocket); 213 | emit newConnection(); 214 | } 215 | 216 | void QWsServer::incomingConnection(int socketDescriptor) 217 | { 218 | QTcpSocket* tcpSocket = new QTcpSocket(tcpServer); 219 | tcpSocket->setSocketDescriptor(socketDescriptor, QAbstractSocket::ConnectedState); 220 | QWsSocket* wsSocket = new QWsSocket(this, tcpSocket); 221 | 222 | addPendingConnection(wsSocket); 223 | emit newConnection(); 224 | } 225 | 226 | void QWsServer::addPendingConnection(QWsSocket* socket) 227 | { 228 | if (pendingConnections.size() < maxPendingConnections()) 229 | { 230 | pendingConnections.enqueue(socket); 231 | } 232 | } 233 | 234 | QWsSocket* QWsServer::nextPendingConnection() 235 | { 236 | return pendingConnections.dequeue(); 237 | } 238 | 239 | bool QWsServer::hasPendingConnections() 240 | { 241 | if (pendingConnections.size() > 0) 242 | { 243 | return true; 244 | } 245 | return false; 246 | } 247 | 248 | int QWsServer::maxPendingConnections() 249 | { 250 | return tcpServer->maxPendingConnections(); 251 | } 252 | 253 | bool QWsServer::isListening() 254 | { 255 | return tcpServer->isListening(); 256 | } 257 | 258 | QNetworkProxy QWsServer::proxy() 259 | { 260 | return tcpServer->proxy(); 261 | } 262 | 263 | QHostAddress QWsServer::serverAddress() 264 | { 265 | return tcpServer->serverAddress(); 266 | } 267 | 268 | quint16 QWsServer::serverPort() 269 | { 270 | return tcpServer->serverPort(); 271 | } 272 | 273 | void QWsServer::setMaxPendingConnections(int numConnections) 274 | { 275 | tcpServer->setMaxPendingConnections(numConnections); 276 | } 277 | 278 | void QWsServer::setProxy(const QNetworkProxy & networkProxy) 279 | { 280 | tcpServer->setProxy(networkProxy); 281 | } 282 | 283 | bool QWsServer::setSocketDescriptor(int socketDescriptor) 284 | { 285 | return tcpServer->setSocketDescriptor(socketDescriptor); 286 | } 287 | 288 | int QWsServer::socketDescriptor() 289 | { 290 | return tcpServer->socketDescriptor(); 291 | } 292 | 293 | bool QWsServer::waitForNewConnection(int msec, bool* timedOut) 294 | { 295 | return tcpServer->waitForNewConnection(msec, timedOut); 296 | } 297 | 298 | QString QWsServer::composeOpeningHandshakeResponseV0(QByteArray accept, QString origin, QString hostAddress, QString hostPort, QString resourceName, QString protocol) 299 | { 300 | QString response; 301 | response += QLatin1String("HTTP/1.1 101 WebSocket Protocol Handshake\r\n"); 302 | response += QLatin1String("Upgrade: Websocket\r\n"); 303 | response += QLatin1String("Connection: Upgrade\r\n"); 304 | response += QString("Sec-WebSocket-Origin: %1\r\n").arg(origin); 305 | if (!hostAddress.startsWith("ws://", Qt::CaseInsensitive)) 306 | { 307 | hostAddress.prepend(QLatin1String("ws://")); 308 | } 309 | if (!hostPort.isEmpty()) 310 | { 311 | hostPort.prepend(QLatin1Char(':')); 312 | } 313 | response += QString("Sec-WebSocket-Location: %1%2%3\r\n").arg(hostAddress).arg(hostPort).arg(resourceName); 314 | if (!protocol.isEmpty()) 315 | { 316 | response += QString("Sec-WebSocket-Protocol: %1\r\n").arg(protocol); 317 | } 318 | response += QLatin1String("\r\n"); 319 | response += QLatin1String(accept); 320 | 321 | return response; 322 | } 323 | 324 | QString QWsServer::composeOpeningHandshakeResponseV4(QByteArray accept, QByteArray nonce, QString protocol, QString extensions) 325 | { 326 | QString response; 327 | response += QLatin1String("HTTP/1.1 101 WebSocket Protocol Handshake\r\n"); 328 | response += QLatin1String("Upgrade: websocket\r\n"); 329 | response += QLatin1String("Connection: Upgrade\r\n"); 330 | response += QString("Sec-WebSocket-Accept: %1\r\n").arg(QLatin1String(accept)); 331 | response += QString("Sec-WebSocket-Nonce: %1\r\n").arg(QLatin1String(nonce)); 332 | if (!protocol.isEmpty()) 333 | { 334 | response += QString("Sec-WebSocket-Protocol: %1\r\n").arg(protocol); 335 | } 336 | if (!extensions.isEmpty()) 337 | { 338 | response += QString("Sec-WebSocket-Extensions: %1\r\n").arg(extensions); 339 | } 340 | response += QLatin1String("\r\n"); 341 | return response; 342 | } 343 | 344 | QString QWsServer::composeOpeningHandshakeResponseV6(QByteArray accept, QString protocol, QString extensions) 345 | { 346 | QString response; 347 | response += QLatin1String("HTTP/1.1 101 WebSocket Protocol Handshake\r\n"); 348 | response += QLatin1String("Upgrade: websocket\r\n"); 349 | response += QLatin1String("Connection: Upgrade\r\n"); 350 | response += QString("Sec-WebSocket-Accept: %1\r\n").arg(QLatin1String(accept)); 351 | if (!protocol.isEmpty()) 352 | { 353 | response += QString("Sec-WebSocket-Protocol: %1\r\n").arg(protocol); 354 | } 355 | if (!extensions.isEmpty()) 356 | { 357 | response += QString("Sec-WebSocket-Extensions: %1\r\n").arg(extensions); 358 | } 359 | response += QLatin1String("\r\n"); 360 | return response; 361 | } 362 | 363 | QString QWsServer::composeBadRequestResponse(QList versions) 364 | { 365 | QString response; 366 | response += QLatin1String("HTTP/1.1 400 Bad Request\r\n"); 367 | if (!versions.isEmpty()) 368 | { 369 | QString versionsStr; 370 | int i = versions.size(); 371 | while (i--) 372 | { 373 | versionsStr += QString::number((quint16)versions.at(i)); 374 | if (i) 375 | { 376 | versionsStr += QLatin1String(", "); 377 | } 378 | } 379 | response += QString("Sec-WebSocket-Version: %1\r\n").arg(versionsStr); 380 | } 381 | return response; 382 | } 383 | 384 | } // namespace QtWebsocket 385 | -------------------------------------------------------------------------------- /Example/Server/Server.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | 15 | true 16 | 17 | 18 | true 19 | 20 | 21 | true 22 | 23 | 24 | true 25 | 26 | 27 | true 28 | 29 | 30 | true 31 | 32 | 33 | 34 | 35 | 36 | 37 | $(QTDIR)\bin\moc.exe;%(FullPath) 38 | Moc%27ing Server.h... 39 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 40 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 41 | $(QTDIR)\bin\moc.exe;%(FullPath) 42 | Moc%27ing Server.h... 43 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 44 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 45 | 46 | 47 | 48 | 49 | $(QTDIR)\bin\moc.exe;%(FullPath) 50 | Moc%27ing QWsServer.h... 51 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 52 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 53 | $(QTDIR)\bin\moc.exe;%(FullPath) 54 | Moc%27ing QWsServer.h... 55 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 56 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 57 | 58 | 59 | 60 | 61 | $(QTDIR)\bin\moc.exe;%(FullPath) 62 | Moc%27ing QWsSocket.h... 63 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 64 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 65 | $(QTDIR)\bin\moc.exe;%(FullPath) 66 | Moc%27ing QWsSocket.h... 67 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 68 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 69 | 70 | 71 | 72 | {5C7FFE1F-B387-4A78-AEDF-41F84E9FAB45} 73 | Qt4VSv1.0 74 | 75 | 76 | 77 | Application 78 | 79 | 80 | Application 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | <_ProjectFileVersion>10.0.40219.1 94 | AllRules.ruleset 95 | 96 | 97 | AllRules.ruleset 98 | 99 | 100 | $(SolutionDir)$(Platform)\$(Configuration)\ 101 | $(SolutionDir)$(Platform)\$(Configuration)\ 102 | $(ProjectDir)$(Configuration)\ 103 | $(ProjectDir)$(Configuration)\ 104 | 105 | 106 | 107 | UNICODE;WIN32;QT_DLL;QT_CORE_LIB;QT_NETWORK_LIB;%(PreprocessorDefinitions) 108 | Disabled 109 | ProgramDatabase 110 | MultiThreadedDebugDLL 111 | .;..\..\QtWebsocket;.\GeneratedFiles;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 112 | false 113 | 114 | 115 | Console 116 | $(OutDir)\$(ProjectName).exe 117 | $(QTDIR)\lib;$(SolutionDir)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) 118 | true 119 | qtmaind.lib;Qt5Cored.lib;Qt5Networkd.lib;QtWebsocket.lib;%(AdditionalDependencies) 120 | 121 | 122 | 123 | 124 | UNICODE;WIN32;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_NETWORK_LIB;%(PreprocessorDefinitions) 125 | 126 | 127 | MultiThreadedDLL 128 | .;..\..\QtWebsocket;.\GeneratedFiles;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 129 | false 130 | 131 | 132 | Console 133 | $(OutDir)\$(ProjectName).exe 134 | $(QTDIR)\lib;$(SolutionDir)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) 135 | false 136 | qtmain.lib;Qt5Core.lib;Qt5Network.lib;QtWebsocket.lib;%(AdditionalDependencies) 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | -------------------------------------------------------------------------------- /Example/ServerThreaded/ServerThreaded.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | 15 | true 16 | 17 | 18 | true 19 | 20 | 21 | true 22 | 23 | 24 | true 25 | 26 | 27 | true 28 | 29 | 30 | true 31 | 32 | 33 | true 34 | 35 | 36 | true 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | $(QTDIR)\bin\moc.exe;%(FullPath) 45 | Moc%27ing ServerThreaded.h... 46 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 47 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 48 | $(QTDIR)\bin\moc.exe;%(FullPath) 49 | Moc%27ing ServerThreaded.h... 50 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 51 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 52 | 53 | 54 | 55 | 56 | $(QTDIR)\bin\moc.exe;%(FullPath) 57 | Moc%27ing SocketThread.h... 58 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 59 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 60 | $(QTDIR)\bin\moc.exe;%(FullPath) 61 | Moc%27ing SocketThread.h... 62 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 63 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 64 | 65 | 66 | 67 | 68 | $(QTDIR)\bin\moc.exe;%(FullPath) 69 | Moc%27ing QWsServer.h... 70 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 71 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 72 | $(QTDIR)\bin\moc.exe;%(FullPath) 73 | Moc%27ing QWsServer.h... 74 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 75 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 76 | 77 | 78 | 79 | 80 | $(QTDIR)\bin\moc.exe;%(FullPath) 81 | Moc%27ing QWsSocket.h... 82 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 83 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 84 | $(QTDIR)\bin\moc.exe;%(FullPath) 85 | Moc%27ing QWsSocket.h... 86 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 87 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 88 | 89 | 90 | 91 | {5B11012D-3641-4AD8-9B65-11EA72C458DD} 92 | Qt4VSv1.0 93 | 94 | 95 | 96 | Application 97 | 98 | 99 | Application 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | <_ProjectFileVersion>10.0.40219.1 113 | AllRules.ruleset 114 | 115 | 116 | AllRules.ruleset 117 | 118 | 119 | $(SolutionDir)$(Platform)\$(Configuration)\ 120 | $(SolutionDir)$(Platform)\$(Configuration)\ 121 | $(ProjectDir)$(Configuration)\ 122 | 123 | 124 | 125 | UNICODE;WIN32;QT_DLL;QT_CORE_LIB;QT_NETWORK_LIB;%(PreprocessorDefinitions) 126 | Disabled 127 | ProgramDatabase 128 | MultiThreadedDebugDLL 129 | .;..\..\QtWebsocket;.\GeneratedFiles;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 130 | false 131 | 132 | 133 | Console 134 | $(OutDir)\$(ProjectName).exe 135 | $(QTDIR)\lib;$(SolutionDir)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) 136 | true 137 | qtmaind.lib;Qt5Cored.lib;Qt5Networkd.lib;QtWebsocket.lib;%(AdditionalDependencies) 138 | 139 | 140 | 141 | 142 | UNICODE;WIN32;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_NETWORK_LIB;%(PreprocessorDefinitions) 143 | 144 | 145 | MultiThreadedDLL 146 | .;..\..\QtWebsocket;.\GeneratedFiles;.\GeneratedFiles\$(ConfigurationName);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 147 | false 148 | 149 | 150 | Console 151 | $(OutDir)\$(ProjectName).exe 152 | $(QTDIR)\lib;$(SolutionDir)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) 153 | false 154 | qtmain.lib;Qt5Core.lib;Qt5Network.lib;QtWebsocket.lib;%(AdditionalDependencies) 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | -------------------------------------------------------------------------------- /AutobahnTestSuite/AutobahnTestSuite.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Template 14 | Win32 15 | 16 | 17 | 18 | {CF0BAFAA-70E5-4777-8196-AAE035657648} 19 | AutobahnTestSuite 20 | Qt4VSv1.0 21 | 22 | 23 | 24 | Application 25 | 26 | 27 | Application 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | <_ProjectFileVersion>10.0.40219.1 41 | $(SolutionDir)$(Platform)\$(Configuration)\ 42 | $(SolutionDir)$(Platform)\$(Configuration)\ 43 | $(SolutionDir)$(Platform)\$(Configuration)\ 44 | $(ProjectDir)$(Platform)\$(Configuration)\ 45 | AllRules.ruleset 46 | 47 | 48 | AllRules.ruleset 49 | 50 | 51 | AllRules.ruleset 52 | 53 | 54 | 55 | 56 | 57 | .;$(QTDIR)\include;.\GeneratedFiles\$(Configuration);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 58 | UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_NETWORK_LIB;%(PreprocessorDefinitions) 59 | MultiThreadedDLL 60 | false 61 | 62 | 63 | 64 | 65 | qtmain.lib;QtCore4.lib;QtNetwork4.lib;Qt5Core.lib;Qt5Network.lib;%(AdditionalDependencies) 66 | $(OutDir)$(ProjectName).exe 67 | $(QTDIR)\lib;%(AdditionalLibraryDirectories) 68 | false 69 | Console 70 | 71 | 72 | 73 | 74 | Disabled 75 | ..\qtwebsocket;.;$(QTDIR)\include;.\GeneratedFiles\$(Configuration);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 76 | UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_CORE_LIB;QT_NETWORK_LIB;%(PreprocessorDefinitions) 77 | MultiThreadedDebugDLL 78 | false 79 | ProgramDatabase 80 | 81 | 82 | qtmaind.lib;QtWebsocket.lib;Qt5Cored.lib;Qt5Networkd.lib;%(AdditionalDependencies) 83 | $(OutDir)$(ProjectName).exe 84 | $(QTDIR)\lib;$(SolutionDir)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) 85 | true 86 | Console 87 | 88 | 89 | 90 | 91 | QT_CORE_LIB;QT_NETWORK_LIB;%(PreprocessorDefinitions) 92 | $(QTDIR)\include\QtCore;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 93 | 94 | 95 | Qt5Core.lib;Qt5Network.lib;%(AdditionalDependencies) 96 | 97 | 98 | 99 | 100 | 101 | 102 | true 103 | 104 | 105 | true 106 | 107 | 108 | true 109 | true 110 | 111 | 112 | true 113 | 114 | 115 | true 116 | 117 | 118 | true 119 | true 120 | 121 | 122 | 123 | 124 | Moc%27ing QWsServer.h... 125 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB "-I.\..\qtwebsocket" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 126 | 127 | $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) 128 | .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) 129 | Moc%27ing QWsServer.h... 130 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 131 | 132 | $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) 133 | .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) 134 | 135 | 136 | Performing Custom Build Tools 137 | 138 | 139 | 140 | 141 | 142 | 143 | Moc%27ing QWsSocket.h... 144 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB "-I.\..\qtwebsocket" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 145 | 146 | $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) 147 | .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) 148 | Moc%27ing QWsSocket.h... 149 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 150 | 151 | $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) 152 | .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) 153 | 154 | 155 | Performing Custom Build Tools 156 | 157 | 158 | 159 | 160 | 161 | 162 | Moc%27ing TestServer.h... 163 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB "-I.\..\qtwebsocket" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 164 | 165 | $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) 166 | .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) 167 | Moc%27ing TestServer.h... 168 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 169 | 170 | $(QTDIR)\bin\moc.exe;%(FullPath);%(AdditionalInputs) 171 | .\GeneratedFiles\$(Configuration)\moc_%(Filename).cpp;%(Outputs) 172 | 173 | 174 | Performing Custom Build Tools 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | {7e3a920c-4257-41a1-b9b9-bfa138c1c8a2} 184 | false 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | -------------------------------------------------------------------------------- /QtWebsocket/QtWebsocket.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Template 14 | Win32 15 | 16 | 17 | 18 | 19 | 20 | true 21 | true 22 | 23 | 24 | true 25 | true 26 | 27 | 28 | true 29 | true 30 | 31 | 32 | true 33 | true 34 | 35 | 36 | true 37 | true 38 | 39 | 40 | true 41 | true 42 | 43 | 44 | true 45 | true 46 | 47 | 48 | true 49 | true 50 | 51 | 52 | true 53 | true 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | $(QTDIR)\bin\moc.exe;%(FullPath) 64 | Moc%27ing QWsServer.h... 65 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 66 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB -DQTWEBSOCKET_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 67 | $(QTDIR)\bin\moc.exe;%(FullPath) 68 | Moc%27ing QWsServer.h... 69 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 70 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB -DQTWEBSOCKET_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 71 | $(QTDIR)\bin\moc.exe;%(FullPath) 72 | Moc%27ing QWsServer.h... 73 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 74 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" 75 | 76 | 77 | 78 | 79 | $(QTDIR)\bin\moc.exe;%(FullPath) 80 | Moc%27ing QWsSocket.h... 81 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 82 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB -DQTWEBSOCKET_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 83 | $(QTDIR)\bin\moc.exe;%(FullPath) 84 | Moc%27ing QWsSocket.h... 85 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 86 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB -DQTWEBSOCKET_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 87 | $(QTDIR)\bin\moc.exe;%(FullPath) 88 | Moc%27ing QWsSocket.h... 89 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 90 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" 91 | 92 | 93 | 94 | 95 | %(AdditionalInputs) 96 | 97 | 98 | 99 | 100 | 101 | 102 | %(AdditionalInputs) 103 | 104 | 105 | 106 | 107 | 108 | 109 | %(AdditionalInputs) 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | $(QTDIR)\bin\moc.exe;%(FullPath) 119 | Moc%27ing QTlsServer.h... 120 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 121 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_NETWORK_LIB -DQTWEBSOCKET_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 122 | $(QTDIR)\bin\moc.exe;%(FullPath) 123 | Moc%27ing QTlsServer.h... 124 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 125 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_NETWORK_LIB -DQTWEBSOCKET_LIB "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" 126 | $(QTDIR)\bin\moc.exe;%(FullPath) 127 | Moc%27ing QTlsServer.h... 128 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 129 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" 130 | 131 | 132 | 133 | 134 | 135 | 136 | {7E3A920C-4257-41A1-B9B9-BFA138C1C8A2} 137 | Qt4VSv1.0 138 | 139 | 140 | 141 | StaticLibrary 142 | 143 | 144 | StaticLibrary 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | <_ProjectFileVersion>10.0.40219.1 158 | $(SolutionDir)$(Platform)\$(Configuration)\ 159 | $(ProjectDir)$(Configuration)\ 160 | $(SolutionDir)$(Platform)\$(Configuration)\ 161 | $(ProjectDir)$(Configuration)\ 162 | AllRules.ruleset 163 | 164 | 165 | AllRules.ruleset 166 | 167 | 168 | AllRules.ruleset 169 | 170 | 171 | $(ProjectName) 172 | .lib 173 | 174 | 175 | 176 | .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(Configuration);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 177 | UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_NETWORK_LIB;QTWEBSOCKET_LIB;%(PreprocessorDefinitions) 178 | MultiThreadedDLL 179 | false 180 | 181 | 182 | 183 | 184 | $(OutDir)$(ProjectName).lib 185 | $(QTDIR)\lib;%(AdditionalLibraryDirectories) 186 | 187 | 188 | 189 | 190 | Disabled 191 | .\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(Configuration);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtNetwork;%(AdditionalIncludeDirectories) 192 | UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_CORE_LIB;QT_NETWORK_LIB;QTWEBSOCKET_LIB;%(PreprocessorDefinitions) 193 | MultiThreadedDebugDLL 194 | false 195 | ProgramDatabase 196 | 197 | 198 | $(OutDir)$(ProjectName).lib 199 | $(QTDIR)\lib;%(AdditionalLibraryDirectories) 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | -------------------------------------------------------------------------------- /Example/Client/Client.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Template 14 | Win32 15 | 16 | 17 | 18 | {B12702AD-ABFB-343A-A199-8E24837244A3} 19 | Qt4VSv1.0 20 | 21 | 22 | 23 | Application 24 | 25 | 26 | Application 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | <_ProjectFileVersion>10.0.40219.1 40 | $(SolutionDir)$(Platform)\$(Configuration)\ 41 | $(ProjectDir)$(Configuration)\ 42 | $(SolutionDir)$(Platform)\$(Configuration)\ 43 | $(ProjectDir)$(Configuration)\ 44 | AllRules.ruleset 45 | 46 | 47 | AllRules.ruleset 48 | 49 | 50 | AllRules.ruleset 51 | 52 | 53 | 54 | 55 | 56 | ..\..\QtWebsocket;.\GeneratedFiles;.;$(QTDIR)\include;.\GeneratedFiles\$(Configuration);$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) 57 | UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;QT_GUI_LIB;QT_NETWORK_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) 58 | MultiThreadedDLL 59 | false 60 | 61 | 62 | 63 | 64 | qtmain.lib;Qt5Core.lib;Qt5Gui.lib;Qt5Network.lib;Qt5Widgets.lib;QtWebsocket.lib;%(AdditionalDependencies) 65 | $(OutDir)\$(ProjectName).exe 66 | $(QTDIR)\lib;$(SolutionDir)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) 67 | false 68 | Windows 69 | 70 | 71 | 72 | 73 | Disabled 74 | .;..\..\QtWebsocket;.\GeneratedFiles;.\GeneratedFiles\$(Configuration);$(QTDIR)\include;$(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWidgets;%(AdditionalIncludeDirectories) 75 | UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_DLL;QT_CORE_LIB;QT_GUI_LIB;QT_NETWORK_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) 76 | MultiThreadedDebugDLL 77 | false 78 | ProgramDatabase 79 | 80 | 81 | qtmaind.lib;Qt5Cored.lib;Qt5Networkd.lib;Qt5Guid.lib;Qt5Widgetsd.lib;QtWebsocket.lib;%(AdditionalDependencies) 82 | $(OutDir)\$(ProjectName).exe 83 | $(QTDIR)\lib;$(SolutionDir)$(Platform)\$(Configuration);%(AdditionalLibraryDirectories) 84 | true 85 | Windows 86 | 87 | 88 | 89 | 90 | QT_CORE_LIB;QT_GUI_LIB;QT_NETWORK_LIB;QT_WIDGETS_LIB;%(PreprocessorDefinitions) 91 | $(QTDIR)\include\QtCore;$(QTDIR)\include\QtGui;$(QTDIR)\include\QtNetwork;$(QTDIR)\include\QtWidgets;.\;.\GeneratedFiles;%(AdditionalIncludeDirectories) 92 | 93 | 94 | Qt5Core.lib;Qt5Gui.lib;Qt5Network.lib;Qt5Widgets.lib;%(AdditionalDependencies) 95 | 96 | 97 | 98 | 99 | {7e3a920c-4257-41a1-b9b9-bfa138c1c8a2} 100 | false 101 | 102 | 103 | 104 | 105 | 106 | true 107 | true 108 | 109 | 110 | true 111 | true 112 | 113 | 114 | true 115 | true 116 | 117 | 118 | true 119 | true 120 | 121 | 122 | true 123 | true 124 | 125 | 126 | true 127 | true 128 | 129 | 130 | true 131 | true 132 | 133 | 134 | true 135 | true 136 | 137 | 138 | true 139 | true 140 | 141 | 142 | 143 | 144 | 145 | $(QTDIR)\bin\moc.exe;%(FullPath) 146 | Moc%27ing Client.h... 147 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 148 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WIDGETS_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWidgets" 149 | $(QTDIR)\bin\moc.exe;%(FullPath) 150 | Moc%27ing Client.h... 151 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 152 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WIDGETS_LIB "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWidgets" 153 | $(QTDIR)\bin\moc.exe;%(FullPath) 154 | Moc%27ing Client.h... 155 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 156 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WIDGETS_LIB "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWidgets" "-I." "-I.\GeneratedFiles" 157 | 158 | 159 | 160 | 161 | 162 | $(QTDIR)\bin\moc.exe;%(FullPath) 163 | Moc%27ing QWsSocket.h... 164 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 165 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WIDGETS_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWidgets" 166 | $(QTDIR)\bin\moc.exe;%(FullPath) 167 | Moc%27ing QWsSocket.h... 168 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 169 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WIDGETS_LIB "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWidgets" 170 | $(QTDIR)\bin\moc.exe;%(FullPath) 171 | Moc%27ing QWsSocket.h... 172 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 173 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WIDGETS_LIB "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWidgets" "-I." "-I.\GeneratedFiles" 174 | 175 | 176 | $(QTDIR)\bin\moc.exe;%(FullPath) 177 | Moc%27ing QWsServer.h... 178 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 179 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WIDGETS_LIB "-I." "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWidgets" 180 | $(QTDIR)\bin\moc.exe;%(FullPath) 181 | Moc%27ing QWsServer.h... 182 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 183 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DLL -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WIDGETS_LIB "-I.\..\..\QtWebsocket" "-I.\GeneratedFiles" "-I." "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(Configuration)\." "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWidgets" 184 | $(QTDIR)\bin\moc.exe;%(FullPath) 185 | Moc%27ing QWsServer.h... 186 | .\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp 187 | "$(QTDIR)\bin\moc.exe" "%(FullPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_%(Filename).cpp" -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_WIDGETS_LIB "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtGui" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtWidgets" "-I." "-I.\GeneratedFiles" 188 | 189 | 190 | 191 | 192 | Document 193 | $(QTDIR)\bin\uic.exe;%(AdditionalInputs) 194 | Uic%27ing %(Identity)... 195 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 196 | "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 197 | $(QTDIR)\bin\uic.exe;%(AdditionalInputs) 198 | Uic%27ing %(Identity)... 199 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 200 | "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 201 | $(QTDIR)\bin\uic.exe;%(AdditionalInputs) 202 | Uic%27ing %(Identity)... 203 | .\GeneratedFiles\ui_%(Filename).h;%(Outputs) 204 | "$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_%(Filename).h" "%(FullPath)" 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | --------------------------------------------------------------------------------