2020-03-03 21:12:06 +03:00
|
|
|
// Licensed to the .NET Foundation under one or more agreements.
|
|
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
|
|
// See the LICENSE file in the project root for more information.
|
2019-04-02 22:14:15 +03:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-06 23:49:07 +03:00
|
|
|
#ifdef USE_CPPRESTSDK
|
2020-04-14 23:05:15 +03:00
|
|
|
#pragma warning (push)
|
|
|
|
#pragma warning (disable : 5204 4355 4625 4626 4868)
|
|
|
|
#include <cpprest/http_client.h>
|
|
|
|
#include <cpprest/ws_client.h>
|
|
|
|
#pragma warning (pop)
|
2019-11-06 23:49:07 +03:00
|
|
|
#endif
|
|
|
|
|
2019-04-02 22:14:15 +03:00
|
|
|
#include "_exports.h"
|
2020-02-05 03:06:57 +03:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2021-04-14 18:54:49 +03:00
|
|
|
#include "scheduler.h"
|
|
|
|
#include <memory>
|
2019-04-02 22:14:15 +03:00
|
|
|
|
|
|
|
namespace signalr
|
|
|
|
{
|
|
|
|
class signalr_client_config
|
|
|
|
{
|
|
|
|
public:
|
2020-02-05 03:06:57 +03:00
|
|
|
#ifdef USE_CPPRESTSDK
|
2019-04-02 22:14:15 +03:00
|
|
|
SIGNALRCLIENT_API void __cdecl set_proxy(const web::web_proxy &proxy);
|
|
|
|
// Please note that setting credentials does not work in all cases.
|
|
|
|
// For example, Basic Authentication fails under Win32.
|
|
|
|
// As a workaround, you can set the required authorization headers directly
|
|
|
|
// using signalr_client_config::set_http_headers
|
|
|
|
SIGNALRCLIENT_API void __cdecl set_credentials(const web::credentials &credentials);
|
|
|
|
|
|
|
|
SIGNALRCLIENT_API web::http::client::http_client_config __cdecl get_http_client_config() const;
|
|
|
|
SIGNALRCLIENT_API void __cdecl set_http_client_config(const web::http::client::http_client_config& http_client_config);
|
|
|
|
|
|
|
|
SIGNALRCLIENT_API web::websockets::client::websocket_client_config __cdecl get_websocket_client_config() const noexcept;
|
|
|
|
SIGNALRCLIENT_API void __cdecl set_websocket_client_config(const web::websockets::client::websocket_client_config& websocket_client_config);
|
2020-02-05 03:06:57 +03:00
|
|
|
#endif
|
2019-04-02 22:14:15 +03:00
|
|
|
|
2021-08-06 20:44:57 +03:00
|
|
|
SIGNALRCLIENT_API signalr_client_config();
|
2021-04-14 18:54:49 +03:00
|
|
|
|
2020-02-05 03:06:57 +03:00
|
|
|
SIGNALRCLIENT_API const std::map<std::string, std::string>& __cdecl get_http_headers() const noexcept;
|
|
|
|
SIGNALRCLIENT_API std::map<std::string, std::string>& __cdecl get_http_headers() noexcept;
|
|
|
|
SIGNALRCLIENT_API void __cdecl set_http_headers(const std::map<std::string, std::string>& http_headers);
|
2021-04-14 18:54:49 +03:00
|
|
|
SIGNALRCLIENT_API void __cdecl set_scheduler(std::shared_ptr<scheduler> scheduler);
|
|
|
|
SIGNALRCLIENT_API const std::shared_ptr<scheduler>& __cdecl get_scheduler() const noexcept;
|
2021-07-23 23:17:54 +03:00
|
|
|
SIGNALRCLIENT_API void set_handshake_timeout(std::chrono::milliseconds);
|
|
|
|
SIGNALRCLIENT_API std::chrono::milliseconds get_handshake_timeout() const noexcept;
|
2022-03-08 21:07:52 +03:00
|
|
|
SIGNALRCLIENT_API void set_server_timeout(std::chrono::milliseconds);
|
|
|
|
SIGNALRCLIENT_API std::chrono::milliseconds get_server_timeout() const noexcept;
|
|
|
|
SIGNALRCLIENT_API void set_keepalive_interval(std::chrono::milliseconds);
|
|
|
|
SIGNALRCLIENT_API std::chrono::milliseconds get_keepalive_interval() const noexcept;
|
2019-04-02 22:14:15 +03:00
|
|
|
|
|
|
|
private:
|
2020-02-05 03:06:57 +03:00
|
|
|
#ifdef USE_CPPRESTSDK
|
2019-04-02 22:14:15 +03:00
|
|
|
web::http::client::http_client_config m_http_client_config;
|
|
|
|
web::websockets::client::websocket_client_config m_websocket_client_config;
|
2019-11-06 23:49:07 +03:00
|
|
|
#endif
|
2020-02-05 03:06:57 +03:00
|
|
|
std::map<std::string, std::string> m_http_headers;
|
2021-04-14 18:54:49 +03:00
|
|
|
std::shared_ptr<scheduler> m_scheduler;
|
2021-07-23 23:17:54 +03:00
|
|
|
std::chrono::milliseconds m_handshake_timeout;
|
2022-03-08 21:07:52 +03:00
|
|
|
std::chrono::milliseconds m_server_timeout;
|
|
|
|
std::chrono::milliseconds m_keepalive_interval;
|
2019-04-02 22:14:15 +03:00
|
|
|
};
|
|
|
|
}
|