Skip to main content

include/sleepy_discord/custom_session.h

Namespaces​

Name
SleepyDiscord

Classes​

Name
classSleepyDiscord::CustomSession

Types​

Name
typedef GenericSession (const)()CustomInit
typedef CustomInitCustomInitSession

Types Documentation​

typedef CustomInit​

typedef GenericSession*(*const SleepyDiscord::CustomInit) ();

typedef CustomInitSession​

typedef CustomInit SleepyDiscord::CustomInitSession;

Source code​

#pragma once
#include <memory>
#include "http.h"

namespace SleepyDiscord {
typedef GenericSession* (*const CustomInit)(); //keep compatibility with old code
typedef CustomInit CustomInitSession;

class CustomSession : public GenericSession {
public:
static CustomInitSession init;
CustomSession() : session(init()) {}
inline void setUrl(const std::string& url) { session->setUrl(url); }
inline void setBody(const std::string* jsonParamters) { session->setBody(jsonParamters); }
inline void setHeader(const std::vector<HeaderPair>& header) {
session->setHeader(header);
}
inline void setMultipart(const std::vector<Part>& parts) {
session->setMultipart(parts);
}
inline void setResponseCallback(const ResponseCallback& callback) {
session->setResponseCallback(callback);
}
inline Response request(RequestMethod method) {
return session->request(method);
}
private:
std::unique_ptr<GenericSession> session; //pointer to session
};

typedef CustomSession Session;
}

Updated on 13 April 2022 at 18:39:59 UTC