Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

smasherprog/websocket_lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

410 Commits

Repository files navigation

websocket_lite

Linux/Mac

Windows

This library is a fully compliant websocket implementation! Autobahn complete , but with a few design goals:

  • Cross-platform: Asio https://github.com/chriskohlhoff/asio/
  • Performance
  • Simple and easy to use
  • Latest standards: c++ 17
  • All functions are thread-safe and can be called from any thread at any time

Dependencies: Cmake, openssl, zlib

  • Ubuntu: sudo apt-get install libssl-dev zlib1g-dev -y
  • Mac: brew install openssl zlib
  • WIndows: vcpkg install openssl zlib

USAGE

To get started check out the example here

https://github.com/smasherprog/websocket_lite/blob/master/Test/main.cpp

SL::WS_LITE::PortNumber port(3002);
auto listener =
 SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1))
 ->NoTLS()
 ->CreateListener(port)
 ->onConnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket> &socket, const std::unordered_map<std::string, std::string> &header) {
 
 })
 ->onMessage([&](const std::shared_ptr<SL::WS_LITE::IWSocket> &socket, const SL::WS_LITE::WSMessage &message) {
 })->listen();
 listener->set_ReadTimeout(std::chrono::seconds(100));
 listener->set_WriteTimeout(std::chrono::seconds(100));
 
auto clientctx =
 SL::WS_LITE::CreateContext(SL::WS_LITE::ThreadCount(1))
 ->NoTLS()
 ->CreateClient()
 ->onConnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket> &socket, const std::unordered_map<std::string, std::string> &header) {
 })
 ->onDisconnection([&](const std::shared_ptr<SL::WS_LITE::IWSocket> &socket, unsigned short code, const std::string &msg) {
 })->connect("localhost", port);

AltStyle によって変換されたページ (->オリジナル) /