diff options
Diffstat (limited to 'bridge')
-rw-r--r-- | bridge/BridgeService.cpp | 41 | ||||
-rw-r--r-- | bridge/BridgeService.hpp | 41 | ||||
-rw-r--r-- | bridge/DiscordService.cpp | 43 | ||||
-rw-r--r-- | bridge/DiscordService.hpp | 28 |
4 files changed, 0 insertions, 153 deletions
diff --git a/bridge/BridgeService.cpp b/bridge/BridgeService.cpp deleted file mode 100644 index 0b52643..0000000 --- a/bridge/BridgeService.cpp +++ /dev/null @@ -1,41 +0,0 @@ -#include "BridgeService.hpp" - -namespace dchat -{ - BridgeServiceUser::BridgeServiceUser(Type _type, const std::string &_name) : - User(User::Type::OTHER), - type(_type), - name(_name) - { - - } - - BridgeService::BridgeService() - { - - } - - BridgeService::~BridgeService() - { - for(User *user : users) - { - delete user; - } - } - - bool BridgeService::addUser(BridgeServiceUser *user) - { - for(User *existingUser : users) - { - if(static_cast<BridgeServiceUser*>(existingUser)->equals(user)) - return false; - } - users.push_back(user); - return true; - } - - const std::vector<User*>& BridgeService::getUsers() const - { - return users; - } -}
\ No newline at end of file diff --git a/bridge/BridgeService.hpp b/bridge/BridgeService.hpp deleted file mode 100644 index e536c81..0000000 --- a/bridge/BridgeService.hpp +++ /dev/null @@ -1,41 +0,0 @@ -#pragma once - -#include <vector> -#include <string> -#include "../include/User.hpp" - -namespace dchat -{ - class BridgeServiceUser : public User - { - public: - enum class Type - { - DISCORD - }; - - BridgeServiceUser(Type type, const std::string &name); - virtual ~BridgeServiceUser(){} - - virtual const std::string& getName() const override { return name; } - virtual bool isConnected(i64 timestampUtcSec) const override { return true; } - - virtual bool equals(BridgeServiceUser *other) const = 0; - - const Type type; - private: - std::string name; - }; - - class BridgeService - { - public: - BridgeService(); - virtual ~BridgeService(); - - bool addUser(BridgeServiceUser *user); - const std::vector<User*>& getUsers() const; - protected: - std::vector<User*> users; - }; -}
\ No newline at end of file diff --git a/bridge/DiscordService.cpp b/bridge/DiscordService.cpp deleted file mode 100644 index a4546a8..0000000 --- a/bridge/DiscordService.cpp +++ /dev/null @@ -1,43 +0,0 @@ -#include "DiscordService.hpp" - -namespace dchat -{ - DiscordServiceUser::DiscordServiceUser(const std::string &name, const u64 _id, bool _connected) : - BridgeServiceUser(Type::DISCORD, name), - id(_id), - connected(_connected) - { - - } - - bool DiscordServiceUser::equals(BridgeServiceUser *other) const - { - return other && type == other->type && id == static_cast<DiscordServiceUser*>(other)->id; - } - - bool DiscordService::removeUser(u64 discordUserId) - { - for(auto it = users.begin(), end = users.end(); it != end; ++it) - { - BridgeServiceUser *serviceUser = static_cast<BridgeServiceUser*>(*it); - if(serviceUser->type == BridgeServiceUser::Type::DISCORD && static_cast<DiscordServiceUser*>(serviceUser)->id == discordUserId) - { - delete serviceUser; - users.erase(it); - return true; - } - } - return false; - } - - DiscordServiceUser* DiscordService::getUserById(u64 discordUserId) - { - for(User *user : users) - { - BridgeServiceUser *serviceUser = static_cast<BridgeServiceUser*>(user); - if(serviceUser->type == BridgeServiceUser::Type::DISCORD && static_cast<DiscordServiceUser*>(serviceUser)->id == discordUserId) - return static_cast<DiscordServiceUser*>(serviceUser); - } - return nullptr; - } -}
\ No newline at end of file diff --git a/bridge/DiscordService.hpp b/bridge/DiscordService.hpp deleted file mode 100644 index c778c41..0000000 --- a/bridge/DiscordService.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#pragma once - -#include "BridgeService.hpp" - -namespace dchat -{ - class DiscordServiceUser : public BridgeServiceUser - { - public: - DiscordServiceUser(const std::string &name, const u64 id, bool connected); - virtual ~DiscordServiceUser(){} - - virtual bool isConnected(i64 timestampUtcSec) const override { return connected; } - bool equals(BridgeServiceUser *other) const override; - - const u64 id; - bool connected; - }; - - class DiscordService : public BridgeService - { - public: - virtual ~DiscordService(){} - - bool removeUser(u64 discordUserId); - DiscordServiceUser* getUserById(u64 discordUserId); - }; -}
\ No newline at end of file |