Skip to content

Commit 14686f7

Browse files
committed
📌 Nodepp | Bug Fixing | V1.3.1 📌
1 parent 2f39a65 commit 14686f7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1714
-933
lines changed

README.md

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
# Nodepp
2+
> **The DOOM of Async Frameworks: Write Once, Build Everywhere, Process Everything.**
3+
4+
[![MIT License](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5+
[![Platform](https://img.shields.io/badge/platform-Linux%20%7C%20Windows%20%7C%20Arduino%20%7C%20WASM-blue)](https://github.com/NodeppOfficial/nodepp)
6+
[![Build Status](https://github.com/NodeppOfficial/nodepp/actions/workflows/c-cpp.yml/badge.svg)](https://github.com/NodeppOfficial/nodepp/actions)
7+
8+
Nodepp is a groundbreaking open-source project that simplifies C++ application development by bridging the gap between the language's raw power and the developer-friendly abstractions of Node.js.
29

310
Nodepp is a groundbreaking open-source project that simplifies C++ application development by bridging the gap between the language's raw power and the developer-friendly abstractions of Node.js. By providing a high-level API, Nodepp empowers developers to write C++ code in a familiar, Node.js-inspired style.
411

@@ -40,17 +47,31 @@ target_link_libraries( #[...]
4047
- 📌: **Scalability:** Build applications that can handle large workloads and grow with your needs.
4148
- 📌: **Open-source:** Contribute to the project's development and customize it to your specific requirements.
4249

43-
## Bateries Included
50+
## Projects made with NodePP
51+
52+
- 🔗: [Computer Vision VR Controllers for phones Demo](https://github.com/PocketVR/Barely_VR_AR_Controller_Test)
53+
- 🔗: [Draw on your PC using your smartphone](https://github.com/ScreenDraw/PCDraw)
54+
- 🔗: [Simple multiplayer Game With Raylib](https://medium.com/@EDBCBlog/create-your-own-online-multiplayer-small-fast-and-fun-with-raylib-nodepp-and-websockets-190f5c174094)
55+
- 🔗: [Cursed Luna - A simple Raylib Game](https://github.com/EDBCREPO/Space-Shocker)
56+
- 🔗: [Smart Card Reader(Nodepp-Arduino)](https://github.com/EDBCREPO/emv-reader)
57+
- 🔗: [Serial Port arduino using Nodepp](https://github.com/EDBCREPO/Arduino_PC)
58+
- 🔗: [Simple Raylib Real-Time Chat](https://github.com/EDBCREPO/simple-raylib-websocket-chat)
59+
- 🔗: [Simple Bitget Trading Bot](https://github.com/EDBCREPO/simple-binance-bot-nodepp)
60+
61+
Check out some articles on [Medium](https://medium.com/@EDBCBlog)
62+
63+
## Batteries Included
4464

4565
- 📌: Include a **build-in JSON** parser / stringify system.
4666
- 📌: Include a **build-in RegExp** engine for processing text strings.
47-
- 📌: Include Support for **UTF** manipulation | **UTF8 - UTF16 - UTF32**
67+
- 📌: Include support for **UTF** manipulation | **UTF8 - UTF16 - UTF32**
4868
- 📌: Include a **build-in System** that make every object **Async Task** safety.
4969
- 📌: Include a **Smart Pointer** base **Garbage Collector** to avoid **Memory Leaks**.
5070
- 📌: Include support for **Reactive Programming** based on **Events** and **Observers**.
5171
- 📌: Include an **Event Loop** that can handle multiple events and tasks on a single thread.
5272
- 📌: Include support for **TCP | TLS | UDP | HTTP | WS** making it easy to create networked applications.
53-
- 📌: Include Support for **Poll | Epoll | Kqueue | WSAPoll** making it easy to handle multiple file descriptors.
73+
- 📌: Include support for **Poll | Epoll | Kqueue | WSAPoll** making it easy to handle multiple file descriptors.
74+
- 📌: Include support for **Worker isolated event-loop** making it easy to create distributed self-contained event-loops.
5475

5576
## Build & Run
5677
```bash
@@ -160,6 +181,47 @@ void onMain(){
160181
}
161182
```
162183

184+
### Worker Isolated Event-Loop
185+
```cpp
186+
#include <nodepp/nodepp.h>
187+
#include <nodepp/worker.h>
188+
#include <nodepp/os.h>
189+
190+
using namespace nodepp;
191+
192+
atomic_t<int> shared_variable = 100;
193+
194+
void local_main( int cpu_id ){
195+
196+
// this event-loop runs in it's own isolated worker-thread
197+
198+
process::add( coroutine::add( COROUTINE(){
199+
thread_local static int variable;
200+
// this will create a static variable per thread
201+
static atomic_t<int> shared_variable;
202+
// this will create a shared global variable
203+
int local_variable;
204+
// this is a normal variable only exists here
205+
coBegin
206+
207+
while( shared_variable-->0 ){
208+
console::log( cpu_id, "->", shared_variable.get() );
209+
coDelay(1000); }
210+
211+
coFinish
212+
}));
213+
214+
}
215+
216+
void onMain(){
217+
218+
for( auto x=os::cpus(); x-->0; ){ worker::add([=](){
219+
local_main( x ); process::wait();
220+
return -1; }); }
221+
222+
}
223+
```
224+
163225
### More Examples [here](https://nodeppofficial.github.io/nodepp-doc/guide.html)
164226
165227
## Installing Nodepp
@@ -197,18 +259,6 @@ void onMain() {
197259
- 🔗: [NodePP for Arduino](https://github.com/NodeppOfficial/nodepp-arduino)
198260
- 🔗: [Nodepp for WASM](https://github.com/NodeppOfficial/nodepp-wasm)
199261

200-
## Projects made with NodePP
201-
- 🔗: [Computer Vision VR Controllers for phones Demo](https://github.com/PocketVR/Barely_VR_AR_Controller_Test)
202-
- 🔗: [Draw on your PC using your smartphone](https://github.com/ScreenDraw/PCDraw)
203-
- 🔗: [Simple multiplayer Game With Raylib](https://medium.com/@EDBCBlog/create-your-own-online-multiplayer-small-fast-and-fun-with-raylib-nodepp-and-websockets-190f5c174094)
204-
- 🔗: [Cursed Luna - A simple Raylib Game](https://github.com/EDBCREPO/Space-Shocker)
205-
- 🔗: [Smart Card Reader(Nodepp-Arduino)](https://github.com/EDBCREPO/emv-reader)
206-
- 🔗: [Serial Port arduino using Nodepp](https://github.com/EDBCREPO/Arduino_PC)
207-
- 🔗: [Simple Raylib Real-Time Chat](https://github.com/EDBCREPO/simple-raylib-websocket-chat)
208-
- 🔗: [Simple Bitget Trading Bot](https://github.com/EDBCREPO/simple-binance-bot-nodepp)
209-
210-
Check out some articles on [Medium](https://medium.com/@EDBCBlog)
211-
212262
## Official Libraries for Nodepp
213263
- 🔗: [ExpressPP](https://github.com/NodeppOfficial/nodepp-express) -> Express equivalent for Nodepp
214264
- 🔗: [ApifyPP](https://github.com/NodeppOfficial/nodepp-apify) -> Socket.io equivalent for Nodepp

examples/35-WS-Client.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,19 @@ using namespace nodepp;
88
void onMain() {
99

1010
auto client = ws::client( "ws://localhost:8000/" );
11-
auto cin = fs::std_input();
1211

1312
client.onConnect([=]( ws_t cli ){
1413

1514
console::log("connected", cli.get_peername() );
1615

17-
cli.onData([]( string_t chunk ){
18-
console::log("client:>",chunk);
16+
cli.onData([]( string_t data ){
17+
console::log( data );
1918
});
2019

21-
cin.onData([=]( string_t data ){
22-
cli.write( data );
23-
});
24-
2520
cli.onDrain([=](){
2621
console::log("closed");
27-
cin.close();
2822
});
2923

30-
stream::pipe( cin );
31-
3224
});
3325

3426
client.onError([=]( except_t err ){

examples/37-WSS-Client.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,19 @@ void onMain() {
1010
ssl_t ssl; //ssl_t ssl( "./ssl/cert.key", "./ssl/cert.crt" );
1111

1212
auto client = wss::client( "wss://localhost:8000/", &ssl );
13-
auto cin = fs::std_input();
1413

1514
client.onConnect([=]( wss_t cli ){
1615

1716
console::log("connected");
1817

19-
cli.onData([]( string_t chunk ){
20-
console::log("client:>",chunk);
18+
cli.onData([]( string_t data ){
19+
console::log( data );
2120
});
2221

23-
cin.onData([=]( string_t data ){
24-
cli.write( data );
25-
});
26-
2722
cli.onDrain([=](){
2823
console::log("closed");
29-
cin.close();
3024
});
3125

32-
stream::pipe( cin );
33-
3426
});
3527

3628
client.onError([=]( except_t err ){

examples/38-WS.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,17 @@ void server(){
2121

2222
server.onConnect([=]( ws_t cli ){
2323

24-
auto cin = fs::std_input();
2524
console::log("connected");
2625

27-
cin.onData([=]( string_t data ){
28-
cli.write( data );
29-
});
30-
3126
cli.onData([=]( string_t data ){
32-
console::log( "serv:", data );
27+
cli.write( "<: received" );
28+
console::log( data );
3329
});
3430

3531
cli.onDrain([=](){
3632
console::log("closed");
37-
cin.close();
3833
});
3934

40-
stream::pipe( cin );
41-
4235
});
4336

4437
server.listen( "localhost", 8000, [=]( socket_t server ){
@@ -56,8 +49,8 @@ void client() {
5649
auto cin = fs::std_input();
5750
console::log("connected");
5851

59-
cli.onData([]( string_t chunk ){
60-
console::log("cli:", chunk);
52+
cli.onData([]( string_t data ){
53+
console::log( data );
6154
});
6255

6356
cin.onData([=]( string_t data ){

examples/38-WSS.cpp

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,17 @@ void server(){
2323

2424
server.onConnect([=]( wss_t cli ){
2525

26-
auto cin = fs::std_input();
2726
console::log("connected");
2827

29-
cin.onData([=]( string_t data ){
30-
cli.write( data );
31-
});
32-
3328
cli.onData([=]( string_t data ){
34-
console::log( "serv:", data );
29+
cli.write( "<: received" );
30+
console::log( data );
3531
});
3632

3733
cli.onDrain([=](){
3834
console::log("closed");
39-
cin.close();
4035
});
4136

42-
stream::pipe( cin );
43-
4437
});
4538

4639
server.listen( "localhost", 8000, [=]( ssocket_t server ){
@@ -60,8 +53,8 @@ void client() {
6053
auto cin = fs::std_input();
6154
console::log("connected");
6255

63-
cli.onData([]( string_t chunk ){
64-
console::log("cli:", chunk);
56+
cli.onData([]( string_t data ){
57+
console::log( data );
6558
});
6659

6760
cin.onData([=]( string_t data ){

examples/45-TCPClient.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,16 @@ void onMain(){
1111
client.onOpen([=]( socket_t cli ){
1212

1313
console::log("connected", cli.get_peername() );
14-
auto cin = fs::std_input();
1514

1615
cli.onData([=]( string_t data ){
1716
console::log( data );
1817
});
1918

20-
cin.onData([=]( string_t data ){
21-
cli.write( data );
22-
});
23-
2419
cli.onClose.once([=](){
2520
console::log("closed");
26-
cin.close();
2721
});
2822

2923
stream::pipe( cli );
30-
stream::pipe( cin );
3124

3225
});
3326

examples/46-TCP.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,17 @@ void server(){
1111
server.onConnect([=]( socket_t cli ){
1212

1313
console::log("connected" );
14-
auto cin = fs::std_input();
1514

1615
cli.onData([=]( string_t data ){
16+
cli.write( "<: received" );
1717
console::log( data );
1818
});
1919

20-
cin.onData([=]( string_t data ){
21-
cli.write( data );
22-
});
23-
2420
cli.onDrain.once([=](){
2521
console::log("closed");
26-
cin.close();
2722
});
2823

2924
stream::pipe( cli );
30-
stream::pipe( cin );
3125

3226
});
3327

examples/46-TCPServer.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,16 @@ void onMain(){
1111
server.onConnect([=]( socket_t cli ){
1212

1313
console::log("connected", cli.get_peername() );
14-
auto cin = fs::std_input();
1514

1615
cli.onData([=]( string_t data ){
1716
console::log( data );
1817
});
1918

20-
cin.onData([=]( string_t data ){
21-
cli.write( data );
22-
});
23-
2419
cli.onDrain.once([=](){
2520
console::log("closed");
26-
cin.close();
2721
});
2822

2923
stream::pipe( cli );
30-
stream::pipe( cin );
3124

3225
});
3326

examples/47-UDPClient.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,16 @@ void onMain(){
1111
client.onConnect([=]( socket_t cli ){
1212

1313
console::log("connected", cli.get_peername() );
14-
auto cin = fs::std_input();
1514

1615
cli.onData([=]( string_t data ){
1716
console::log( data );
1817
});
1918

20-
cin.onData([=]( string_t data ){
21-
cli.write( data );
22-
});
23-
2419
cli.onDrain.once([=](){
2520
console::log("closed");
26-
cin.close();
2721
});
2822

2923
stream::pipe( cli );
30-
stream::pipe( cin );
3124

3225
});
3326

examples/48-UDP.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,17 @@ void server(){
1111
server.onConnect([=]( socket_t cli ){
1212

1313
console::log("connected" );
14-
auto cin = fs::std_input();
1514

1615
cli.onData([=]( string_t data ){
16+
cli.write( "<: received" );
1717
console::log( data );
1818
});
1919

20-
cin.onData([=]( string_t data ){
21-
cli.write( data );
22-
});
23-
2420
cli.onDrain.once([=](){
2521
console::log("closed");
26-
cin.close();
2722
});
2823

2924
stream::pipe( cli );
30-
stream::pipe( cin );
3125

3226
});
3327

0 commit comments

Comments
 (0)