diff options
| author | ilotterytea <iltsu@alright.party> | 2024-04-20 23:22:45 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2024-04-20 23:22:45 +0500 |
| commit | 9953a68a5d1918ad6e77a7c614279d14ab1c6bc0 (patch) | |
| tree | d1e70937671e9aafbde36fa7b8406f92ed0343a0 /src | |
| parent | f80792c6e0e0ef167132ccec65105bb6a422031f (diff) | |
feat: connecting to twitch irc servers
Diffstat (limited to 'src')
| -rw-r--r-- | src/irc/client.cpp | 29 | ||||
| -rw-r--r-- | src/irc/client.hpp | 2 | ||||
| -rw-r--r-- | src/main.cpp | 2 |
3 files changed, 33 insertions, 0 deletions
diff --git a/src/irc/client.cpp b/src/irc/client.cpp index a4a2e5c..470bad9 100644 --- a/src/irc/client.cpp +++ b/src/irc/client.cpp @@ -1,5 +1,9 @@ #include "client.hpp" +#include <ixwebsocket/IXWebSocketMessage.h> +#include <ixwebsocket/IXWebSocketMessageType.h> + +#include <iostream> #include <string> using namespace RedpilledBot::IRC; @@ -13,3 +17,28 @@ Client::Client(std::string username, std::string password) { this->websocket.setUrl(this->host + ":" + this->port); } + +void Client::run() { + this->websocket.setOnMessageCallback( + [this](const ix::WebSocketMessagePtr &msg) { + switch (msg->type) { + case ix::WebSocketMessageType::Message: { + std::cout << "Got a message: " << msg->str << std::endl; + break; + } + case ix::WebSocketMessageType::Open: { + std::cout << "Connected to Twitch IRC!\n"; + break; + } + case ix::WebSocketMessageType::Close: { + std::cout << "Twitch IRC Connection closed!\n"; + break; + } + default: { + break; + } + } + }); + + this->websocket.run(); +} diff --git a/src/irc/client.hpp b/src/irc/client.hpp index 18e9854..52c8cbf 100644 --- a/src/irc/client.hpp +++ b/src/irc/client.hpp @@ -11,6 +11,8 @@ namespace RedpilledBot { Client(std::string username, std::string password); ~Client() = default; + void run(); + private: std::string username; std::string password; diff --git a/src/main.cpp b/src/main.cpp index 34839eb..3e13f5c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -7,5 +7,7 @@ int main(int argc, char *argv[]) { RedpilledBot::IRC::Client client("", ""); + client.run(); + return 0; } |
