-
Notifications
You must be signed in to change notification settings - Fork 0
/
net_core.cpp
60 lines (46 loc) · 1.66 KB
/
net_core.cpp
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
//
// net_core.cpp
// go-socket-client
//
// Copyright © 2023 Yan. All rights reserved.
//
#include "net_core.hpp"
#include "tcp_client.hpp"
static TcpClient _client;
void NetCore::InitHostAndPort(std::string host, std::string backupIp, int port, bool isTls, GetConnectInfo getConnectInfo) {
_client.InitHostAndPort(host, backupIp, port, isTls, getConnectInfo);
}
void NetCore::MakeSureConnected() {
_client.MakeSureConnected();
}
void NetCore::DisconnectAsync(DisconnectCode code, bool shouldReconnect) {
_client.SendDisconnect();
_client.DisconnectAsync(code, shouldReconnect);
}
bool NetCore::Send(std::string payloadType, std::string payload, OnSendRespCallback callback) {
return _client.Send(payloadType, payload, callback);
}
bool NetCore::Send(std::string payloadType, std::string payload, char *data, int dataLen, OnSendRespCallback callback) {
return _client.Send(payloadType, payload, data, dataLen, callback);
}
bool NetCore::SendNoReply(std::string payloadType, std::string payload) {
return _client.SendNoReply(payloadType, payload);
}
void NetCore::SetOnConnStatusChange(OnConnStatusChange onStatusChange) {
_client.SetOnConnStatusChange(onStatusChange);
}
void NetCore::SetOnServerDisconnect(OnServerDisconnect onServerDisconnect) {
_client.SetOnServerDisconnect(onServerDisconnect);
}
void NetCore::SetHttpDns(GetHttpDns getHttpDns) {
_client.SetHttpDns(getHttpDns);
}
void NetCore::SetOnSendReq(OnSendReqCallback callback) {
_client.SetOnSendReq(callback);
}
void NetCore::SetNetType(NetType netType) {
_client.SetNetType(netType);
}
ConnectStatus NetCore::GetConnectStatus() {
return _client.GetConnectStatus();
}