MCPcopy Create free account
hub / github.com/Clarionos/clarion / testNet

Function testNet

tests/web/a.cpp:43–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41}
42
43clintrinsics::Task<> testNet()
44{
45 clintrinsics::Connection myConnection{"ws", "localhost", 9125};
46 myConnection.onOpen = []() { printf("connection opened!\n"); };
47 myConnection.onMessage = [](clintrinsics::ExternalBytes data) {
48 printf("received bytes handle: %p -- size: %d\n", data.handle,
49 (int)data.toUint8Vector().size());
50 };
51 myConnection.onClose = [](uint32_t code) { printf("connection closed code: %d\n", code); };
52 myConnection.onError = []() { printf("client connection has failed!\n"); };
53 co_await myConnection.connect();
54
55 printf(">> connection handle: %p\n", myConnection.handle);
56 co_await myConnection.sendMessage("hey there from CLARION wasm! :)\n"); // todo: make send async
57 printf(">> message sent!\n");
58
59 co_await clintrinsics::later(5000); // waits for some messages exchanges before closing it
60
61 myConnection.close();
62 printf(">> connection closed!\n");
63}
64
65clintrinsics::Task<bool> testHashing()
66{

Callers 1

testFunction · 0.85

Calls 6

laterFunction · 0.85
toUint8VectorMethod · 0.80
sendMessageMethod · 0.80
sizeMethod · 0.45
connectMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected