Skip to content

NodeppOfficial/nodepp-apify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

NODEPP-APIFY

To develop a high-performance, real-time API in C++ leveraging the NodePP library. This API will offer a development experience similar to Socket.IO but within the C++ ecosystem.

Features

  • Real-time Bidirectional Communication: Enable persistent, low-latency communication between clients and the server, allowing for instant data exchange.
  • Event-Driven Architecture: Design the API around the concept of emitting and handling events, providing a flexible and reactive programming model.
  • Asynchronous I/O: Utilize an asynchronous I/O model to handle concurrent connections efficiently without blocking, ensuring scalability and responsiveness.
  • C++ Performance: Capitalize on the inherent performance advantages of C++ for demanding real-time applications.

Build & Run

time; g++ -o main main.cpp -I ./include; ./main

Usage

Server

#include <nodepp/nodepp.h>
#include <apify/apify.h>
#include <nodepp/ws.h>

using namespace nodepp;

void onMain() {
    auto app = apify::add<ws_t>();
    auto srv = ws::server();

    app.on("METHOD","/PATH",[=]( apify_t<ws_t> cli ){
        console::log( cli.message );
        cli.emit( "DONE", "/PATH", "done" );
    });

    srv.onConnect([=]( ws_t cli ){

        cli.onData([=]( string_t data ){
            app.next( cli, data );
        });

        cli.onClose([=](){
            console::log("Disconnected");
        }); console::log("Connected");

    });

    srv.listen("localhost",8000,[=](...){
        console::log( "ws:/localhost:8000" );
    }); console::log( "Started" );

}

Client

#include <nodepp/nodepp.h>
#include <apify/apify.h>
#include <nodepp/ws.h>

using namespace nodepp;

void onMain(){
    auto srv = ws::client( "ws://localhost:8000" );
    auto app = apify::add<ws_t>();

    app.on("DONE","/PATH",[=]( apify_t<ws_t> cli ){
        console::log( cli.message );
    });

    srv.onConnect([=]( ws_t cli ){

        cli.onData([=]( string_t data ){
            app.next( cli, data );
        });

        srv.onClose([=](){
            console::log("Disconnected");
        }); console::log("Connected");

        apify::add(cli).emit("METHOD","/PATH","hello world!");

    });

}

License

Nodepp is distributed under the MIT License. See the LICENSE file for more details.

About

high-performance, real-time API in C++ with Nodepp + Apify

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages