Skip to content

Commit 16e45dc

Browse files
committed
fix: added missing implementations of connected/disconnected
1 parent 1db553b commit 16e45dc

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

Source/Ecsact/Public/EcsactUnreal/Ecsact.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "Misc/Paths.h"
77
#include "EcsactUnreal/EcsactAsyncRunner.h"
88
#include "ecsact/runtime.h"
9+
#include "Engine/World.h"
910

1011
#define LOCTEXT_NAMESPACE "FEcsactModule"
1112

Source/Ecsact/Public/EcsactUnreal/EcsactAsyncRunner.cpp

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ auto UEcsactAsyncRunner::StreamImpl(
4141
}
4242

4343
auto UEcsactAsyncRunner::Connect( //
44-
const char* ConnectionStr,
45-
FAsyncRequestDoneCallback Callback
44+
const char* ConnectionStr,
45+
FAsyncRequestErrorCallback ErrorCallback,
46+
FAsyncRequestDoneCallback Callback
4647
) -> void {
4748
auto req_id = ecsact_async_connect(ConnectionStr);
4849
OnRequestDone(
@@ -54,6 +55,14 @@ auto UEcsactAsyncRunner::Connect( //
5455
}
5556
)
5657
);
58+
OnRequestError(
59+
req_id,
60+
FAsyncRequestErrorCallback::CreateLambda( //
61+
[this, ErrorCallback = std::move(ErrorCallback)](ecsact_async_error err) {
62+
ErrorCallback.ExecuteIfBound(err);
63+
}
64+
)
65+
);
5766
}
5867

5968
auto UEcsactAsyncRunner::Disconnect() -> void {
@@ -86,6 +95,13 @@ auto UEcsactAsyncRunner::OnAsyncErrorRaw(
8695
for(auto req_id : request_ids) {
8796
auto cbs = self->RequestErrorCallbacks.Find(req_id);
8897

98+
UE_LOG(
99+
LogTemp,
100+
Warning,
101+
TEXT("Received request error raw (req=%i)"),
102+
static_cast<int>(req_id)
103+
);
104+
89105
if(cbs && !cbs->IsEmpty()) {
90106
for(auto& cb : *cbs) {
91107
if(!cb.ExecuteIfBound(async_err)) {
@@ -113,6 +129,8 @@ auto UEcsactAsyncRunner::OnExecuteSysErrorRaw(
113129
void* callback_user_data
114130
) -> void {
115131
auto self = static_cast<ThisClass*>(callback_user_data);
132+
133+
UE_LOG(LogTemp, Warning, TEXT("System error"));
116134
}
117135

118136
auto UEcsactAsyncRunner::OnAsyncRequestDoneRaw(
@@ -127,6 +145,13 @@ auto UEcsactAsyncRunner::OnAsyncRequestDoneRaw(
127145
for(auto req_id : request_ids) {
128146
auto cbs = self->RequestDoneCallbacks.Find(req_id);
129147

148+
UE_LOG(
149+
LogTemp,
150+
Warning,
151+
TEXT("Received request done raw (req=%i)"),
152+
static_cast<int>(req_id)
153+
);
154+
130155
if(cbs && !cbs->IsEmpty()) {
131156
for(auto& cb : *cbs) {
132157
if(!cb.ExecuteIfBound()) {
@@ -190,6 +215,12 @@ auto UEcsactAsyncRunner::OnRequestDone(
190215
FAsyncRequestDoneCallback Callback
191216
) -> void {
192217
check(RequestId != ECSACT_INVALID_ID(async_request));
218+
UE_LOG(
219+
LogTemp,
220+
Warning,
221+
TEXT("Adding request done handler (req=%i)"),
222+
static_cast<int>(RequestId)
223+
);
193224
RequestDoneCallbacks.FindOrAdd(RequestId).Add(Callback);
194225
}
195226

@@ -200,3 +231,11 @@ auto UEcsactAsyncRunner::OnRequestError(
200231
check(RequestId != ECSACT_INVALID_ID(async_request));
201232
RequestErrorCallbacks.FindOrAdd(RequestId).Add(Callback);
202233
}
234+
235+
auto UEcsactAsyncRunner::OnConnect(TDelegate<void()> Callback) -> void {
236+
GenericConnectCallbacks.Add(std::move(Callback));
237+
}
238+
239+
auto UEcsactAsyncRunner::OnDisconnect(TDelegate<void()> Callback) -> void {
240+
GenericDisconnectCallbacks.Add(std::move(Callback));
241+
}

Source/Ecsact/Public/EcsactUnreal/EcsactAsyncRunner.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,17 @@ class ECSACT_API UEcsactAsyncRunner //
7070
* Wrapper around ecsact_async_connect
7171
*/
7272
auto Connect( //
73-
const char* ConnectionStr,
74-
FAsyncRequestDoneCallback Callback
73+
const char* ConnectionStr,
74+
FAsyncRequestErrorCallback ErrorCallback,
75+
FAsyncRequestDoneCallback Callback
7576
) -> void;
7677

7778
auto Disconnect() -> void;
7879

80+
auto OnConnect(TDelegate<void()> Callback) -> void override;
81+
82+
auto OnDisconnect(TDelegate<void()> Callback) -> void override;
83+
7984
auto OnRequestDone(
8085
ecsact_async_request_id RequestId,
8186
FAsyncRequestDoneCallback Callback

0 commit comments

Comments
 (0)