Skip to content

Commit c4cce1e

Browse files
committed
📌 Nodepp | Bug Fixing | V1.3.2 📌
1 parent 7cbc6b4 commit c4cce1e

38 files changed

+961
-478
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
image.jpg
12
main.exe
23
main

examples/0-Terminal_Color.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,30 @@
22

33
using namespace nodepp;
44

5-
void onMain() {
5+
void onMain(){
66

7-
conio::background( conio::color::cyan | conio::color::bold );
8-
console::log( "hello world!" );
9-
conio::reset();
10-
11-
conio::foreground( conio::color::red | conio::color::bold );
12-
console::log( "hello world!" );
13-
conio::reset();
14-
15-
conio::background( conio::color::magenta | conio::color::bold );
16-
console::log( "hello world!" );
17-
conio::reset();
18-
19-
conio::foreground( conio::color::blue | conio::color::bold );
20-
console::log( "hello world!" );
21-
conio::reset();
22-
23-
conio::background( conio::color::yellow | conio::color::bold );
24-
console::log( "hello world!" );
25-
conio::reset();
26-
277
conio::foreground( conio::color::green | conio::color::bold );
28-
console::log( "hello world!" );
29-
conio::reset();
8+
conio::log(" Hello World! \n");
9+
10+
conio::foreground( conio::color::red | conio::color::bold );
11+
conio::log(" Hello World! \n");
12+
13+
conio::foreground( conio::color::yellow | conio::color::bold );
14+
conio::log(" Hello World! \n");
15+
16+
conio::foreground( conio::color::cyan | conio::color::bold );
17+
conio::log(" Hello World! \n");
18+
19+
conio::foreground( conio::color::magenta | conio::color::bold );
20+
conio::log(" Hello World! \n");
21+
22+
conio::foreground( conio::color::white | conio::color::bold );
23+
conio::log(" Hello World! \n");
24+
25+
conio::foreground( conio::color::black | conio::color::bold );
26+
conio::background( conio::color::white );
27+
conio::log(" Hello World! \n");
28+
29+
conio::log(" Hello World! \n");
3030

3131
}

examples/14-Event.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,18 @@ void onMain(){
1212
ev.on([](){ console::done(" World 1 "); });
1313

1414
// create an event that can be emitted once
15-
ev.on([](){ console::done(" hello "); });
15+
ev.once([](){ console::done(" hello "); });
1616

1717
// Emit Events
1818
ev.emit();
1919
console::log( "->", ev.size() );
2020

21-
// Clear Even Queue
21+
// Clear Event Queue
2222
ev.clear();
2323

24-
// turn of an specific event
24+
// turn off an specific event
2525
auto item = ev.on([](){
26-
console::log("me cago en la puta");
26+
console::log("hello world!");
2727
});
2828
console::log( "->", ev.size() );
2929

examples/17-Date.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ void onMain() {
77

88
auto time1 = date_t( 2025, 7, 9, false );
99
auto time2 = date_t( 2025, 7, 19, false );
10-
auto time3 = date2 - date1;
10+
auto time3 = time2 - time1;
1111

1212
console::log( "days left:", time3.get_day() );
1313

14-
}
14+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#include <nodepp/nodepp.h>
2+
#include <nodepp/https.h>
3+
4+
using namespace nodepp;
5+
6+
void onMain(){
7+
8+
ssl_t ssl; // ( "./ssl/cert.key", "./ssl/cert.crt" );
9+
10+
fetch_t args;
11+
args.method = "GET";
12+
args.url = "https://www.wearegecko.co.uk/media/50316/mountain-3.jpg";
13+
args.headers = header_t({
14+
{ "Host", url::host(args.url) }
15+
});
16+
17+
// args.file = file_t("PATH","r");
18+
// args.body = "MYBODY";
19+
20+
https::fetch( args, &ssl )
21+
22+
.then([]( https_t cli ){
23+
cli.onDrain([](){ console::log( "done" ); });
24+
file_t file ( "image.jpg", "w" );
25+
stream::pipe( cli, file );
26+
})
27+
28+
.fail([]( except_t err ){
29+
console::error( err );
30+
});
31+
32+
}

examples/39-WS-load-test.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,20 @@ void client( int x ) {
1212

1313
auto client = ws::client( "ws://localhost:8000/" );
1414

15-
client.onConnect([=]( ws_t cli ){ for( auto y=100; y-->0; ){
15+
client.onConnect([=]( ws_t cli ){ for( auto y=100; y-->0; ){
1616

1717
auto raw = type::bind( cli );
18-
auto stt = type::bind( int(0) );
19-
auto idx = type::bind( int(10) );
20-
auto wrt = type::bind( _file_::write() );
21-
22-
process::add([=](){ auto _state_ = *stt;
23-
gnStart while( (*idx)-->0 ){
24-
coWait( (*wrt)(&raw,regex::format( "Hello World ${0} ${1} ${2}", x, y, *idx ))==1 );
25-
} gnStop });
18+
auto idx = type::bind( int(1000) );
19+
auto wrt = type::bind( generator::file::write() );
20+
21+
process::add( coroutine::add( COROUTINE(){
22+
coBegin
23+
24+
while( (*idx)-->0 ){
25+
coWait( (*wrt)(&raw,regex::format( "Hello World ${0} ${1} ${2}", x, y, *idx ))==1 );
26+
}
27+
28+
coFinish }));
2629

2730
}});
2831

@@ -53,4 +56,10 @@ void server(){
5356

5457
}
5558

56-
void onMain() { server(); for( auto x=10; x-->0; ){ client(x); } }
59+
void onMain() {
60+
if( process::env::get( "mode" )!="client" ){
61+
server();
62+
} else {
63+
for( auto x=10; x-->0; ){ client(x); }
64+
}
65+
}

examples/4-Garbage-Colector.cpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,40 @@ using namespace nodepp;
44

55
void onMain(){
66

7-
ptr_t<uint> GC = new uint(10);
7+
ptr_t<int> GC ( 0UL, 10 ); // SSO optimization and automatic heap
8+
// ptr_t<int> GC = new int(10); // No SSO optimization always heap
9+
// ptr_t<int> GC = type::bind( (int)10 ) // SSO optimization and automatic heap
10+
// ptr_t<int> GC = type::bind( new int(10) ) // NEVER USE ( new ) WITH TYPE::BIND
811

9-
console::log("-- --");
10-
console::log( "value->", *GC );
12+
console::log("-- 0 --");
1113
console::log( "addr ->", GC );
14+
console::log( "value->", *GC );
1215
console::log( "count->", GC.count() );
1316

14-
process::add([=](){ // <- note = and not & | this is important to correctly share the memory across tasks
15-
16-
console::log("-- --");
17-
console::log( "value->", *GC );
17+
process::add([=](){
18+
console::log("-- 1 --");
1819
console::log( "addr ->", GC );
20+
console::log( "value->", *GC );
1921
console::log( "count->", GC.count() );
22+
return -1; });
2023

21-
return -1;
22-
});
23-
24-
process::await([&](){ // <- note & instead = | but you are still able to use =
25-
26-
console::log("-- --");
27-
console::log( "value->", *GC );
24+
process::await([&](){
25+
console::log("-- 2 --");
2826
console::log( "addr ->", GC );
27+
console::log( "value->", *GC );
2928
console::log( "count->", GC.count() );
29+
return -1; });
3030

31-
return -1;
31+
process::onSIGCLOSE.once([=](){
32+
console::log("-- 3 --");
33+
console::log( "addr ->", GC );
34+
console::log( "value->", *GC );
35+
console::log( "count->", GC.count() );
3236
});
3337

34-
console::log("-- --");
35-
console::log( "value->", *GC );
38+
console::log("-- 4 --");
3639
console::log( "addr ->", GC );
40+
console::log( "value->", *GC );
3741
console::log( "count->", GC.count() );
3842

3943
}

examples/42-CryptoDH.cpp

Lines changed: 0 additions & 18 deletions
This file was deleted.

examples/42-crypto_DH.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#include <nodepp/nodepp.h>
2+
#include <nodepp/encoder.h>
3+
#include <nodepp/crypto.h>
4+
5+
using namespace nodepp;
6+
7+
void onMain(){
8+
9+
crypto::sign::DH key; key.generate_keys();
10+
11+
auto skey = key.get_public_key();
12+
auto sign = key.sign( skey );
13+
14+
console::log( sign );
15+
console::log( "verified", key.verify( skey, sign ) );
16+
17+
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ using namespace nodepp;
66

77
void onMain(){
88

9-
crypto::sign::DSA ppt;
9+
crypto::sign::DSA ppt; ppt.generate_keys();
10+
1011
string_t msg = "Hello World!";
1112
auto sign = ppt.sign( msg );
1213
ptr_t<uchar> data ( sign.size() );

0 commit comments

Comments
 (0)