Coder Social home page Coder Social logo

smasherprog / websocket_lite Goto Github PK

View Code? Open in Web Editor NEW
10.0 4.0 5.0 8.65 MB

cross platform web socket library

License: MIT License

CMake 0.14% C++ 99.86%
websocket websockets websocket-client websocket-protocol websocket-library websocket-server websocket-api websocket-application c-plus-plus cross-platform

websocket_lite's Introduction

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

websocket_lite's People

Contributors

smasherprog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

websocket_lite's Issues

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.