-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathhub_connection.h
More file actions
63 lines (47 loc) · 2.79 KB
/
Copy pathhub_connection.h
File metadata and controls
63 lines (47 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// 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.
#pragma once
#include "_exports.h"
#include <memory>
#include <functional>
#include "connection_state.h"
#include "trace_level.h"
#include "log_writer.h"
#include "signalr_client_config.h"
#include "signalr_value.h"
namespace signalr
{
class http_client;
class websocket_client;
class hub_connection_impl;
class hub_connection_builder;
class hub_protocol;
class hub_connection
{
public:
typedef std::function<void __cdecl (const std::vector<signalr::value>&)> method_invoked_handler;
SIGNALRCLIENT_API ~hub_connection();
hub_connection(const hub_connection& rhs) = delete;
hub_connection& operator=(const hub_connection&) = delete;
hub_connection(hub_connection&&) = delete;
hub_connection& operator=(hub_connection&&) = delete;
SIGNALRCLIENT_API void __cdecl start(std::function<void(std::exception_ptr)> callback) noexcept;
SIGNALRCLIENT_API void __cdecl stop(std::function<void(std::exception_ptr)> callback) noexcept;
SIGNALRCLIENT_API connection_state __cdecl get_connection_state() const;
SIGNALRCLIENT_API std::string __cdecl get_connection_id() const;
SIGNALRCLIENT_API void __cdecl set_disconnected(const std::function<void __cdecl(std::exception_ptr)>& disconnected_callback);
SIGNALRCLIENT_API void __cdecl set_client_config(const signalr_client_config& config);
SIGNALRCLIENT_API void __cdecl on(const std::string& event_name, const method_invoked_handler& handler);
SIGNALRCLIENT_API void invoke(const std::string& method_name, const std::vector<signalr::value>& arguments = std::vector<signalr::value>(), std::function<void(const signalr::value&, std::exception_ptr)> callback = [](const signalr::value&, std::exception_ptr) {}) noexcept;
SIGNALRCLIENT_API void send(const std::string& method_name, const std::vector<signalr::value>& arguments = std::vector<signalr::value>(), std::function<void(std::exception_ptr)> callback = [](std::exception_ptr) {}) noexcept;
private:
friend class hub_connection_builder;
explicit hub_connection(const std::string& url, std::unique_ptr<hub_protocol>&& hub_protocol,
trace_level trace_level = trace_level::info, std::shared_ptr<log_writer> log_writer = nullptr,
std::function<std::shared_ptr<http_client>(const signalr_client_config&)> http_client_factory = nullptr,
std::function<std::shared_ptr<websocket_client>(const signalr_client_config&)> websocket_factory = nullptr,
bool skip_negotiation = false);
std::shared_ptr<hub_connection_impl> m_pImpl;
};
}