PIChunkStream::set() new feature
This commit is contained in:
36
main.cpp
36
main.cpp
@@ -1,11 +1,39 @@
|
||||
#include "pip.h"
|
||||
|
||||
|
||||
PIPeer p0("p0"), p1("p1");
|
||||
//PIPeer p0("p0"), p1("p1");
|
||||
|
||||
int main() {
|
||||
|
||||
PIMap<uint, int> sends, recs;
|
||||
PIByteArray ba, bd, ext;
|
||||
bd.resize(4096);
|
||||
for (int i = 0; i < bd.size_s(); ++i) bd[i] = rand() % 256;
|
||||
uint hash = bd.hash();
|
||||
piCout << hash;
|
||||
{
|
||||
PIChunkStream cs;
|
||||
cs.add(1, PIString("string")).add(3, 123456).add(2, PIString("!!-second-!!"));
|
||||
ba = cs.data();
|
||||
}
|
||||
//piCout << ba.toHex();
|
||||
{
|
||||
PIChunkStream cs(ba);
|
||||
cs.readAll();
|
||||
PIString s1, s2; int i = 0;
|
||||
cs.get(1, s1).get(3, i).get(2, s2);
|
||||
piCout << s1 << s2 << i;
|
||||
cs.set(3, PIString("WHATSAP!"));
|
||||
cs.set(1, bd);
|
||||
ba = cs.data();
|
||||
}
|
||||
//piCout << ba.toHex();
|
||||
{
|
||||
PIChunkStream cs(ba);
|
||||
cs.readAll();
|
||||
PIString s1, s2, s3;
|
||||
cs.get(1, ext).get(2, s2).get(3, s3);
|
||||
piCout << ext.hash() << s2 << s3;
|
||||
}
|
||||
/*PIMap<uint, int> sends, recs;
|
||||
PISet<uint> errors, missed;
|
||||
|
||||
CONNECTL(&p0, dataReceivedEvent, ([&](const PIString & from, const PIByteArray & data){
|
||||
@@ -38,7 +66,7 @@ int main() {
|
||||
for (int i = 0; i < count; ++i)
|
||||
if (!recs.contains(i)) missed << i;
|
||||
piCout << "errors" << errors;
|
||||
piCout << "missed" << missed;
|
||||
piCout << "missed" << missed;*/
|
||||
|
||||
|
||||
/*PIDataTransfer tr0, tr1;
|
||||
|
||||
Reference in New Issue
Block a user