gilmaimon / tinywebsockets Goto Github PK
View Code? Open in Web Editor NEWA modern and minimal websockets implementation in C++14. Made with IOT in mind.
License: GNU General Public License v3.0
A modern and minimal websockets implementation in C++14. Made with IOT in mind.
License: GNU General Public License v3.0
Make it easier for users to check if a message is an event (ping, pong, open, close) or text/binary.
Also, maybe close messages should arrive the user (which means some way to return error from readBlocking)
hello
for my work, I want to implement socket for gsm module that works with at command. when i see the network directory all file was header file. exactly where i should create my own implementation of client and which class should extend?
Messages are not masked by default in order to simplify the communication and reduce work on the micro controller.
Add server class that accepts connections and relies on a TcpServer (not implemented)
Add support for websockets over ssl. At first only client side and eventually server side.
Consider OpenSSL.
Examples:
Add some to the readme (events handling, blocking interface).
I'm trying to poll the server for incoming connections and if true create a WebsocketsClient named client. In my first approach I call poll() on every new loop. As soon as a client is connected, it gets disconnected again when the loop rolls over and reaches " if(server.poll()) {" again.
What's the problem here?
void loop() {
static WebsocketsClient client;
if(server.poll()) {
client = server.accept();
Serial.println("new client!");
}
else {
Serial.println("no new client");
}
if(client.available()) {
WebsocketsMessage msg = client.readBlocking();
// log
Serial.print("Got Message: ");
Serial.println(msg.data());
// return echo
client.send("Echo: " + msg.data());
Serial.println("Echo: " + msg.data());
}
delay(1000);
}
i cloned the lib in my arduino libraries folders like
git clone https://github.com/gilmaimon/TinyWebsockets.git
now when i tried to upload sample code am getting error
tiny_websockets/client.hpp: No such file or directory
possibly due to bad structure of library folder
Handshake keys are not randomly generated in order to spare that work from microcontrollers.
Using Ubuntu 20.04, I get this error when doing "make demo_echo_client" 👍
Scanning dependencies of target tiny_websockets_lib
[ 8%] Building CXX object tiny_websockets_lib/CMakeFiles/tiny_websockets_lib.dir/src/crypto.cpp.o
[ 16%] Building CXX object tiny_websockets_lib/CMakeFiles/tiny_websockets_lib.dir/src/linux_tcp.cpp.o
[ 25%] Building CXX object tiny_websockets_lib/CMakeFiles/tiny_websockets_lib.dir/src/message.cpp.o
[ 33%] Building CXX object tiny_websockets_lib/CMakeFiles/tiny_websockets_lib.dir/src/openssl_secure_tcp_client.cpp.o
[ 41%] Building CXX object tiny_websockets_lib/CMakeFiles/tiny_websockets_lib.dir/src/websockets_client.cpp.o
/home/nick_thomas/Data/Utils/WebSockets/TinyWebsockets/TinyWebsockets/tiny_websockets_lib/src/websockets_client.cpp: In function ‘websockets::HandshakeRequestResult websockets::generateHandshake(const WSString&, const WSString&, const std::vector<std::pair<std::__cxx11::basic_string, std::__cxx11::basic_string > >&)’:
/home/nick_thomas/Data/Utils/WebSockets/TinyWebsockets/TinyWebsockets/tiny_websockets_lib/src/websockets_client.cpp:111:25: error: moving a local object in a return statement prevents copy elision [-Werror=pessimizing-move]
111 | return std::move(result);
| ~~~~~~~~~^~~~~~~~
/home/nick_thomas/Data/Utils/WebSockets/TinyWebsockets/TinyWebsockets/tiny_websockets_lib/src/websockets_client.cpp:111:25: note: remove ‘std::move’ call
/home/nick_thomas/Data/Utils/WebSockets/TinyWebsockets/TinyWebsockets/tiny_websockets_lib/src/websockets_client.cpp: In member function ‘bool websockets::WebsocketsClient::send(const char*)’:
/home/nick_thomas/Data/Utils/WebSockets/TinyWebsockets/TinyWebsockets/tiny_websockets_lib/src/websockets_client.cpp:352:33: error: ‘strlen’ was not declared in this scope
352 | return this->send(data, strlen(data));
| ^~~~~~
/home/nick_thomas/Data/Utils/WebSockets/TinyWebsockets/TinyWebsockets/tiny_websockets_lib/src/websockets_client.cpp:6:1: note: ‘strlen’ is defined in header ‘’; did you forget to ‘#include ’?
5 | #include <tiny_websockets/internals/wscrypto/crypto.hpp>
+++ |+#include
6 |
cc1plus: all warnings being treated as errors
make[3]: *** [tiny_websockets_lib/CMakeFiles/tiny_websockets_lib.dir/build.make:115: tiny_websockets_lib/CMakeFiles/tiny_websockets_lib.dir/src/websockets_client.cpp.o] Error 1
make[2]: *** [CMakeFiles/Makefile2:263: tiny_websockets_lib/CMakeFiles/tiny_websockets_lib.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:189: CMakeFiles/demo_echo_client.dir/rule] Error 2
make: *** [Makefile:188: demo_echo_client] Error 2
Thought you should know.
Add support for error codes when closing a connection, according to the rfc:
https://tools.ietf.org/html/rfc6455#section-7.4.1
Add indication for errors such as:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.