Adjusted workflow.
This commit is contained in:
113
include/ehs/io/socket/rest/Spotify.h
Normal file
113
include/ehs/io/socket/rest/Spotify.h
Normal file
@@ -0,0 +1,113 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
#include "ehs/Array.h"
|
||||
#include "ehs/io/socket/SSL.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
enum class SpotifyState
|
||||
{
|
||||
TRACK,
|
||||
CONTEXT,
|
||||
OFF
|
||||
};
|
||||
|
||||
struct Track
|
||||
{
|
||||
Array<Str_8> artists;
|
||||
Str_8 name;
|
||||
Str_8 id;
|
||||
};
|
||||
|
||||
class Spotify
|
||||
{
|
||||
private:
|
||||
SSL client;
|
||||
Str_8 clientId;
|
||||
Str_8 secret;
|
||||
Str_8 redURI;
|
||||
Array<Str_8> scopes;
|
||||
bool forceVerify;
|
||||
Str_8 token;
|
||||
Str_8 rToken;
|
||||
|
||||
public:
|
||||
static const Str_8 trackUriPrefix;
|
||||
|
||||
virtual ~Spotify();
|
||||
|
||||
Spotify();
|
||||
|
||||
Spotify(const Str_8& clientId, const Str_8& secret, const Str_8& redURI, const Array<Str_8>& scopes, const bool forceVerify);
|
||||
|
||||
bool Authorize();
|
||||
|
||||
/// Sets the volume for a device.
|
||||
/// @param [in] level The percentage to set the volume to.
|
||||
/// @returns The response code.
|
||||
UInt_32 SetVolume(const UInt_8 level);
|
||||
|
||||
/// Resume playback for a device.
|
||||
/// @returns The response code.
|
||||
UInt_32 Play();
|
||||
|
||||
/// Pauses playback for a device.
|
||||
/// @returns The response code.
|
||||
UInt_32 Pause();
|
||||
|
||||
/// Repeats playback for a device.
|
||||
/// @param [in] status The status to set it to.
|
||||
/// @returns The response code.
|
||||
UInt_32 SetRepeat(const SpotifyState state);
|
||||
|
||||
/// Shuffles playback for a device.
|
||||
/// @param [in] state The state to set shuffle to.
|
||||
/// @returns The response code.
|
||||
UInt_32 SetShuffle(const bool state);
|
||||
|
||||
UInt_32 SearchTrack(Vector<Str_8>& artists, Str_8& id, Str_8& name);
|
||||
|
||||
UInt_32 GetPlayingTrack(Vector<Str_8>& artists, Str_8& id, Str_8& name);
|
||||
|
||||
UInt_32 GetQueue(Array<Track>& tracks);
|
||||
|
||||
/// Adds a track to the queue for a device.
|
||||
/// @param [in] uri The track id to add.
|
||||
/// @returns The response code.
|
||||
UInt_32 QueueTrack(const Str_8& id);
|
||||
|
||||
UInt_32 AddTracks(const Str_8& playlistId, const Array<Str_8>& trackIds, const UInt_32 pos = 0);
|
||||
|
||||
UInt_32 AddTrack(const Str_8& playlistId, const Str_8& trackId, const UInt_32 pos = 0);
|
||||
|
||||
/// Skips to the next track.
|
||||
/// @returns The response code.
|
||||
UInt_32 Skip();
|
||||
|
||||
/// Skips to the previous track.
|
||||
/// @returns The response code.
|
||||
UInt_32 Previous();
|
||||
|
||||
/// Seeks to a position of the currently playing track in milliseconds.
|
||||
/// @param [in] pos The position in milliseconds to seek to.
|
||||
/// @returns The response code.
|
||||
UInt_32 Seek(const UInt_32 pos);
|
||||
|
||||
Str_8 GetClientId() const;
|
||||
|
||||
Str_8 GetSecret() const;
|
||||
|
||||
Str_8 GetRedURI() const;
|
||||
|
||||
bool IsVerificationForced() const;
|
||||
|
||||
bool IsActive() const;
|
||||
|
||||
private:
|
||||
void StartConnection();
|
||||
|
||||
bool ReAuthorize();
|
||||
};
|
||||
}
|
39
include/ehs/io/socket/rest/Twitch.h
Normal file
39
include/ehs/io/socket/rest/Twitch.h
Normal file
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
#include "ehs/io/socket/SSL.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class Twitch
|
||||
{
|
||||
private:
|
||||
SSL client;
|
||||
Str_8 clientId;
|
||||
Str_8 secret;
|
||||
Str_8 redURI;
|
||||
Array<Str_8> scopes;
|
||||
bool forceVerify;
|
||||
Str_8 token;
|
||||
|
||||
public:
|
||||
virtual ~Twitch();
|
||||
|
||||
Twitch();
|
||||
|
||||
Twitch(const Str_8& clientId, const Str_8& secret, const Str_8& redURI, const Array<Str_8>& scopes, const bool forceVerify);
|
||||
|
||||
bool Authorize();
|
||||
|
||||
Str_8 GetClientId() const;
|
||||
|
||||
Str_8 GetSecret() const;
|
||||
|
||||
Str_8 GetRedURI() const;
|
||||
|
||||
bool IsVerificationForced() const;
|
||||
|
||||
Str_8 GetToken() const;
|
||||
};
|
||||
}
|
53
include/ehs/io/socket/rest/TwitchChat.h
Normal file
53
include/ehs/io/socket/rest/TwitchChat.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
#include "ehs/io/socket/TCP.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class TwitchChat
|
||||
{
|
||||
private:
|
||||
TCP client;
|
||||
Str_8 username;
|
||||
Str_8 token;
|
||||
Str_8 channel;
|
||||
bool initialized;
|
||||
|
||||
public:
|
||||
~TwitchChat();
|
||||
|
||||
TwitchChat();
|
||||
|
||||
TwitchChat(const Str_8& username);
|
||||
|
||||
TwitchChat(const Str_8& username, const Str_8& token);
|
||||
|
||||
TwitchChat(const TwitchChat& chat);
|
||||
|
||||
TwitchChat& operator=(const TwitchChat& chat);
|
||||
|
||||
void SetToken(const Str_8& newToken);
|
||||
|
||||
void Initialize();
|
||||
|
||||
void UnInitialize();
|
||||
|
||||
void JoinChannel(const Str_8& newChannel);
|
||||
|
||||
void LeaveChannel();
|
||||
|
||||
void SendPong();
|
||||
|
||||
void SendMsg(const Str_8& msg);
|
||||
|
||||
void WhisperMsg(const Str_8& user, const Str_8& msg);
|
||||
|
||||
Str_8 RecvMsg();
|
||||
|
||||
Str_8 GetUsername() const;
|
||||
|
||||
Str_8 GetChannel() const;
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user