Last active
March 9, 2019 00:39
-
-
Save BrennanConroy/af393d101b8b4ab192ebfe34f3e934a2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class transport | |
{ | |
void start(std::string url, transfer_format format, std::function<void(std::exception_ptr)> callback); | |
void stop(std::function<void(std::exception_ptr)> callback); | |
void on_close(std::function<void(std::exception_ptr)>); | |
void send(std::string payload, std::function<void(std::exception_ptr)> callback); | |
void on_receive(std::function<void(std::string, std::exception_ptr)> callback); | |
} | |
// need to figure out text vs binary | |
class websocket | |
{ | |
void start(std::string url, transfer_format format, std::function<void(std::exception_ptr)> callback); | |
void stop(std::function<void(std::exception_ptr)> callback); | |
void on_close(std::function<void(std::exception_ptr)>); | |
void send(std::string payload, std::function<void(std::exception_ptr)> callback); | |
void on_receive(std::function<void(std::string, std::exception_ptr)> callback); | |
} | |
enum transport_type | |
{ | |
WEBSOCKET; | |
} | |
/*class transport_factory | |
{ | |
// pass logger to create_transport? or transport.start? | |
std::shared_ptr<transport> create_transport(transport_type types); | |
}*/ | |
enum http_method | |
{ | |
GET, | |
POST; | |
} | |
class http_request | |
{ | |
http_method method; | |
std::map<std::string, std::string> headers; | |
std::string content; | |
int timeout; | |
// ??? | |
} | |
class http_response | |
{ | |
int status_code; | |
std::string content; | |
} | |
class http_client | |
{ | |
// could remove post and get? | |
// void post(std::string url, http_request, std::function<void(http_response, std::exception_ptr)> callback); | |
// void get(std::string url, http_request, std::function<void(http_response, std::exception_ptr)> callback); | |
void send(std::string url, http_request, std::function<void(http_response, std::exception_ptr)> callback); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment