Coder Social home page Coder Social logo

gilmaimon / tinywebsockets Goto Github PK

View Code? Open in Web Editor NEW
40.0 40.0 11.0 371 KB

A modern and minimal websockets implementation in C++14. Made with IOT in mind.

License: GNU General Public License v3.0

CMake 0.61% C++ 99.25% JavaScript 0.14%
cplusplus wbsockets

tinywebsockets's People

Contributors

gilmaimon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

tinywebsockets's Issues

Rework readBlocking

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)

add gsm module with at command to supported network sockets.

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?

Add WebsocketsServer

Add server class that accepts connections and relies on a TcpServer (not implemented)

SSL/TLS Support

Add support for websockets over ssl. At first only client side and eventually server side.
Consider OpenSSL.

Add examples, demos and enhance README.md

Examples:

  • echo server example (echo.websockets.org)
  • keep alive with pings and pongs
  • example usage of active poll
  • example for blocking message reading interface

Add some to the readme (events handling, blocking interface).

poll() disconnects client

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);
}

Unable to run sample code

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

Add proper handling for fragmented messages

  • A message should always be complete and never fragmented (or partial)
  • Should the user be notified on changes?
  • An option to select fragmented messages
  • Usage of streams for sending/receiving

Build errors.

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.

Recommend Projects

  • React photo React

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

  • Vue.js photo Vue.js

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

  • Typescript photo Typescript

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

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

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

Recommend Topics

  • javascript

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

  • web

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

  • server

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

  • Machine learning

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

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

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

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.