All Projects → Molorius → Esp32 Websocket

Molorius / Esp32 Websocket

Licence: gpl-3.0
ESP-IDF WebSocket Component

Programming Languages

c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to Esp32 Websocket

Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+7771.08%)
Mutual labels:  websocket-server
Babl
Low-latency WebSocket Server
Stars: ✭ 37 (-55.42%)
Mutual labels:  websocket-server
Sockjs
SockJS server for rust language
Stars: ✭ 63 (-24.1%)
Mutual labels:  websocket-server
Beetlex
high performance dotnet core socket tcp communication components, support TLS, HTTP, HTTPS, WebSocket, RPC, Redis protocols, custom protocols and 1M connections problem solution
Stars: ✭ 802 (+866.27%)
Mutual labels:  websocket-server
Stl.fusion
Get real-time UI updates in Blazor apps and 10-1000x faster API responses with a novel approach to distributed reactive computing. Fusion brings computed observables and automatic dependency tracking from Knockout.js/MobX/Vue to the next level by enabling a single dependency graph span multiple servers and clients, including Blazor apps running in browser.
Stars: ✭ 858 (+933.73%)
Mutual labels:  websocket-server
Websockets Chat
Laravel WebSockets chat
Stars: ✭ 44 (-46.99%)
Mutual labels:  websocket-server
Ulfius
Web Framework to build REST APIs, Webservices or any HTTP endpoint in C language. Can stream large amount of data, integrate JSON data with Jansson, and create websocket services
Stars: ✭ 666 (+702.41%)
Mutual labels:  websocket-server
Deno Websocket
🦕 A simple WebSocket library like ws of node.js library for deno
Stars: ✭ 74 (-10.84%)
Mutual labels:  websocket-server
Websock3ds
Example websocket server for Nintendo 3DS
Stars: ✭ 13 (-84.34%)
Mutual labels:  websocket-server
Vtx clientserver
VTX Client / Server package.
Stars: ✭ 60 (-27.71%)
Mutual labels:  websocket-server
Sylar
C++高性能分布式服务器框架,webserver,websocket server,自定义tcp_server(包含日志模块,配置模块,线程模块,协程模块,协程调度模块,io协程调度模块,hook模块,socket模块,bytearray序列化,http模块,TcpServer模块,Websocket模块,Https模块等, Smtp邮件模块, MySQL, SQLite3, ORM,Redis,Zookeeper)
Stars: ✭ 895 (+978.31%)
Mutual labels:  websocket-server
Awesome Websockets
A curated list of Websocket libraries and resources.
Stars: ✭ 850 (+924.1%)
Mutual labels:  websocket-server
Angel
A polished, production-ready backend framework in Dart for the VM, AOT, and Flutter.
Stars: ✭ 1,055 (+1171.08%)
Mutual labels:  websocket-server
Netcoreserver
Ultra fast and low latency asynchronous socket server & client C# .NET Core library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Stars: ✭ 799 (+862.65%)
Mutual labels:  websocket-server
Laravel Websockets Chat Example
Example of a real-time chat system built with the Laravel WebSockets package, VueJs, and Laravel-echo.
Stars: ✭ 65 (-21.69%)
Mutual labels:  websocket-server
Iodine
iodine - HTTP / WebSockets Server for Ruby with Pub/Sub support
Stars: ✭ 720 (+767.47%)
Mutual labels:  websocket-server
Jiny
Lightweight, modern, simple JVM web framework for rapid development in the API era
Stars: ✭ 40 (-51.81%)
Mutual labels:  websocket-server
Devify Server
A set of lightweight IoT cloud server boilerplates. The simplest way to build isomorphic JavaScript IoT servers.
Stars: ✭ 78 (-6.02%)
Mutual labels:  websocket-server
Cebsocket
Lightweight WebSocket library for C.
Stars: ✭ 73 (-12.05%)
Mutual labels:  websocket-server
Websocket
A PHP implementation of WebSocket.
Stars: ✭ 54 (-34.94%)
Mutual labels:  websocket-server

By Blake Felt - [email protected]

ESP32 WebSocket

A component for WebSockets on ESP-IDF using lwip netconn. For an example, see https://github.com/Molorius/ESP32-Examples.

To add to a project, type: git submodule add https://github.com/Molorius/esp32-websocket.git components/websocket into the base directory of your project.

Some configuration options for the Server can be found in menuconfig in: Component config ---> WebSocket Server

This presently only has the WebSocket server code working, but client code will be added in the future (the groundwork is there).

The code only allows one WebSocket server at a time, but this merely handles all incoming reads. New connections are added externally, so this can be used to hold various WebSocket connections.

While this can theoretically handle very large messages, hardware constraints (RAM) limits the size of messages. I highly recommend not using more than 5000 bytes per message, but no constraint is in place for this.

Any suggestions or fixes are gladly appreciated.

Table of Contents

Enumerations

enum WEBSOCKET_TYPE_t

The different types of WebSocket events.

Values

  • WEBSOCKET_CONNECT: A new client has successfully connected.
  • WEBSOCKET_DISCONNECT_EXTERNAL: The other side sent a disconnect message.
  • WEBSOCKET_DISCONNECT_INTERNAL: The esp32 server sent a disconnect message.
  • WEBSOCKET_DISCONNECT_ERROR: Disconnect due to a connection error.
  • WEBSOCKET_TEXT: Incoming text.
  • WEBSOCKET_BIN: Incoming binary.
  • WEBSOCKET_PING: The other side sent a ping message.
  • WEBSOCKET_PONG: The other side successfully replied to our ping.

Functions

int ws_server_start()

Starts the WebSocket Server. Use this function before attempting any sort of transmission or adding a client.

Returns

  • 1: successful start
  • 0: server already running

int ws_server_stop()

Stops the WebSocket Server. New clients can still be added and messages can be sent, but new messages will not be received.

Returns

  • 1: successful stop
  • 0: server was not running before

int ws_server_add_client(struct netconn* conn,char* msg,uint16_t len,char* url,void *callback)

Adds a client to the WebSocket Server handler and performs the necessary handshake.

Parameters

  • conn: the lwip netconn connection.
  • msg: the entire incoming request message to join the server. Necessary for the handshake.
  • len: the length of msg.
  • url: the NULL-terminated url. Used to keep track of clients, not required.
  • callback: the callback that is used to run WebSocket events. This must be with parameters(uint8_t num,WEBSOCKET_TYPE_t type,char* msg,uint64_t len) where "num" is the client number, "type" is the event type, "msg" is the incoming message, and "len" is the message length. The callback itself is optional.

Returns

  • -2: not enough information in msg to perform handshake.
  • -1: server full, or connection issue.
  • 0 or greater: connection number

int ws_server_add_client_protocol(struct netconn* conn,char* msg,uint16_t len,char* url,char* protocol,void *callback)

Adds a client to the WebSocket Server handler and performs the necessary handshake. Will also send the specified protocol.

Parameters

  • conn: the lwip netconn connection.
  • msg: the entire incoming request message to join the server. Necessary for the handshake.
  • len: the length of msg.
  • url: the NULL-terminated url. Used to keep track of clients, not required.
  • protocol: the NULL-terminated protocol. This will be sent to the client in the header.
  • callback: the callback that is used to run WebSocket events. This must be with parameters(uint8_t num,WEBSOCKET_TYPE_t type,char* msg,uint64_t len) where "num" is the client number, "type" is the event type, "msg" is the incoming message, and "len" is the message length. The callback itself is optional.

Returns

  • -2: not enough information in msg to perform handshake.
  • -1: server full, or connection issue.
  • 0 or greater: connection number

int ws_server_len_url(char* url)

Returns the number of clients connected to the specified URL.

Parameters

  • url: the NULL-terminated string of the desired URL.

Returns

  • The number of clients connected to the specified URL.

int ws_server_len_all()

Returns

  • The number of connected clients.

int ws_server_remove_client(int num)

Removes the desired client.

Parameters

  • num: the client number

Returns

  • 0: not a valid client number
  • 1: client disconnected

int ws_server_remove_clients(char* url)

Removes all clients connect to the desired URL.

Parameters

  • url: the NULL-terminated URL.

Returns

  • The number of clients that were disconnected.

int ws_server_remove_all()

Removes all clients from server.

Returns

  • The number of clients that were disconnected.

int ws_server_send_text_client(int num,char* msg,uint64_t len)

Sends the desired message to the client.

Parameters

  • num: the client's number.
  • msg: the desired message.
  • len: the length of the message.

Returns

  • 0: message not sent properly
  • 1: message sent

int ws_server_send_text_clients(char* url,char* msg,uint64_t len)

Sends the message to clients connected to the desired URL.

Parameters

  • url: the NULL-terminated URL.
  • msg: the desired message.
  • len: the length of the message.

Returns

  • The number of clients that the message was sent to.

int ws_server_send_text_all(char* msg,uint64_t len)

Sends the message to all connected clients.

Parameters

  • msg: the desired message
  • len: the length of the message

Returns

  • The number of clients that the message was sent to.

int ws_server_send_text_client_from_callback(int num,char* msg,uint64_t len)

Sends the desired message to the client. Only use this inside the callback function.

Parameters

  • num: the client's number.
  • msg: the desired message.
  • len: the length of the message.

Returns

  • 0: message not sent properly
  • 1: message sent

int ws_server_send_text_clients_from_callback(char* url,char* msg,uint64_t len)

Sends the message to clients connected to the desired URL. Only use this inside the callback function.

Parameters

  • url: the NULL-terminated URL.
  • msg: the desired message.
  • len: the length of the message.

Returns

  • The number of clients that the message was sent to.

int ws_server_send_text_all_from_callback(char* msg,uint64_t len)

Sends the message to all connected clients. Only use this inside the callback function.

Parameters

  • msg: the desired message
  • len: the length of the message

Returns

  • The number of clients that the message was sent to.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].