https://github.com/eintim23/switchws
https://github.com/eintim23/switchws
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/eintim23/switchws
- Owner: EinTim23
- License: unlicense
- Created: 2022-12-28T18:26:42.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-29T09:40:18.000Z (over 3 years ago)
- Last Synced: 2025-03-12T00:44:40.518Z (over 1 year ago)
- Language: C++
- Size: 6.84 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Switch WS
A websocket client library that targets the nintendo switch. It uses [easywsclient](https://github.com/dhbaird/easywsclient) as reference.
### Known issues
- The library doesn't verify the SSL certificates which might lead to security issues
- Only SSL secured websockets are supported(plaintext will be added back later)
- You currently can't open multiple sockets at once because the mbedtls variables are global (will be fixed once I have time, I did it like that for testing purposes)
### Example
```cpp
#include
#include
using switchws::WebSocket;
int main(int argc, char* argv[]) {
consoleInit(NULL);
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
PadState pad;
padInitializeDefault(&pad);
socketInitializeDefault();
WebSocket::pointer ws = WebSocket::from_url("wss://example.com");
if(ws == NULL)
goto exit;
ws->send("test");
while (ws->getReadyState() != WebSocket::CLOSED && appletMainLoop())
{
padUpdate(&pad);
u64 kDown = padGetButtonsDown(&pad);
if (kDown & HidNpadButton_Plus)
break;
ws->poll();
ws->dispatch([ws](const std::string & message) {
std::cout << message << std::endl;
consoleUpdate(NULL);
});
consoleUpdate(NULL);
}
exit:
socketExit();
consoleExit(NULL);
return 0;
}
delete ws;
```